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
26 changes: 26 additions & 0 deletions cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,32 @@ func detectSyncIssues(gitClient git.GitClient, stackBranches []stack.StackBranch
} else if err != nil && verbose {
fmt.Printf(" ⚠ Could not check if branch is behind: %v\n", err)
}

// Check if local branch differs from remote (needs push)
if gitClient.RemoteBranchExists(branch.Name) {
if verbose {
fmt.Printf(" Checking if local branch differs from origin/%s...\n", branch.Name)
}
localHash, localErr := gitClient.GetCommitHash(branch.Name)
remoteHash, remoteErr := gitClient.GetCommitHash("origin/" + branch.Name)
if localErr == nil && remoteErr == nil && localHash != remoteHash {
if verbose {
fmt.Printf(" ✗ Local branch differs from origin/%s (needs push)\n", branch.Name)
}
issues = append(issues, fmt.Sprintf(" - Branch '%s' differs from origin (needs push)", branch.Name))
} else if localErr == nil && remoteErr == nil && verbose {
fmt.Printf(" ✓ Local branch matches origin/%s\n", branch.Name)
} else if verbose {
if localErr != nil {
fmt.Printf(" ⚠ Could not get local commit hash: %v\n", localErr)
}
if remoteErr != nil {
fmt.Printf(" ⚠ Could not get remote commit hash: %v\n", remoteErr)
}
}
} else if verbose {
fmt.Printf(" ℹ No remote branch origin/%s found\n", branch.Name)
}
}

return &syncIssuesResult{
Expand Down
2 changes: 2 additions & 0 deletions cmd/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func TestDetectSyncIssues(t *testing.T) {
prCache: make(map[string]*github.PRInfo),
setupMocks: func(mockGit *testutil.MockGitClient) {
mockGit.On("IsCommitsBehind", "feature-a", "main").Return(true, nil)
mockGit.On("RemoteBranchExists", "feature-a").Return(false)
},
expectedIssues: 1,
expectedMerged: 0,
Expand Down Expand Up @@ -240,6 +241,7 @@ func TestDetectSyncIssues(t *testing.T) {
setupMocks: func(mockGit *testutil.MockGitClient) {
mockGit.On("GetDefaultBranch").Return("main")
mockGit.On("IsCommitsBehind", "feature-b", "feature-a").Return(false, nil)
mockGit.On("RemoteBranchExists", "feature-b").Return(false)
},
expectedIssues: 1, // Issue because parent is merged
expectedMerged: 0,
Expand Down
4 changes: 0 additions & 4 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ func runSync(gitClient git.GitClient, githubClient github.GitHubClient) error {
fmt.Printf("✓ Added '%s' to stack with parent '%s'\n", originalBranch, baseBranch)
}

fmt.Println()
fmt.Println("Syncing stack...")
fmt.Println()

// Start parallel fetch operations (git fetch and GitHub PR fetch)
// These are the slowest operations and have no dependencies between them
var wg sync.WaitGroup
Expand Down