History

fix(gix-tix): make tests portable to Windows

Windows runners exposed platform-specific snapshot metadata and filenames, and could not let external editors replace open temporary files. Use portable snapshots and paths, close editor tempfiles before invoking PowerShell-backed replacement editors, and mark shell fixtures executable. Keep exact-byte and index tests deterministic by disabling automatic line-ending conversion only in their temporary repositories, removing the override before configuration snapshots. Identify the current linked worktree by its canonical per-worktree Git directory so undo and redo update its index when worktree paths have different representations.

Codex committed 2 months ago

Commit 75dca4f1 parent b72684324 files · +141 −77Browse files

Unified · Split

24 files
  1. gix-tix/src/command.rs +7 −2
  2. gix-tix/src/command/enrich.rs +7 −1
  3. gix-tix/src/command/new.rs +2 −0
  4. gix-tix/src/command/reword.rs +15 −3
  5. gix-tix/src/edit/create.rs +1 −0
  6. gix-tix/src/edit/forget.rs +1 −0
  7. gix-tix/src/edit/mod.rs +7 −5
  8. gix-tix/src/edit/rebase.rs +1 −1
  9. gix-tix/src/edit/review.rs +3 −1
  10. gix-tix/src/edit/snapshots/gix_tix__edit__rebase__tests__reworded-middle-stack.snap +8 −19
  11. gix-tix/src/edit/snapshots/gix_tix__edit__review__tests__changed-review-with-successors.snap +9 −23
  12. gix-tix/src/edit/snapshots/gix_tix__edit__time_travel__tests__accepted-pending-rebase-conflict.snap +7 −17
  13. gix-tix/src/edit/stash.rs +1 −0
  14. gix-tix/src/edit/time_travel.rs +4 −1
  15. gix-tix/src/edit/todo.rs +6 −1
  16. gix-tix/src/edit/undo.rs +6 −1
  17. gix-tix/src/lib.rs +3 −2
  18. gix-tix/src/test_repository.rs +44 −0
  19. gix-tix/tests/fixtures/create_commit.sh +0 −0
  20. gix-tix/tests/fixtures/forget_commit.sh +0 −0
  21. gix-tix/tests/fixtures/rebase_conflict.sh +0 −0
  22. gix-tix/tests/fixtures/rebase_edit.sh +0 −0
  23. gix-tix/tests/fixtures/replace-editor.ps1 +9 −0
  24. gix-tix/tests/fixtures/split_commit.sh +0 −0
