Skip to content

Commit 42e9cb4

Browse files
committed
feat: always use tags in our mirror repos
1 parent 3034966 commit 42e9cb4

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

rust/patchable/src/main.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -480,21 +480,7 @@ fn main() -> Result<()> {
480480
let mut push_options = git2::PushOptions::new();
481481
push_options.remote_callbacks(callbacks);
482482

483-
// Check if the reference is a tag or branch by inspecting the git repository
484-
let refspec = {
485-
let tag_ref = format!("refs/tags/{}", base);
486-
let is_tag = product_repo
487-
.find_reference(&tag_ref)
488-
.is_ok();
489-
490-
if is_tag {
491-
format!("{}:refs/tags/{}", base_commit, base)
492-
} else {
493-
// Assume it's a branch as default behavior
494-
format!("{}:refs/heads/{}", base_commit, base)
495-
}
496-
};
497-
483+
let refspec = format!("{}:refs/tags/{}", base_commit, base);
498484
tracing::info!(refspec = refspec, "constructed push refspec");
499485

500486
mirror_remote

rust/patchable/src/repo.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ pub fn resolve_and_fetch_commitish(
176176
&[commitish],
177177
Some(
178178
FetchOptions::new()
179-
// Tags need to be present to later determine whether `commitish` is a tag or not
180-
// Patchable needs to know this when initializing a repository with the `--mirrored` option (to construct the refspec)
181-
.download_tags(git2::AutotagOption::Auto)
179+
.update_fetchhead(true)
182180
.remote_callbacks(callbacks)
183181
// TODO: could be 1, CLI option maybe?
184182
.depth(0),
@@ -191,7 +189,8 @@ pub fn resolve_and_fetch_commitish(
191189
refs: vec![commitish.to_string()],
192190
})?;
193191
tracing::info!("fetched base commit");
194-
repo.revparse_single(commitish)
192+
// FETCH_HEAD is written by Remote::fetch to be the last reference fetched
193+
repo.revparse_single("FETCH_HEAD")
195194
.and_then(|obj| obj.peel_to_commit())
196195
}
197196
Err(err) => Err(err),

0 commit comments

Comments
 (0)