Skip to content

Commit f3bcf62

Browse files
committed
refactor (#301)
1 parent c8055be commit f3bcf62

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

git-repository/tests/easy/id.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ fn prefix() -> crate::Result {
1212

1313
// TODO: do this in-memory (with or without writing to disk)
1414
assert!(
15-
std::process::Command::new("git")
16-
.current_dir(worktree_dir.path())
17-
.args(["config", "--int", "core.abbrev", "5"])
18-
.status()?
19-
.success(),
15+
git_testtools::run_git(worktree_dir.path(), &["config", "--int", "core.abbrev", "5"])?.success(),
2016
"set core abbrev value successfully"
2117
);
2218

tests/tools/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ pub use tempfile;
1212

1313
static SCRIPT_IDENTITY: Lazy<Mutex<BTreeMap<PathBuf, u32>>> = Lazy::new(|| Mutex::new(BTreeMap::new()));
1414

15+
pub fn run_git(working_dir: &Path, args: &[&str]) -> std::io::Result<std::process::ExitStatus> {
16+
std::process::Command::new("git")
17+
.current_dir(working_dir)
18+
.args(args)
19+
.status()
20+
}
21+
1522
pub fn hex_to_id(hex: &str) -> git_hash::ObjectId {
1623
git_hash::ObjectId::from_hex(hex.as_bytes()).expect("40 bytes hex")
1724
}

0 commit comments

Comments
 (0)