Skip to content

Commit 6cfa65d

Browse files
committed
fix
1 parent 85129e6 commit 6cfa65d

File tree

2 files changed

+11
-31
lines changed

2 files changed

+11
-31
lines changed

tests/repos/test_file.rs

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,8 @@ impl<'a> TestFile<'a> {
120120
};
121121
}
122122

123-
// Run blame to get authorship - use relative path from repo root
124-
let filename = file_path
125-
.strip_prefix(&repo.path)
126-
.expect("file path should be within repo")
127-
.to_str()
128-
.expect("valid path");
123+
// Run blame to get authorship
124+
let filename = file_path.to_str().expect("valid path");
129125
let blame_result = repo.git_ai(&["blame", filename]);
130126

131127
let lines = if let Ok(blame_output) = blame_result {
@@ -217,11 +213,7 @@ impl<'a> TestFile<'a> {
217213
}
218214

219215
pub fn assert_blame_snapshot(&self) {
220-
let filename = self.file_path
221-
.strip_prefix(&self.repo.path)
222-
.expect("file path should be within repo")
223-
.to_str()
224-
.expect("valid path");
216+
let filename = self.file_path.to_str().expect("valid path");
225217
let blame_output = self
226218
.repo
227219
.git_ai(&["blame", filename])
@@ -234,12 +226,8 @@ impl<'a> TestFile<'a> {
234226
pub fn assert_lines_and_blame<T: Into<ExpectedLine>>(&mut self, lines: Vec<T>) {
235227
let expected_lines: Vec<ExpectedLine> = lines.into_iter().map(|l| l.into()).collect();
236228

237-
// Get blame output - use relative path from repo root
238-
let filename = self.file_path
239-
.strip_prefix(&self.repo.path)
240-
.expect("file path should be within repo")
241-
.to_str()
242-
.expect("valid path");
229+
// Get blame output
230+
let filename = self.file_path.to_str().expect("valid path");
243231
let blame_output = self
244232
.repo
245233
.git_ai(&["blame", filename])
@@ -312,12 +300,8 @@ impl<'a> TestFile<'a> {
312300
pub fn assert_committed_lines<T: Into<ExpectedLine>>(&mut self, lines: Vec<T>) {
313301
let expected_lines: Vec<ExpectedLine> = lines.into_iter().map(|l| l.into()).collect();
314302

315-
// Get blame output - use relative path from repo root
316-
let filename = self.file_path
317-
.strip_prefix(&self.repo.path)
318-
.expect("file path should be within repo")
319-
.to_str()
320-
.expect("valid path");
303+
// Get blame output
304+
let filename = self.file_path.to_str().expect("valid path");
321305
let blame_output = self
322306
.repo
323307
.git_ai(&["blame", filename])
@@ -446,12 +430,8 @@ impl<'a> TestFile<'a> {
446430

447431
/// Assert that the file at the given path matches the expected contents and authorship
448432
pub fn assert_blame_contents_expected(&self) {
449-
// Get blame output - use relative path from repo root
450-
let filename = self.file_path
451-
.strip_prefix(&self.repo.path)
452-
.expect("file path should be within repo")
453-
.to_str()
454-
.expect("valid path");
433+
// Get blame output
434+
let filename = self.file_path.to_str().expect("valid path");
455435
let blame_output = self
456436
.repo
457437
.git_ai(&["blame", filename])

tests/repos/test_repo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use super::test_file::TestFile;
1414

1515
#[derive(Clone, Debug)]
1616
pub struct TestRepo {
17-
pub path: PathBuf,
17+
path: PathBuf,
1818
}
1919

2020
impl TestRepo {
@@ -216,7 +216,7 @@ impl TestRepo {
216216
}
217217

218218
pub fn stage_all_and_commit(&self, message: &str) -> Result<NewCommit, String> {
219-
println!("stage_all_and_commit: {:?}", self.git(&["add", "-A"]).expect("add --all should succeed"));
219+
self.git(&["add", "-A"]).expect("add --all should succeed");
220220
self.commit(message)
221221
}
222222

0 commit comments

Comments
 (0)