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
78 changes: 15 additions & 63 deletions .github/aw/github-agentic-workflows.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .github/workflows/release.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions pkg/workflow/repository_features_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"sync"

"github.com/cli/go-gh/v2"
"github.com/cli/go-gh/v2/pkg/repository"
"github.com/githubnext/gh-aw/pkg/console"
"github.com/githubnext/gh-aw/pkg/logger"
)
Expand Down Expand Up @@ -175,22 +176,23 @@ func getCurrentRepository() (string, error) {

// getCurrentRepositoryUncached fetches the current repository from gh CLI (no caching)
func getCurrentRepositoryUncached() (string, error) {
repositoryFeaturesLog.Print("Fetching current repository from gh CLI")
repositoryFeaturesLog.Print("Fetching current repository using repository.Current()")

// Use gh CLI to get the current repository
// This works when in a git repository with GitHub remote
stdOut, _, err := gh.Exec("repo", "view", "--json", "nameWithOwner", "-q", ".nameWithOwner")
// Use native repository.Current() to get the current repository
// This works when in a git repository with GitHub remote and respects GH_REPO
repo, err := repository.Current()
if err != nil {
return "", fmt.Errorf("failed to get current repository: %w", err)
}

repo := strings.TrimSpace(stdOut.String())
if repo == "" {
return "", fmt.Errorf("repository name is empty")
// Validate that owner and name are not empty
if repo.Owner == "" || repo.Name == "" {
return "", fmt.Errorf("repository owner or name is empty (owner: %q, name: %q)", repo.Owner, repo.Name)
}

repositoryFeaturesLog.Printf("Cached current repository: %s", repo)
return repo, nil
repoName := fmt.Sprintf("%s/%s", repo.Owner, repo.Name)
repositoryFeaturesLog.Printf("Cached current repository: %s", repoName)
return repoName, nil
}

// getRepositoryFeatures gets repository features with caching to amortize API calls
Expand Down