Skip to content

Commit 45c7115

Browse files
vik-nullifyclaude
andcommitted
feat: add --repository flag for non-git environments
Resolution order: --repository flag > GITHUB_REPOSITORY env > git auto-detect. Allows CLI usage outside git repos and CI environments. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7d37359 commit 45c7115

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

internal/commands/context_push.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func RegisterContextPushCommand(parent *cobra.Command, getClient func() *api.Cli
3535

3636
var (
3737
contextType string
38+
repository string
3839
name string
3940
environment string
4041
branch string
@@ -61,13 +62,16 @@ func RegisterContextPushCommand(parent *cobra.Command, getClient func() *api.Cli
6162
return fmt.Errorf("file %s is %d MB, exceeds maximum of %d MB", filePath, info.Size()>>20, maxUploadSize>>20)
6263
}
6364

64-
// Auto-detect git context — check CI env vars first, then git
65-
repo := os.Getenv("GITHUB_REPOSITORY")
65+
// Resolve repository: flag > env var > git auto-detect
66+
repo := repository
67+
if repo == "" {
68+
repo = os.Getenv("GITHUB_REPOSITORY")
69+
}
6670
if repo == "" {
6771
repo = lib.DetectGitContext().Repository
6872
}
6973
if repo == "" {
70-
return fmt.Errorf("could not detect repository — set GITHUB_REPOSITORY or ensure you're in a git repo")
74+
return fmt.Errorf("could not detect repository — use --repository, set GITHUB_REPOSITORY, or run inside a git repo")
7175
}
7276

7377
if branch == "" {
@@ -162,6 +166,7 @@ func RegisterContextPushCommand(parent *cobra.Command, getClient func() *api.Cli
162166
}
163167

164168
pushCmd.Flags().StringVar(&contextType, "type", "", "Context type (terraform, ci_logs, config, deploy, api_spec)")
169+
pushCmd.Flags().StringVar(&repository, "repository", "", "Repository in org/repo format (auto-detected if omitted)")
165170
pushCmd.Flags().StringVar(&name, "name", "", "Logical name for this context (e.g. networking, ecs-api). Auto-detected from file path if omitted.")
166171
pushCmd.Flags().StringVar(&environment, "environment", "", "Deployment environment (development, staging, production, unknown)")
167172
pushCmd.Flags().StringVar(&branch, "branch", "", "Git branch (auto-detected if omitted)")

0 commit comments

Comments
 (0)