summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-07-13 23:03:57 +0300
committerPaul Buetow <paul@buetow.org>2025-07-13 23:03:57 +0300
commit5feaed014f83e83e8accb1a1ff43930cb1fb5e5d (patch)
tree0b0199286b73c0d942bfc172c79595529f329986
parent044a47095716c1953aab2495cc63201aeaba12bf (diff)
fix: skip fetching from backup locations when --backup flag is not used
- Check all organizations (not just active ones) to identify backup locations - Skip fetching from backup remotes when backup is not enabled - Remove duplicate "Fetching" message from fetchRemote function - Prevents "Warning: Remote repository does not exist yet" for backup locations This ensures backup locations are truly opt-in and don't interfere with normal sync operations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
-rw-r--r--internal/sync/git_operations.go1
-rw-r--r--internal/sync/sync.go15
2 files changed, 11 insertions, 5 deletions
diff --git a/internal/sync/git_operations.go b/internal/sync/git_operations.go
index 3bd6618..efa27f5 100644
--- a/internal/sync/git_operations.go
+++ b/internal/sync/git_operations.go
@@ -127,7 +127,6 @@ func getRemotesList() (map[string]bool, error) {
// fetchRemote fetches from a single remote with error handling
func fetchRemote(remote string) error {
- fmt.Printf("Fetching %s\n", remote)
cmd := exec.Command("git", "fetch", remote, "--prune", "--tags")
output, err := cmd.CombinedOutput()
diff --git a/internal/sync/sync.go b/internal/sync/sync.go
index 85372fa..0f51689 100644
--- a/internal/sync/sync.go
+++ b/internal/sync/sync.go
@@ -224,13 +224,19 @@ func (s *Syncer) fetchAll() error {
return err
}
- // Get remotes map to check if it's a backup location
- remotesMap := s.getRemotesMap()
+ // Check all organizations to identify backup locations
+ // We need to check ALL orgs, not just active ones
+ allOrgsMap := make(map[string]*config.Organization)
+ for i := range s.config.Organizations {
+ org := &s.config.Organizations[i]
+ remoteName := s.getRemoteName(org)
+ allOrgsMap[remoteName] = org
+ }
// Fetch from each remote
for remote := range remotes {
- // Skip backup locations if backup is not enabled
- if org, exists := remotesMap[remote]; exists && org.BackupLocation {
+ // Check if this remote is a backup location
+ if org, exists := allOrgsMap[remote]; exists && org.BackupLocation {
if !s.backupEnabled {
// Silently skip - don't even print a message since backup is not enabled
continue
@@ -240,6 +246,7 @@ func (s *Syncer) fetchAll() error {
continue
}
+ fmt.Printf("Fetching %s\n", remote)
if err := fetchRemote(remote); err != nil {
return err
}