From 5feaed014f83e83e8accb1a1ff43930cb1fb5e5d Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 13 Jul 2025 23:03:57 +0300 Subject: fix: skip fetching from backup locations when --backup flag is not used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- internal/sync/git_operations.go | 1 - internal/sync/sync.go | 15 +++++++++++---- 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 } -- cgit v1.2.3