diff --git a/src/utils/vcs.rs b/src/utils/vcs.rs index f1d92f05a5..2ec789f0e4 100644 --- a/src/utils/vcs.rs +++ b/src/utils/vcs.rs @@ -284,7 +284,7 @@ fn find_merge_base_ref( } /// Attempts to get the base repository name from git remotes. -/// Prefers "origin" remote if it exists, otherwise uses the first available remote. +/// Prefers "upstream" remote if it exists, then "origin", otherwise uses the first available remote. /// Returns the base repository name if a remote is found. pub fn git_repo_base_repo_name(repo: &git2::Repository) -> Result> { let remotes = repo.remotes()?; @@ -295,8 +295,10 @@ pub fn git_repo_base_repo_name(repo: &git2::Repository) -> Result return Ok(None); } - // Prefer "origin" remote if it exists, otherwise use the first one - let chosen_remote = if remote_names.contains(&"origin") { + // Prefer "upstream" if it exists, then "origin", otherwise use the first one + let chosen_remote = if remote_names.contains(&"upstream") { + "upstream" + } else if remote_names.contains(&"origin") { "origin" } else { remote_names[0]