You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In cargo-generate/cargo-generate#1460 we try to get away from git2 and migrate to gix. It looks all promising so far, only one thing does not work. It is checking out a specific branch, tag or revision.
let (mut prepare_checkout, _) = if let Some(branch) = self.branch {
let mut opts = Options::default();
let ref_spec = gix::refspec::parse(branch.as_str().into(), Operation::Fetch).unwrap();
dbg!(ref_spec);
opts.extra_refspecs.push(ref_spec.to_owned());
prepare_clone.with_fetch_options(opts)
Then I would expect that calling
let (repo, _) = prepare_checkout
.main_worktree(gix::progress::Discard, &gix::interrupt::IS_INTERRUPTED)?;
would check out the specific branch, tag or revision.
Git behavior
git2 has a .checkout_tree that does behave exactly as described above
Current behavior 😯
In cargo-generate/cargo-generate#1460 we try to get away from
git2and migrate togix. It looks all promising so far, only one thing does not work. It is checking out a specific branch, tag or revision.What gix does, (see the code https://github.com/cargo-generate/cargo-generate/pull/1460/files#diff-dbcccd0cf247f619f177ddeb85fe8dfc4eb4c71c0de0bb47ec839764c7d4918dR82) it checks out the default branch (in our test case it is
main).Expected behavior 🤔
when we configure the
prepare_clonewith the refsepc like in https://github.com/cargo-generate/cargo-generate/pull/1460/files#diff-dbcccd0cf247f619f177ddeb85fe8dfc4eb4c71c0de0bb47ec839764c7d4918dR72or here the excerpt:
Then I would expect that calling
would check out the specific branch, tag or revision.
Git behavior
git2 has a
.checkout_treethat does behave exactly as described abovehere is some sample code: https://github.com/cargo-generate/cargo-generate/blob/0e9471d4991764270de8940c7695d13f932c086b/src/git/clone_tool.rs#L183
Steps to reproduce 🕹
gh pr checkout 1460)cargo test