Skip to content

Commit b5aa641

Browse files
git-unix: make index and regression test work without global gitconfig
The tests of git-unix fail if there's no global `.gitconfig` setting user.name and user.email in every `git commit` being run. This easily fixed by setting a local git config per repository/store used. This fixes the tests failing in sandboxed environments or on systems without git set up properly.
1 parent 6f13511 commit b5aa641

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

test/index/test.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ let delete_should_be_empty =
183183
let run path =
184184
let open Rresult in
185185
Bos.OS.Dir.with_current path @@ fun () ->
186+
Bos.OS.Cmd.run Bos.Cmd.(v "git" % "config" % "user.name" % "test")
187+
>>= fun () ->
188+
Bos.OS.Cmd.run
189+
Bos.Cmd.(v "git" % "config" % "user.email" % "[email protected]")
190+
>>= fun () ->
186191
Bos.OS.Cmd.run Bos.Cmd.(v "git" % "commit" % "-m" % ".") >>= fun () ->
187192
load ~hash:SHA1 Fpath.(v ".git" / "index") >>= fun t ->
188193
(* XXX(dinosaure): [git] deletes [should-be-empty] into the index file **AND**

test/smart/test.ml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,11 @@ let commit_foo store =
385385
let commit =
386386
let open Rresult in
387387
Bos.OS.Dir.with_current path @@ fun () ->
388+
Bos.OS.Cmd.run Bos.Cmd.(v "git" % "config" % "user.name" % "test")
389+
>>= fun () ->
390+
Bos.OS.Cmd.run
391+
Bos.Cmd.(v "git" % "config" % "user.email" % "[email protected]")
392+
>>= fun () ->
388393
Bos.OS.File.write (Fpath.v "foo") "" >>= fun () ->
389394
Bos.OS.Cmd.run Bos.Cmd.(v "git" % "add" % "foo") >>= fun () ->
390395
Bos.OS.Cmd.run Bos.Cmd.(v "git" % "commit" % "-m" % ".") >>= fun () ->
@@ -1490,6 +1495,11 @@ let test_partial_fetch_ssh () =
14901495
let fiber =
14911496
let open Rresult in
14921497
OS.Dir.with_current path @@ fun () ->
1498+
OS.Cmd.run Bos.Cmd.(v "git" % "config" % "user.name" % "test")
1499+
>>= fun () ->
1500+
OS.Cmd.run
1501+
Bos.Cmd.(v "git" % "config" % "user.email" % "[email protected]")
1502+
>>= fun () ->
14931503
OS.Cmd.run Cmd.(v "touch" % "foo") >>= fun () ->
14941504
OS.Cmd.run Cmd.(v "git" % "add" % "foo") >>= fun () ->
14951505
OS.Cmd.run Cmd.(v "git" % "commit" % "-m" % ".")
@@ -1503,6 +1513,11 @@ let test_partial_fetch_ssh () =
15031513
let fiber =
15041514
let open Rresult in
15051515
OS.Dir.with_current path @@ fun () ->
1516+
OS.Cmd.run Bos.Cmd.(v "git" % "config" % "user.name" % "test")
1517+
>>= fun () ->
1518+
OS.Cmd.run
1519+
Bos.Cmd.(v "git" % "config" % "user.email" % "[email protected]")
1520+
>>= fun () ->
15061521
OS.Cmd.run Cmd.(v "touch" % "bar") >>= fun () ->
15071522
OS.Cmd.run Cmd.(v "git" % "add" % "bar") >>= fun () ->
15081523
OS.Cmd.run Cmd.(v "git" % "commit" % "-m" % ".") >>= fun () ->

0 commit comments

Comments
 (0)