Skip to content

Commit 775f60f

Browse files
runningcodeclaude
andauthored
feat(vcs): Prefer upstream remote over origin for base repo name (#2737)
## Summary Prefer "upstream" remote over "origin" when determining base repository name, following Git fork conventions. 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent a031cfd commit 775f60f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/utils/vcs.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ fn find_merge_base_ref(
284284
}
285285

286286
/// Attempts to get the base repository name from git remotes.
287-
/// Prefers "origin" remote if it exists, otherwise uses the first available remote.
287+
/// Prefers "upstream" remote if it exists, then "origin", otherwise uses the first available remote.
288288
/// Returns the base repository name if a remote is found.
289289
pub fn git_repo_base_repo_name(repo: &git2::Repository) -> Result<Option<String>> {
290290
let remotes = repo.remotes()?;
@@ -295,8 +295,10 @@ pub fn git_repo_base_repo_name(repo: &git2::Repository) -> Result<Option<String>
295295
return Ok(None);
296296
}
297297

298-
// Prefer "origin" remote if it exists, otherwise use the first one
299-
let chosen_remote = if remote_names.contains(&"origin") {
298+
// Prefer "upstream" if it exists, then "origin", otherwise use the first one
299+
let chosen_remote = if remote_names.contains(&"upstream") {
300+
"upstream"
301+
} else if remote_names.contains(&"origin") {
300302
"origin"
301303
} else {
302304
remote_names[0]

0 commit comments

Comments
 (0)