Skip to content

Commit

Permalink
Remove new_repo_without_add_and_commit
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
  • Loading branch information
Rustin170506 committed Nov 22, 2022
1 parent f5b02c5 commit e525dd3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
14 changes: 0 additions & 14 deletions crates/cargo-test-support/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions tests/testsuite/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e525dd3

Please sign in to comment.