Skip to content
Merged
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
8 changes: 5 additions & 3 deletions src/utils/vcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<String>> {
let remotes = repo.remotes()?;
Expand All @@ -295,8 +295,10 @@ pub fn git_repo_base_repo_name(repo: &git2::Repository) -> Result<Option<String>
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]
Expand Down