merge remote module into repo
This commit is contained in:
@@ -130,6 +130,7 @@ fn repo_ref_state_lists_branches_tags_and_head() {
|
||||
assert_eq!(state.refs.len(), 3);
|
||||
}
|
||||
|
||||
/// Creates a repository fixture with the given files.
|
||||
fn fixture(files: &[(&str, &[u8])]) -> (tempfile::TempDir, Repo) {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
gix::init(&dir).expect("init");
|
||||
@@ -144,6 +145,7 @@ fn fixture(files: &[(&str, &[u8])]) -> (tempfile::TempDir, Repo) {
|
||||
(dir, repo)
|
||||
}
|
||||
|
||||
/// Stages and commits every change in the repository.
|
||||
fn commit_all(repo: &Repo, message: &str) {
|
||||
git_run(repo.workdir().expect("workdir"), &["add", "-A"]);
|
||||
git_run(repo.workdir().expect("workdir"), &["commit", "-m", message]);
|
||||
@@ -415,6 +417,7 @@ fn fetch_repo_refs_imports_heads_under_a_prefix() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Runs `git` in `dir`, failing the test on a non-zero exit.
|
||||
fn git_run(dir: &Path, args: &[&str]) -> std::process::Output {
|
||||
let output = Command::new("git")
|
||||
.current_dir(dir)
|
||||
@@ -430,6 +433,24 @@ fn git_run(dir: &Path, args: &[&str]) -> std::process::Output {
|
||||
output
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_git_repos_reports_the_outermost_repository() {
|
||||
let root = tempfile::tempdir().expect("tempdir");
|
||||
let repo_dir = root.path().join("project").join("sub");
|
||||
std::fs::create_dir_all(&repo_dir).expect("mkdir");
|
||||
git_run(&repo_dir, &["init", "-q"]);
|
||||
|
||||
let plain_dir = root.path().join("plain").join("deep");
|
||||
std::fs::create_dir_all(&plain_dir).expect("mkdir");
|
||||
|
||||
let repos = find_git_repos(root.path());
|
||||
|
||||
assert_eq!(repos.len(), 1);
|
||||
assert_eq!(repos[0].path, repo_dir.canonicalize().expect("canonical"));
|
||||
assert!(repos[0].nip34.is_none());
|
||||
}
|
||||
|
||||
/// Creates an empty bare server repository for push tests.
|
||||
fn bare_server(base: &Path, owner: &str, name: &str) -> PathBuf {
|
||||
let repo = base.join(owner).join(format!("{name}.git"));
|
||||
std::fs::create_dir_all(repo.parent().expect("parent")).expect("mkdir");
|
||||
|
||||
Reference in New Issue
Block a user