Remove new_repo_without_add_and_commit

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
This commit is contained in:
hi-rustin 2022-11-22 18:56:52 +08:00
parent 89b8a8bb10
commit 25f7d4b09a
2 changed files with 5 additions and 17 deletions

View File

@ -175,20 +175,6 @@ where
(git_project, repo)
}
/// Create a new git repository with a project.
/// Returns both the Project and the git Repository but does not commit.
pub fn new_repo_without_add_and_commit<F>(name: &str, callback: F) -> (Project, git2::Repository)
where
F: FnOnce(ProjectBuilder) -> ProjectBuilder,
{
let mut git_project = project().at(name);
git_project = callback(git_project);
let git_project = git_project.build();
let repo = init(&git_project.root());
(git_project, repo)
}
/// Add all files in the working directory to the git index.
pub fn add(repo: &git2::Repository) {
// FIXME(libgit2/libgit2#2514): apparently, `add_all` will add all submodules

View File

@ -2,7 +2,7 @@
use cargo::core::Edition;
use cargo_test_support::compare::assert_match_exact;
use cargo_test_support::git;
use cargo_test_support::git::{self, init};
use cargo_test_support::paths::{self, CargoPathExt};
use cargo_test_support::registry::{Dependency, Package};
use cargo_test_support::tools;
@ -773,8 +773,10 @@ commit the changes to these files:
#[cargo_test]
fn errors_on_empty_repo() {
let (p, _) =
git::new_repo_without_add_and_commit("foo", |p| p.file("src/lib.rs", "pub fn foo() {}"));
let mut git_project = project().at("foo");
git_project = git_project.file("src/lib.rs", "pub fn foo() {}");
let p = git_project.build();
let _ = init(&p.root());
p.cargo("fix")
.with_status(101)