mirror of
https://github.com/jj-vcs/jj.git
synced 2026-07-08 18:13:08 +08:00
cli/tests: move test_git_colocated_fetch_deleted_or_moved_bookmark to gitoxide
This commit is contained in:
committed by
Baltasar Dinis
parent
05479df69e
commit
071e724c1c
@@ -587,7 +587,7 @@ fn test_git_colocated_fetch_deleted_or_moved_bookmark() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-bookmark = true");
|
||||
let origin_path = test_env.env_root().join("origin");
|
||||
git2::Repository::init(&origin_path).unwrap();
|
||||
git::init(&origin_path);
|
||||
test_env
|
||||
.run_jj_in(&origin_path, ["git", "init", "--git-repo=."])
|
||||
.success();
|
||||
@@ -611,7 +611,7 @@ fn test_git_colocated_fetch_deleted_or_moved_bookmark() {
|
||||
.success();
|
||||
|
||||
let clone_path = test_env.env_root().join("clone");
|
||||
git2::Repository::clone(origin_path.to_str().unwrap(), &clone_path).unwrap();
|
||||
git::clone(&clone_path, origin_path.to_str().unwrap());
|
||||
test_env
|
||||
.run_jj_in(&clone_path, ["git", "init", "--git-repo=."])
|
||||
.success();
|
||||
|
||||
@@ -56,23 +56,26 @@ pub fn init_bare(directory: impl AsRef<Path>) -> gix::Repository {
|
||||
.to_thread_local()
|
||||
}
|
||||
|
||||
pub fn clone(dest_path: &Path, url: &str) -> gix::Repository {
|
||||
let mut prepare_fetch = gix::clone::PrepareFetch::new(
|
||||
url,
|
||||
dest_path,
|
||||
gix::create::Kind::WithWorktree,
|
||||
gix::create::Options::default(),
|
||||
open_options(),
|
||||
)
|
||||
.unwrap();
|
||||
let (mut prepare_checkout, _outcome) = prepare_fetch
|
||||
.fetch_then_checkout(gix::progress::Discard, &gix::interrupt::IS_INTERRUPTED)
|
||||
.unwrap();
|
||||
let (repo, _outcome) = prepare_checkout
|
||||
.main_worktree(gix::progress::Discard, &gix::interrupt::IS_INTERRUPTED)
|
||||
pub fn clone(dest_path: &Path, repo_url: &str) -> gix::Repository {
|
||||
// gitoxide doesn't write the remote HEAD as a symbolic link, which prevents
|
||||
// `jj` from getting it.
|
||||
//
|
||||
// This, plus the fact that the code to clone a repo in gitoxide is non-trivial,
|
||||
// makes it appealing to just spawn a git subprocess
|
||||
let output = std::process::Command::new("git")
|
||||
.args(["clone", repo_url])
|
||||
.arg(dest_path)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
output.status.success(),
|
||||
"git cloning failed with exit code {}:\n{}\n----- stderr -----\n{}",
|
||||
output.status,
|
||||
bstr::BString::from(output.stdout),
|
||||
bstr::BString::from(output.stderr),
|
||||
);
|
||||
|
||||
repo
|
||||
open(dest_path)
|
||||
}
|
||||
|
||||
/// Writes out gitlink entry pointing to the `target_repo`.
|
||||
|
||||
Reference in New Issue
Block a user