Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/cli/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/githubnext/gh-aw/pkg/cli/fileutil"
"github.com/githubnext/gh-aw/pkg/console"
"github.com/githubnext/gh-aw/pkg/constants"
"github.com/githubnext/gh-aw/pkg/ghhelper"
"github.com/githubnext/gh-aw/pkg/logger"
"github.com/githubnext/gh-aw/pkg/parser"
"github.com/githubnext/gh-aw/pkg/timeutil"
Expand Down Expand Up @@ -393,7 +392,7 @@ func fetchWorkflowRunMetadata(runInfo RunURLInfo, verbose bool) (WorkflowRun, er
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Executing: gh %s", strings.Join(args, " "))))
}

cmd := ghhelper.ExecGH(args...)
cmd := workflow.ExecGH(args...)
output, err := cmd.CombinedOutput()
if err != nil {
if verbose {
Expand Down
5 changes: 2 additions & 3 deletions pkg/cli/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"github.com/githubnext/gh-aw/pkg/console"
"github.com/githubnext/gh-aw/pkg/constants"
"github.com/githubnext/gh-aw/pkg/ghhelper"
"github.com/githubnext/gh-aw/pkg/logger"
"github.com/githubnext/gh-aw/pkg/timeutil"
"github.com/githubnext/gh-aw/pkg/workflow"
Expand Down Expand Up @@ -139,7 +138,7 @@ func fetchJobStatuses(runID int64, verbose bool) (int, error) {
fmt.Println(console.FormatVerboseMessage(fmt.Sprintf("Fetching job statuses for run %d", runID)))
}

cmd := ghhelper.ExecGH("api", fmt.Sprintf("repos/{owner}/{repo}/actions/runs/%d/jobs", runID), "--jq", ".jobs[] | {name: .name, status: .status, conclusion: .conclusion}")
cmd := workflow.ExecGH("api", fmt.Sprintf("repos/{owner}/{repo}/actions/runs/%d/jobs", runID), "--jq", ".jobs[] | {name: .name, status: .status, conclusion: .conclusion}")
output, err := cmd.CombinedOutput()
if err != nil {
if verbose {
Expand Down Expand Up @@ -185,7 +184,7 @@ func fetchJobDetails(runID int64, verbose bool) ([]JobInfoWithDuration, error) {
fmt.Fprintln(os.Stderr, console.FormatVerboseMessage(fmt.Sprintf("Fetching job details for run %d", runID)))
}

cmd := ghhelper.ExecGH("api", fmt.Sprintf("repos/{owner}/{repo}/actions/runs/%d/jobs", runID), "--jq", ".jobs[] | {name: .name, status: .status, conclusion: .conclusion, started_at: .started_at, completed_at: .completed_at}")
cmd := workflow.ExecGH("api", fmt.Sprintf("repos/{owner}/{repo}/actions/runs/%d/jobs", runID), "--jq", ".jobs[] | {name: .name, status: .status, conclusion: .conclusion, started_at: .started_at, completed_at: .completed_at}")
output, err := cmd.CombinedOutput()
if err != nil {
if verbose {
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/logs_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

"github.com/githubnext/gh-aw/pkg/cli/fileutil"
"github.com/githubnext/gh-aw/pkg/console"
"github.com/githubnext/gh-aw/pkg/ghhelper"
"github.com/githubnext/gh-aw/pkg/workflow"
)

// flattenSingleFileArtifacts checks artifact directories and flattens any that contain a single file
Expand Down Expand Up @@ -97,7 +97,7 @@ func downloadWorkflowRunLogs(runID int64, outputDir string, verbose bool) error

// Use gh api to download the logs zip file
// The endpoint returns a 302 redirect to the actual zip file
cmd := ghhelper.ExecGH("api", "repos/{owner}/{repo}/actions/runs/"+strconv.FormatInt(runID, 10)+"/logs")
cmd := workflow.ExecGH("api", "repos/{owner}/{repo}/actions/runs/"+strconv.FormatInt(runID, 10)+"/logs")
output, err := cmd.Output()
if err != nil {
// Check for authentication errors
Expand Down Expand Up @@ -268,7 +268,7 @@ func downloadRunArtifacts(runID int64, outputDir string, verbose bool) error {
spinner.Start()
}

cmd := ghhelper.ExecGH("run", "download", strconv.FormatInt(runID, 10), "--dir", outputDir)
cmd := workflow.ExecGH("run", "download", strconv.FormatInt(runID, 10), "--dir", outputDir)
output, err := cmd.CombinedOutput()

// Stop spinner
Expand Down
12 changes: 6 additions & 6 deletions pkg/cli/pr_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"time"

"github.com/githubnext/gh-aw/pkg/console"
"github.com/githubnext/gh-aw/pkg/ghhelper"
"github.com/githubnext/gh-aw/pkg/parser"
"github.com/githubnext/gh-aw/pkg/workflow"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -100,15 +100,15 @@ func parsePRURL(prURL string) (owner, repo string, prNumber int, err error) {
// checkRepositoryAccess checks if the current user has write access to the target repository
func checkRepositoryAccess(owner, repo string) (bool, error) {
// Get current user
cmd := ghhelper.ExecGH("api", "/user", "--jq", ".login")
cmd := workflow.ExecGH("api", "/user", "--jq", ".login")
output, err := cmd.Output()
if err != nil {
return false, fmt.Errorf("failed to get current user: %w", err)
}
username := strings.TrimSpace(string(output))

// Check user's permission level for the repository
cmd = ghhelper.ExecGH("api", fmt.Sprintf("/repos/%s/%s/collaborators/%s/permission", owner, repo, username))
cmd = workflow.ExecGH("api", fmt.Sprintf("/repos/%s/%s/collaborators/%s/permission", owner, repo, username))
output, err = cmd.Output()
if err != nil {
// If we get an error, it likely means we don't have access or the repo doesn't exist
Expand All @@ -133,7 +133,7 @@ func checkRepositoryAccess(owner, repo string) (bool, error) {
// createForkIfNeeded creates a fork of the target repository and returns the fork repo name
func createForkIfNeeded(targetOwner, targetRepo string, verbose bool) (forkOwner, forkRepo string, err error) {
// Get current user
cmd := ghhelper.ExecGH("api", "/user", "--jq", ".login")
cmd := workflow.ExecGH("api", "/user", "--jq", ".login")
output, err := cmd.Output()
if err != nil {
return "", "", fmt.Errorf("failed to get current user: %w", err)
Expand Down Expand Up @@ -170,7 +170,7 @@ func createForkIfNeeded(targetOwner, targetRepo string, verbose bool) (forkOwner
// fetchPRInfo fetches detailed information about a pull request
func fetchPRInfo(owner, repo string, prNumber int) (*PRInfo, error) {
// Fetch PR details using gh API
cmd := ghhelper.ExecGH("api", fmt.Sprintf("/repos/%s/%s/pulls/%d", owner, repo, prNumber),
cmd := workflow.ExecGH("api", fmt.Sprintf("/repos/%s/%s/pulls/%d", owner, repo, prNumber),
"--jq", `{
number: .number,
title: .title,
Expand Down Expand Up @@ -268,7 +268,7 @@ func applyPatchToRepo(patchFile string, prInfo *PRInfo, targetOwner, targetRepo
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Getting default branch of target repository..."))
}

defaultBranchCmd := ghhelper.ExecGH("api", fmt.Sprintf("/repos/%s/%s", targetOwner, targetRepo), "--jq", ".default_branch")
defaultBranchCmd := workflow.ExecGH("api", fmt.Sprintf("/repos/%s/%s", targetOwner, targetRepo), "--jq", ".default_branch")
defaultBranchOutput, err := defaultBranchCmd.Output()
if err != nil {
return "", fmt.Errorf("failed to get default branch: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/trial_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/githubnext/gh-aw/pkg/cli/fileutil"
"github.com/githubnext/gh-aw/pkg/console"
"github.com/githubnext/gh-aw/pkg/constants"
"github.com/githubnext/gh-aw/pkg/ghhelper"

"github.com/githubnext/gh-aw/pkg/logger"
"github.com/githubnext/gh-aw/pkg/parser"
"github.com/githubnext/gh-aw/pkg/workflow"
Expand Down Expand Up @@ -482,7 +482,7 @@ func RunWorkflowTrials(workflowSpecs []string, logicalRepoSpec string, cloneRepo

// getCurrentGitHubUsername gets the current GitHub username from gh CLI
func getCurrentGitHubUsername() (string, error) {
cmd := ghhelper.ExecGH("api", "user", "--jq", ".login")
cmd := workflow.ExecGH("api", "user", "--jq", ".login")
output, err := cmd.Output()
if err != nil {
return "", fmt.Errorf("failed to get GitHub username: %w", err)
Expand Down
12 changes: 6 additions & 6 deletions pkg/cli/update_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

"github.com/githubnext/gh-aw/pkg/console"
"github.com/githubnext/gh-aw/pkg/constants"
"github.com/githubnext/gh-aw/pkg/ghhelper"
"github.com/githubnext/gh-aw/pkg/parser"
"github.com/githubnext/gh-aw/pkg/workflow"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -429,7 +429,7 @@ func resolveLatestRelease(repo, currentRef string, allowMajor, verbose bool) (st
}

// Use gh CLI to get releases
cmd := ghhelper.ExecGH("api", fmt.Sprintf("/repos/%s/releases", repo), "--jq", ".[].tag_name")
cmd := workflow.ExecGH("api", fmt.Sprintf("/repos/%s/releases", repo), "--jq", ".[].tag_name")
output, err := cmd.Output()
if err != nil {
return "", fmt.Errorf("failed to fetch releases: %w", err)
Expand Down Expand Up @@ -486,7 +486,7 @@ func resolveLatestRelease(repo, currentRef string, allowMajor, verbose bool) (st
// isBranchRef checks if a ref is a branch in the repository
func isBranchRef(repo, ref string) (bool, error) {
// Use gh CLI to list branches
cmd := ghhelper.ExecGH("api", fmt.Sprintf("/repos/%s/branches", repo), "--jq", ".[].name")
cmd := workflow.ExecGH("api", fmt.Sprintf("/repos/%s/branches", repo), "--jq", ".[].name")
output, err := cmd.Output()
if err != nil {
return false, err
Expand All @@ -509,7 +509,7 @@ func resolveBranchHead(repo, branch string, verbose bool) (string, error) {
}

// Use gh CLI to get branch info
cmd := ghhelper.ExecGH("api", fmt.Sprintf("/repos/%s/branches/%s", repo, branch), "--jq", ".commit.sha")
cmd := workflow.ExecGH("api", fmt.Sprintf("/repos/%s/branches/%s", repo, branch), "--jq", ".commit.sha")
output, err := cmd.Output()
if err != nil {
return "", fmt.Errorf("failed to fetch branch info: %w", err)
Expand All @@ -530,7 +530,7 @@ func resolveDefaultBranchHead(repo string, verbose bool) (string, error) {
}

// First get the default branch name
cmd := ghhelper.ExecGH("api", fmt.Sprintf("/repos/%s", repo), "--jq", ".default_branch")
cmd := workflow.ExecGH("api", fmt.Sprintf("/repos/%s", repo), "--jq", ".default_branch")
output, err := cmd.Output()
if err != nil {
return "", fmt.Errorf("failed to fetch repository info: %w", err)
Expand Down Expand Up @@ -692,7 +692,7 @@ func downloadWorkflowContent(repo, path, ref string, verbose bool) ([]byte, erro
}

// Use gh CLI to download the file
cmd := ghhelper.ExecGH("api", fmt.Sprintf("/repos/%s/contents/%s?ref=%s", repo, path, ref), "--jq", ".content")
cmd := workflow.ExecGH("api", fmt.Sprintf("/repos/%s/contents/%s?ref=%s", repo, path, ref), "--jq", ".content")
output, err := cmd.Output()
if err != nil {
return nil, fmt.Errorf("failed to fetch file content: %w", err)
Expand Down
41 changes: 0 additions & 41 deletions pkg/ghhelper/gh_helper.go

This file was deleted.

157 changes: 0 additions & 157 deletions pkg/ghhelper/gh_helper_test.go

This file was deleted.

Loading
Loading