88 "github.com/remotemobprogramming/mob/v5/exit"
99 "github.com/remotemobprogramming/mob/v5/open"
1010 "github.com/remotemobprogramming/mob/v5/say"
11+ "github.com/remotemobprogramming/mob/v5/workdir"
1112 "path/filepath"
1213 "reflect"
1314 "runtime"
@@ -209,7 +210,7 @@ func TestStart(t *testing.T) {
209210
210211func TestStartDespiteGitHook (t * testing.T ) {
211212 _ , configuration := setup (t )
212- createExecutableFileInPath (t , gitClient . WorkingDir + "/.git/hooks" , "pre-commit" , "#!/bin/sh\n echo 'boo'\n exit 1\n " )
213+ createExecutableFileInPath (t , workdir . Path + "/.git/hooks" , "pre-commit" , "#!/bin/sh\n echo 'boo'\n exit 1\n " )
213214
214215 start (configuration )
215216
@@ -854,7 +855,7 @@ func TestStartNextStay_WriteLastModifiedFileInCommit_WhenFileIsModifiedAndWorkin
854855 start (configuration )
855856 createDirectory (t , "dir" )
856857 createFile (t , "file1.txt" , "contentIrrelevantButModified" )
857- setWorkingDir (gitClient . WorkingDir + "/dir" )
858+ setWorkingDir (workdir . Path + "/dir" )
858859 next (configuration )
859860
860861 assertOnBranch (t , "mob-session" )
@@ -884,7 +885,7 @@ func TestStartNextStay_DoNotWriteLastModifiedFileInCommit_WhenFileIsDeleted(t *t
884885 next (configuration )
885886
886887 start (configuration )
887- removeFile (t , filepath .Join (gitClient . WorkingDir , "file1.txt" ))
888+ removeFile (t , filepath .Join (workdir . Path , "file1.txt" ))
888889 next (configuration )
889890
890891 assertOnBranch (t , "mob-session" )
@@ -901,7 +902,7 @@ func TestStartNextStay_DoNotWriteLastModifiedFileInCommit_WhenFileIsMoved(t *tes
901902
902903 start (configuration )
903904 createDirectory (t , "dir" )
904- moveFile (t , filepath .Join (gitClient . WorkingDir , "file1.txt" ), filepath .Join (gitClient . WorkingDir , "dir" , "file1.txt" ))
905+ moveFile (t , filepath .Join (workdir . Path , "file1.txt" ), filepath .Join (workdir . Path , "dir" , "file1.txt" ))
905906 next (configuration )
906907
907908 assertOnBranch (t , "mob-session" )
@@ -2090,7 +2091,7 @@ func resetExit() {
20902091}
20912092
20922093func createTestbed (t * testing.T , configuration config.Configuration ) {
2093- gitClient . WorkingDir = ""
2094+ workdir . Path = ""
20942095
20952096 tempDir = t .TempDir ()
20962097
@@ -2121,7 +2122,7 @@ func createTestbedIn(t *testing.T, temporaryDirectory string) {
21212122 cloneRepository (localDirectory , remoteDirectory )
21222123
21232124 say .Debug ("Populate, initial import and push" )
2124- gitClient . WorkingDir = localDirectory
2125+ workdir . Path = localDirectory
21252126 createFile (t , "test.txt" , "test" )
21262127 createDirectory (t , "subdir" )
21272128 createFileInPath (t , localDirectory + "/subdir" , "subdir.txt" , "subdir" )
@@ -2153,7 +2154,7 @@ func createTestbedIn(t *testing.T, temporaryDirectory string) {
21532154}
21542155
21552156func setWorkingDir (dir string ) {
2156- gitClient . WorkingDir = dir
2157+ workdir . Path = dir
21572158 say .Say ("\n ===== cd " + dir )
21582159}
21592160
@@ -2181,7 +2182,7 @@ func assertCommitsOnBranch(t *testing.T, commits int, branchName string) {
21812182 result := silentgit ("rev-list" , "--count" , branchName )
21822183 number , _ := strconv .Atoi (result )
21832184 if number != commits {
2184- failWithFailure (t , strconv .Itoa (commits )+ " commits in " + gitClient . WorkingDir , strconv .Itoa (number )+ " commits in " + gitClient . WorkingDir )
2185+ failWithFailure (t , strconv .Itoa (commits )+ " commits in " + workdir . Path , strconv .Itoa (number )+ " commits in " + workdir . Path )
21852186 }
21862187}
21872188
@@ -2200,7 +2201,7 @@ func assertCommitLogNotContainsMessage(t *testing.T, branchName string, commitMe
22002201}
22012202
22022203func assertFileExist (t * testing.T , filename string ) {
2203- path := gitClient . WorkingDir + "/" + filename
2204+ path := workdir . Path + "/" + filename
22042205 if strings .Index (filename , "/" ) == 0 {
22052206 path = filename
22062207 }
@@ -2216,7 +2217,7 @@ func createFileAndCommitIt(t *testing.T, filename string, content string, commit
22162217}
22172218
22182219func createFile (t * testing.T , filename string , content string ) (pathToFile string ) {
2219- return createFileInPath (t , gitClient . WorkingDir , filename , content )
2220+ return createFileInPath (t , workdir . Path , filename , content )
22202221}
22212222
22222223func createFileInPath (t * testing.T , path , filename , content string ) (pathToFile string ) {
@@ -2242,7 +2243,7 @@ func createExecutableFileInPath(t *testing.T, path, filename, content string) (p
22422243}
22432244
22442245func createDirectory (t * testing.T , directory string ) (pathToDirectory string ) {
2245- return ensureDirectoryExists (t , gitClient . WorkingDir + "/" + directory )
2246+ return ensureDirectoryExists (t , workdir . Path + "/" + directory )
22462247}
22472248
22482249func ensureDirectoryExists (t * testing.T , path string ) (pathToDirectory string ) {
@@ -2378,7 +2379,7 @@ func createRemoteRepository(path string) {
23782379 say .Error (err .Error ())
23792380 return
23802381 }
2381- gitClient . WorkingDir = path
2382+ workdir . Path = path
23822383 say .Debug ("before git init" )
23832384 git ("--bare" , "init" )
23842385 say .Debug ("before symbolic-ref" )
@@ -2396,7 +2397,7 @@ func cloneRepository(path, remoteDirectory string) {
23962397 say .Error (err .Error ())
23972398 return
23982399 }
2399- gitClient . WorkingDir = path
2400+ workdir . Path = path
24002401 name := basename (path )
24012402 git ("clone" , "--origin" , "origin" , "file://" + remoteDirectory , "." )
24022403 git ("config" , "--local" , "user.name" , name )
0 commit comments