Skip to content

Commit d396e78

Browse files
runningcodeclaude
andcommitted
fix(build): Use merge-base commit SHA as base reference instead of branch name
Previously the base ref detection would only work if a local branch pointed to the exact merge-base commit. This implementation now returns the merge-base commit SHA directly, enabling automatic base reference detection in all cases where a merge-base can be determined. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f4d5564 commit d396e78

2 files changed

Lines changed: 6 additions & 18 deletions

File tree

src/commands/build/upload.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
178178
repo_ref
179179
.and_then(|r| match git_repo_base_ref(r, &cached_remote) {
180180
Ok(Some(base_ref_name)) => {
181-
debug!("Found base branch reference: {}", base_ref_name);
181+
debug!("Found base reference: {}", base_ref_name);
182182
Some(base_ref_name)
183183
}
184184
Ok(None) => {
185-
warn!("No base branch reference found (no local branch points to merge-base)");
185+
warn!("No base reference found (could not determine merge-base)");
186186
None
187187
}
188188
Err(e) => {

src/utils/vcs.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -292,22 +292,10 @@ fn find_merge_base_ref(
292292
let remote_commit = remote_ref.peel_to_commit()?;
293293
let merge_base_oid = repo.merge_base(head_commit.id(), remote_commit.id())?;
294294

295-
// Try to find a branch name that points to this commit
296-
let branch_name = repo
297-
.branches(Some(git2::BranchType::Local))?
298-
.flatten()
299-
.find_map(|(branch, _)| {
300-
let branch_commit = branch.get().peel_to_commit().ok()?;
301-
if branch_commit.id() == merge_base_oid {
302-
let branch_name = branch.name().ok()??;
303-
debug!("Found base branch reference: {}", branch_name);
304-
Some(branch_name.to_owned())
305-
} else {
306-
None
307-
}
308-
});
309-
310-
Ok(branch_name)
295+
// Return the merge-base commit SHA as the base reference
296+
let merge_base_sha = merge_base_oid.to_string();
297+
debug!("Found merge-base commit as base reference: {}", merge_base_sha);
298+
Ok(Some(merge_base_sha))
311299
}
312300

313301
fn find_reference_url(repo: &str, repos: &[Repo]) -> Result<Option<String>> {

0 commit comments

Comments
 (0)