gix-tix/src/command.rs+7−2
@@ -1979,8 +1979,13 @@ mod tests { · 1978 unmodified lines
19791979 }
19801980
19811981 let fixture = gix_testtools::scripted_fixture_writable("split_commit.sh")?;
1982− let repository =
1983− crate::test_repository::open_with(fixture.path(), ["core.editor=sed -i.bak -e 's/^what$/split/'"])?;
1982+ let repository = crate::test_repository::open_with(
1983+ fixture.path(),
1984+ [format!(
1985+ "core.editor={}",
1986+ crate::test_repository::replacing_editor("what", "split")
1987+ )],
1988+ )?;
19841989 let graph = crate::edit::loaded_view_graph(&repository)?;
19851990 let original = repository.head_id()?.detach();
19861991 crate::enrich::set_note(&repository, original, Some(b"source marker"))?;
gix-tix/src/command/enrich.rs+7−1
@@ -281,7 +281,13 @@ mod tests { · 280 unmodified lines
281281 #[test]
282282 fn editors_preserve_other_enrichments() -> gix_testtools::Result {
283283 let fixture = gix_testtools::scripted_fixture_writable("history.sh")?;
284− let repository = crate::test_repository::open_with(fixture.path(), ["core.editor=sed -i.bak -e 's/old/new/'"])?;
284+ let repository = crate::test_repository::open_with(
285+ fixture.path(),
286+ [format!(
287+ "core.editor={}",
288+ crate::test_repository::replacing_editor("old", "new")
289+ )],
290+ )?;
285291 let topic = repository.rev_parse_single("topic")?.detach();
286292 crate::enrich::ensure_todo(&repository, topic, true)?;
287293 crate::enrich::set_note(&repository, topic, Some(b"old\n"))?;
gix-tix/src/command/new.rs+2−0
@@ -222,6 +222,7 @@ mod tests { · 221 unmodified lines
222222 fn unchanged_selected_trees_require_allow_empty() -> gix_testtools::Result {
223223 for worktree in [false, true] {
224224 let fixture = gix_testtools::scripted_fixture_writable("create_commit.sh")?;
225+ crate::test_repository::disable_autocrlf(fixture.path())?;
225226 if worktree {
226227 git(fixture.path(), &["checkout", "--", "tracked"])?;
227228 } else {
@@ -263,6 +264,7 @@ mod tests { · 35 unmodified lines
263264 #[test]
264265 fn unchanged_worktree_untracked_requires_allow_empty() -> gix_testtools::Result {
265266 let fixture = gix_testtools::scripted_fixture_writable("create_commit.sh")?;
267+ crate::test_repository::disable_autocrlf(fixture.path())?;
266268 git(fixture.path(), &["clean", "-fdq"])?;
267269 git(fixture.path(), &["checkout", "--", "tracked"])?;
268270 let parent = git(fixture.path(), &["rev-parse", "HEAD^{tree}"])?;
gix-tix/src/command/reword.rs+15−3
@@ -320,7 +320,10 @@ mod tests { · 319 unmodified lines
320320 fn attached_head_needs_no_pin() -> gix_testtools::Result {
321321 let fixture = gix_testtools::scripted_fixture_writable("rebase_edit.sh")?;
322322 run(
323− open(fixture.path(), "sed -i.bak -e 's/^tip$/rewritten tip/'")?,
323+ open(
324+ fixture.path(),
325+ &crate::test_repository::replacing_editor("tip", "rewritten tip"),
326+ )?,
324327 args("HEAD"),
325328 )?;
326329
@@ -362,7 +365,10 @@ mod tests { · 35 unmodified lines
362365 .to_string();
363366 drop(repository);
364367 run(
365− open(path, "sed -i.bak -e 's/^middle$/rewritten middle/'")?,
368+ open(
369+ path,
370+ &crate::test_repository::replacing_editor("middle", "rewritten middle"),
371+ )?,
366372 args(&change_id),
367373 )?;
368374
@@ -412,7 +418,13 @@ mod tests { · 43 unmodified lines
412418 git(path, &["update-ref", "refs/worktree/tix/pins/side", side])?;
413419 let main = git(path, &["rev-parse", "main"])?;
414420
415− run(open(path, "sed -i.bak -e 's/^side$/rewritten side/'")?, args("side"))?;
421+ run(
422+ open(
423+ path,
424+ &crate::test_repository::replacing_editor("side", "rewritten side"),
425+ )?,
426+ args("side"),
427+ )?;
416428
417429 assert_eq!(
418430 git(path, &["rev-parse", "main"])?,
gix-tix/src/edit/create.rs+1−0
@@ -775,6 +775,7 @@ mod tests { · 774 unmodified lines
775775 #[test]
776776 fn implicit_new_commit_ignores_untracked_files() -> gix_testtools::Result {
777777 let fixture = gix_testtools::scripted_fixture_writable("create_commit.sh")?;
778+ crate::test_repository::disable_autocrlf(fixture.path())?;
778779 assert!(
779780 Command::new("git")
780781 .arg("-C")
gix-tix/src/edit/forget.rs+1−0
@@ -186,6 +186,7 @@ mod tests { · 185 unmodified lines
186186 #[test]
187187 fn forgets_a_tip_atomically_and_preserves_untracked_files() -> gix_testtools::Result {
188188 let fixture = gix_testtools::scripted_fixture_writable("forget_commit.sh")?;
189+ crate::test_repository::disable_autocrlf(fixture.path())?;
189190 let repository = open(fixture.path())?;
190191 let top = repository.head_id()?.detach();
191192 let parent = repository
gix-tix/src/edit/mod.rs+7−5
@@ -125,18 +125,20 @@ pub(crate) fn edit_document_without_terminal( · 124 unmodified lines
125125 gix::tempfile::ContainingDirectory::Exists,
126126 gix::tempfile::AutoRemove::Tempfile,
127127 )
128− .context("could not create commit message file")?
129− .take()
130− .context("commit message file disappeared")?;
128+ .context("could not create commit message file")?;
131129 tempfile
132130 .write_all(document)
133131 .context("could not write commit message file")?;
134132 tempfile.flush().context("could not flush commit message file")?;
133+ let path = tempfile
134+ .with_mut(|tempfile| tempfile.path().to_owned())
135+ .context("commit message file disappeared")?;
136+ let _tempfile = tempfile.close().context("could not close commit message file")?;
135137
136138 if editor != ":" {
137139 let status = Command::from(
138140 gix::command::prepare(editor)
139− .arg(tempfile.path())
141+ .arg(&path)
140142 .command_may_be_shell_script_allow_manual_argument_splitting(),
141143 )
142144 .status()
@@ -145,7 +147,7 @@ pub(crate) fn edit_document_without_terminal( · 2 unmodified lines
145147 anyhow::bail!("Git editor {} exited with {status}", editor.to_string_lossy());
146148 }
147149 }
148− let edited = std::fs::read(tempfile.path()).context("could not read edited commit message")?;
150+ let edited = std::fs::read(path).context("could not read edited commit message")?;
149151 Ok((edited != document).then_some(edited))
150152 }
151153
gix-tix/src/edit/rebase.rs+1−1
@@ -3299,7 +3299,7 @@ mod tests { · 3298 unmodified lines
32993299 }
33003300 insta::assert_snapshot!(
33013301 "reworded-middle-stack",
3302− gix_testtools::repository::snapshot(fixture.path())?.to_string()
3302+ gix_testtools::repository::snapshot_portable(fixture.path())?.to_string()
33033303 );
33043304 Ok(())
33053305 }
gix-tix/src/edit/review.rs+3−1
@@ -619,6 +619,7 @@ mod tests { · 618 unmodified lines
619619 fn a_changed_review_and_its_successors_are_spliced_before_target_successors() -> gix_testtools::Result {
620620 let fixture = gix_testtools::tempfile::tempdir()?;
621621 run(fixture.path(), &["init", "-q", "-b", "main"])?;
622+ crate::test_repository::disable_autocrlf(fixture.path())?;
622623 run(fixture.path(), &["config", "user.name", "reviewer"])?;
623624 run(fixture.path(), &["config", "user.email", "reviewer@example.com"])?;
624625 run(
@@ -752,9 +753,10 @@ mod tests { · 127 unmodified lines
752753 !super::super::rebase::is_pending(&repo.find_commit(successor)?.decode()?.into_owned()?),
753754 "the checked-out review return path is fully replayed"
754755 );
756+ crate::test_repository::clear_autocrlf(fixture.path())?;
755757 insta::assert_snapshot!(
756758 "changed-review-with-successors",
757− gix_testtools::repository::snapshot(fixture.path())?.to_string()
759+ gix_testtools::repository::snapshot_portable(fixture.path())?.to_string()
758760 );
759761 Ok(())
760762 }
gix-tix/src/edit/snapshots/gix_tix__edit__rebase__tests__reworded-middle-stack.snap+8−19
@@ -1,17 +1,17 @@
11 ---
22 source: gix-tix/src/edit/rebase.rs
3−expression: "gix_testtools::repository::snapshot(fixture.path())?.to_string()"
3+expression: "gix_testtools::repository::snapshot_portable(fixture.path())?.to_string()"
44 ---
55 HEAD refs/heads/main -> C2
66
77 [config]
88 [core]
9− bare = false
9+ bare = false
1010 [user]
11− name = author
12− email = author@example.com
11+ name = author
12+ email = author@example.com
1313 [commit]
14− gpgSign = false
14+ gpgSign = false
1515
1616 [refs]
1717 refs/heads/main = C2
@@ -51,17 +51,6 @@ tree = T2 · 33 unmodified lines
5151 100644 B2 stage=0 "tip"
5252
5353 [worktree]
54−100644 file "base" = "base\n"
55−100644 file "middle" = "middle\n"
56−100644 file "tip" = "tip\n"
57−
58−[objects]
59−C1 = 1583a183c3a57fce524e7acdd5a1c007d5f0f9a9
60−C0 = 5295d5ce934d18b6a1f48c3b7d836d53b55304e5
61−T0 = 559dc660acc84805fedbcb75588371240372c173
62−T2 = 569961a34e2a909d8c7a2940ed4ad365504e64ed
63−T1 = 8552142164d268c95f60dabb74465a2f4ffb51b7
64−C2 = 91e50045e3c98994aebc74a28953fc04ce49cacf
65−B2 = b218ebde2fc5b78f14aa04eeb42a74b17e2e367d
66−B0 = df967b96a579e45a18b8251732d16804b2e56a55
67−B1 = ea1a2ae6cdab2b53dee8943ca555c4312a0b798a
54+- file "base" = "base\n"
55+- file "middle" = "middle\n"
56+- file "tip" = "tip\n"
gix-tix/src/edit/snapshots/gix_tix__edit__review__tests__changed-review-with-successors.snap+9−23
@@ -1,18 +1,18 @@
11 ---
22 source: gix-tix/src/edit/review.rs
3−expression: "gix_testtools::repository::snapshot(fixture.path())?.to_string()"
3+expression: "gix_testtools::repository::snapshot_portable(fixture.path())?.to_string()"
44 ---
55 HEAD refs/heads/main -> C4
66
77 [config]
88 [core]
9− bare = false
9+ bare = false
1010 [user]
11− name = reviewer
12− email = reviewer@example.com
11+ name = reviewer
12+ email = reviewer@example.com
1313 [gitoxide "commit"]
14− authorDate = 2001-01-01T00:00:00 +0000
15− committerDate = 2001-01-01T00:00:00 +0000
14+ authorDate = 2001-01-01T00:00:00 +0000
15+ committerDate = 2001-01-01T00:00:00 +0000
1616
1717 [refs]
1818 refs/heads/main = C4
@@ -68,20 +68,6 @@ tree = T3 · 49 unmodified lines
6868 100644 B2 stage=0 "successor"
6969
7070 [worktree]
71−100644 file "file" = "B\n"
72−100644 file "reviewed" = "new review change\n"
73−100644 file "successor" = "A\n"
74−
75−[objects]
76−T3 = 1104ca61473daa5765f3a6eb0a5fae3e5012a067
77−C2 = 1a13dc5cbbc857de093c9a007e6b104a1a9ffbdb
78−B0 = 223b7836fb19fdf64ba2d3cd6173c6a283141f78
79−C1 = 2cb49e443aa675eab8add679938ca6cd303ae353
80−T1 = 2e457f998ff6a6163f89e091bc4d6b92c8ed2a28
81−T2 = 6d5f482d15035cdd7733b1b551d1fead28d22592
82−B1 = 8ab2a145f1f16e50d78eaced3311ac16027db494
83−T0 = 93664bfc7cc096fcc0d1ac962596031e10f26906
84−C0 = c38a9f7427b84ed8ba5e187ec385489d82d71695
85−C3 = e028a8e769407c249d118ddc499f0c064685ba16
86−B2 = f70f10e4db19068f79bc43844b49f3eece45c4e8
87−C4 = fb6e9845e1d808bd1257db0bb3462a1747d1d2d9
71+- file "file" = "B\n"
72+- file "reviewed" = "new review change\n"
73+- file "successor" = "A\n"
gix-tix/src/edit/snapshots/gix_tix__edit__time_travel__tests__accepted-pending-rebase-conflict.snap+7−17
@@ -1,19 +1,19 @@
11 ---
22 source: gix-tix/src/edit/time_travel.rs
3−expression: "gix_testtools::repository::snapshot(fixture.path())?\n.to_string().replace(\"\\n \\n\", \"\\n\\n\")"
3+expression: "gix_testtools::repository::snapshot_portable(fixture.path())?\n.to_string().replace(\"\\n \\n\", \"\\n\\n\")"
44 ---
55 HEAD detached C1
66
77 [config]
88 [core]
9− bare = false
9+ bare = false
1010 [user]
11− name = author
12− email = author@example.com
11+ name = author
12+ email = author@example.com
1313 [commit]
14− gpgSign = false
14+ gpgSign = false
1515 [gitoxide "commit"]
16− committerDate = 2001-01-01T00:00:00 +0000
16+ committerDate = 2001-01-01T00:00:00 +0000
1717
1818 [refs]
1919 refs/heads/main = C2
@@ -54,14 +54,4 @@ tree = conflicted · 34 unmodified lines
5454 100644 B2 stage=3 "file"
5555
5656 [worktree]
57−100644 file "file" = "<<<<<<< rebased parent\nbase\n=======\ntip\n>>>>>>> commit\n"
58−
59−[objects]
60−C2 = 26d78d03083cfe539c4a94c28bd30d9a548a8394
61−C1 = 69348f5557de103f6771f9a121ff67f5272ceab5
62−T1 = 6d5f482d15035cdd7733b1b551d1fead28d22592
63−T0 = 6f2762b571ef9a93001cc607058818aa5d0d055c
64−B2 = b218ebde2fc5b78f14aa04eeb42a74b17e2e367d
65−C0 = c0b811a58f27425263a4276fe881de38736a9446
66−B1 = df967b96a579e45a18b8251732d16804b2e56a55
67−B0 = ea1a2ae6cdab2b53dee8943ca555c4312a0b798a
57+- file "file" = "<<<<<<< rebased parent\nbase\n=======\ntip\n>>>>>>> commit\n"
gix-tix/src/edit/stash.rs+1−0
@@ -382,6 +382,7 @@ mod tests { · 381 unmodified lines
382382 fn manual_stashes_preserve_git_stashes_and_restore_index_and_worktree_state() -> gix_testtools::Result {
383383 let fixture = gix_testtools::tempfile::tempdir()?;
384384 git(fixture.path(), &["init", "-q", "-b", "main"])?;
385+ crate::test_repository::disable_autocrlf(fixture.path())?;
385386 git(fixture.path(), &["config", "user.name", "user"])?;
386387 git(fixture.path(), &["config", "user.email", "user@example.com"])?;
387388 std::fs::write(fixture.path().join("tracked"), "base\n")?;
gix-tix/src/edit/time_travel.rs+4−1
@@ -1489,6 +1489,7 @@ mod tests { · 1488 unmodified lines
14891489 history::HistoryGraph,
14901490 )> {
14911491 let fixture = gix_testtools::scripted_fixture_writable("rebase_conflict.sh")?;
1492+ crate::test_repository::disable_autocrlf(fixture.path())?;
14921493 git(
14931494 fixture.path(),
14941495 &["config", "gitoxide.commit.committerDate", "2001-01-01T00:00:00 +0000"],
@@ -2063,6 +2064,7 @@ mod tests { · 568 unmodified lines
20632064 #[test]
20642065 fn returning_to_a_commit_restores_its_manual_stash() -> gix_testtools::Result {
20652066 let fixture = gix_testtools::scripted_fixture_writable("history.sh")?;
2067+ crate::test_repository::disable_autocrlf(fixture.path())?;
20662068 let repository = crate::test_repository::open(fixture.path())?;
20672069 let repository_path = repository.git_dir().to_owned();
20682070 let head = repository.head_id()?.detach();
@@ -2361,9 +2363,10 @@ mod tests { · 292 unmodified lines
23612363 .contains_str("<<<<<<<"),
23622364 "the checked-out merge tree contains conflict markers"
23632365 );
2366+ crate::test_repository::clear_autocrlf(fixture.path())?;
23642367 insta::assert_snapshot!(
23652368 "accepted-pending-rebase-conflict",
2366− gix_testtools::repository::snapshot(fixture.path())?
2369+ gix_testtools::repository::snapshot_portable(fixture.path())?
23672370 .to_string()
23682371 .replace("\n \n", "\n\n")
23692372 );
gix-tix/src/edit/todo.rs+6−1
@@ -1853,7 +1853,12 @@ mod tests { · 1852 unmodified lines
18531853
18541854 #[test]
18551855 fn reference_lines_move_create_delete_and_detach_head() -> gix_testtools::Result {
1856− let (fixture, repo) = repo()?;
1856+ let (fixture, _) = repo()?;
1857+ crate::test_repository::disable_autocrlf(fixture.path())?;
1858+ let repo = crate::test_repository::open_with(
1859+ fixture.path(),
1860+ ["core.abbrev=7", "user.name=todo author", "user.email=todo@example.com"],
1861+ )?;
18571862 let (base, middle, tip, commits) = commits(&repo)?;
18581863 let prepared = prepare_test(&repo, base, base, &commits, Some(tip))?;
18591864 let generated = String::from_utf8(prepared.document.clone())?;
gix-tix/src/edit/undo.rs+6−1
@@ -398,6 +398,7 @@ struct WorktreeTransition { · 397 unmodified lines
398398 }
399399
400400 fn worktree_transitions(repo: &gix::Repository, changes: &[RefChange]) -> Result<Vec<WorktreeTransition>> {
401+ let current_git_dir = gix::path::realpath(repo.git_dir()).context("could not resolve the current Git directory")?;
401402 let mut repos = vec![
402403 repo.main_repo()
403404 .context("could not open the main worktree repository")?,
@@ -422,7 +423,9 @@ fn worktree_transitions(repo: &gix::Repository, changes: &[RefChange]) -> Result · 18 unmodified lines
422423 .find_reference("HEAD")
423424 .context("could not read a worktree HEAD reference")?;
424425 let raw_head = state_from_target_ref(raw_head.target());
425− let current = worktree_repo == *repo;
426+ let current = gix::path::realpath(worktree_repo.git_dir())
427+ .context("could not resolve an affected worktree Git directory")?
428+ == current_git_dir;
426429 let projected_head = projected_ref_state(&worktree_repo, b"HEAD".as_bstr(), &raw_head, changes, current)?;
427430 ensure!(
428431 projected_head != State::Missing,
@@ -1148,6 +1151,7 @@ mod tests { · 719 unmodified lines
11481151 #[test]
11491152 fn attached_branch_checkout_follows_undo_and_redo() -> gix_testtools::Result {
11501153 let fixture = gix_testtools::scripted_fixture_writable("forget_commit.sh")?;
1154+ crate::test_repository::disable_autocrlf(fixture.path())?;
11511155 let repo = crate::test_repository::open(fixture.path())?;
11521156 let top = repo.head_id()?.detach();
11531157 let parent = repo
@@ -1204,6 +1208,7 @@ mod tests { · 50 unmodified lines
12041208 #[test]
12051209 fn linked_worktree_head_checkout_follows_undo_and_redo() -> gix_testtools::Result {
12061210 let fixture = gix_testtools::scripted_fixture_writable("forget_commit.sh")?;
1211+ crate::test_repository::disable_autocrlf(fixture.path())?;
12071212 let linked = fixture.path().join("linked");
12081213 let status = std::process::Command::new("git")
12091214 .arg("-C")
gix-tix/src/lib.rs+3−2
@@ -8671,16 +8671,17 @@ mod tests { · 8670 unmodified lines
86718671 #[test]
86728672 fn incremental_worktree_status_matches_a_full_refresh() -> gix_testtools::Result {
86738673 let fixture = gix_testtools::scripted_fixture_writable("history.sh")?;
8674+ test_repository::disable_autocrlf(fixture.path())?;
86748675 let path = fixture.path();
86758676 let repository = test_repository::open(path)?;
86768677 let mut pool = LineDiffPool::new(path, false, 2);
86778678 let mut cached = load_worktree_changes(&repository, &mut pool)?;
86788679
86798680 std::fs::write(path.join("main"), "changed in worktree\n")?;
8680− std::fs::write(path.join("literal[*]"), "untracked\n")?;
8681+ std::fs::write(path.join("literal[brackets]"), "untracked\n")?;
86818682 let parts = WorktreeStatusParts {
86828683 staged: false,
8683− scopes: HashSet::from([BString::from("main"), BString::from("literal[*]")]),
8684+ scopes: HashSet::from([BString::from("main"), BString::from("literal[brackets]")]),
86848685 };
86858686 update_worktree_changes(&repository, &mut cached, &parts, &mut pool)?;
86868687 assert_eq!(
gix-tix/src/test_repository.rs+44−0
@@ -26,6 +26,50 @@ where · 25 unmodified lines
2626 )
2727 }
2828
29+pub(crate) fn replacing_editor(old: &str, new: &str) -> String {
30+ #[cfg(windows)]
31+ {
32+ let script = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/replace-editor.ps1");
33+ format!("pwsh -NoProfile -File \"{}\" \"{old}\" \"{new}\"", script.display())
34+ }
35+ #[cfg(not(windows))]
36+ {
37+ format!("sed -i.bak -e 's/^{old}$/{new}/'")
38+ }
39+}
40+
41+/// Keep Git from converting fixture contents while a test compares exact worktree and index bytes.
42+pub(crate) fn disable_autocrlf(path: impl AsRef<Path>) -> std::io::Result<()> {
43+ let status = std::process::Command::new("git")
44+ .arg("-C")
45+ .arg(path.as_ref())
46+ .args(["config", "--local", "core.autocrlf", "false"])
47+ .status()?;
48+ if status.success() {
49+ Ok(())
50+ } else {
51+ Err(std::io::Error::other(
52+ "could not disable core.autocrlf for the test repository",
53+ ))
54+ }
55+}
56+
57+/// Remove the test-local line-ending override before assertions which snapshot repository configuration.
58+pub(crate) fn clear_autocrlf(path: impl AsRef<Path>) -> std::io::Result<()> {
59+ let status = std::process::Command::new("git")
60+ .arg("-C")
61+ .arg(path.as_ref())
62+ .args(["config", "--local", "--unset", "core.autocrlf"])
63+ .status()?;
64+ if status.success() {
65+ Ok(())
66+ } else {
67+ Err(std::io::Error::other(
68+ "could not remove the core.autocrlf test override",
69+ ))
70+ }
71+}
72+
2973 #[test]
3074 fn defaults_are_deterministic_and_case_specific_overrides_win() -> gix_testtools::Result {
3175 let fixture = gix_testtools::scripted_fixture_read_only("history.sh")?;
gix-tix/tests/fixtures/create_commit.sh+0−0

File mode changed from 100644 to 100755.

gix-tix/tests/fixtures/forget_commit.sh+0−0

File mode changed from 100644 to 100755.

gix-tix/tests/fixtures/rebase_conflict.sh+0−0

File mode changed from 100644 to 100755.

gix-tix/tests/fixtures/rebase_edit.sh+0−0

File mode changed from 100644 to 100755.

gix-tix/tests/fixtures/replace-editor.ps1+9−0
@@ -0,0 +1,9 @@
1+param(
2+ [Parameter(Mandatory = $true)][string]$Old,
3+ [Parameter(Mandatory = $true)][string]$New,
4+ [Parameter(Mandatory = $true)][string]$Path
5+)
6+
7+$content = [System.IO.File]::ReadAllText($Path)
8+$utf8WithoutBom = [System.Text.UTF8Encoding]::new($false)
9+[System.IO.File]::WriteAllText($Path, $content.Replace($Old, $New), $utf8WithoutBom)
gix-tix/tests/fixtures/split_commit.sh+0−0

File mode changed from 100644 to 100755.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t