summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-06-24 00:06:45 +0300
committerPaul Buetow <paul@buetow.org>2025-06-24 00:06:45 +0300
commite637f4fbb06b1c0661d2e77ce79d0d5149ac5c47 (patch)
tree2c975d88f76b6d7664c6ebef9261566a43637cbb /cmd
parentc3837b71a6c6dbb0292091922d209679533ec90d (diff)
Ensure proper exit codes for all error conditions
- Exit with code 1 when no action is specified (show usage) - Remove redundant failedRepos tracking since we stop on first error - Simplify code by removing unnecessary failure tracking arrays - Add test script to verify exit code behavior - All errors now consistently exit with code 1 - Successful operations exit with code 0 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gitsyncer/main.go30
1 files changed, 5 insertions, 25 deletions
diff --git a/cmd/gitsyncer/main.go b/cmd/gitsyncer/main.go
index 95305df..b7b974d 100644
--- a/cmd/gitsyncer/main.go
+++ b/cmd/gitsyncer/main.go
@@ -224,7 +224,7 @@ func main() {
}
syncer := sync.New(cfg, workDir)
- failedRepos := []string{}
+ successCount := 0
for i, repo := range cfg.Repositories {
fmt.Printf("\n[%d/%d] Syncing %s...\n", i+1, len(cfg.Repositories), repo)
@@ -245,14 +245,7 @@ func main() {
fmt.Printf("Stopping sync due to error.\n")
os.Exit(1)
}
- }
-
- if len(failedRepos) > 0 {
- fmt.Printf("\nFailed to sync %d repository(ies):\n", len(failedRepos))
- for _, repo := range failedRepos {
- fmt.Printf(" - %s\n", repo)
- }
- os.Exit(1)
+ successCount++
}
fmt.Printf("\nSuccessfully synced all %d repositories!\n", len(cfg.Repositories))
@@ -329,7 +322,6 @@ func main() {
fmt.Printf("\nStarting sync of %d repositories...\n", len(repoNames))
syncer := sync.New(cfg, workDir)
- failedRepos := []string{}
successCount := 0
// Get Codeberg repos for description
@@ -369,13 +361,6 @@ func main() {
fmt.Printf("\n=== Summary ===\n")
fmt.Printf("Successfully synced: %d repositories\n", successCount)
-
- if len(failedRepos) > 0 {
- fmt.Printf("Failed to sync: %d repositories\n", len(failedRepos))
- for _, repo := range failedRepos {
- fmt.Printf(" - %s\n", repo)
- }
- }
} // End of if !dryRun
if !syncGitHubPublic {
@@ -442,7 +427,6 @@ func main() {
fmt.Printf("\nStarting sync of %d repositories...\n", len(repoNames))
syncer := sync.New(cfg, workDir)
- failedRepos := []string{}
successCount := 0
// Get GitHub repos for description
@@ -465,13 +449,6 @@ func main() {
fmt.Printf("\n=== Summary ===\n")
fmt.Printf("Successfully synced: %d repositories\n", successCount)
-
- if len(failedRepos) > 0 {
- fmt.Printf("Failed to sync: %d repositories\n", len(failedRepos))
- for _, repo := range failedRepos {
- fmt.Printf(" - %s\n", repo)
- }
- }
} // End of if !dryRun
os.Exit(0)
@@ -499,4 +476,7 @@ func main() {
fmt.Println(" --dry-run Show what would be done without doing it")
fmt.Println("\nGitHub Token:")
fmt.Println(" Set via: config file, GITHUB_TOKEN env var, or ~/.gitsyncer_github_token file")
+
+ // Exit with error code when no action was specified
+ os.Exit(1)
} \ No newline at end of file