1
1
package git_commands
2
2
3
3
import (
4
- "fmt"
5
- "os"
6
4
"testing"
7
5
8
6
"github.com/go-errors/errors"
@@ -12,8 +10,6 @@ import (
12
10
"github.com/stretchr/testify/assert"
13
11
)
14
12
15
- var disableHooksFlag = fmt .Sprintf ("core.hooksPath=%s" , os .DevNull )
16
-
17
13
func TestWorkingTreeStageFile (t * testing.T ) {
18
14
runner := oscommands .NewFakeRunner (t ).
19
15
ExpectGitArgs ([]string {"add" , "--" , "test.txt" }, "" , nil )
@@ -117,7 +113,7 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) {
117
113
},
118
114
removeFile : func (string ) error { return nil },
119
115
runner : oscommands .NewFakeRunner (t ).
120
- ExpectGitArgs ([]string {"-c" , disableHooksFlag , " checkout" , "--" , "test" }, "" , errors .New ("error" )),
116
+ ExpectGitArgs ([]string {"checkout" , "--" , "test" }, "" , errors .New ("error" )),
121
117
expectedError : "error" ,
122
118
},
123
119
{
@@ -129,7 +125,7 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) {
129
125
},
130
126
removeFile : func (string ) error { return nil },
131
127
runner : oscommands .NewFakeRunner (t ).
132
- ExpectGitArgs ([]string {"-c" , disableHooksFlag , " checkout" , "--" , "test" }, "" , nil ),
128
+ ExpectGitArgs ([]string {"checkout" , "--" , "test" }, "" , nil ),
133
129
expectedError : "" ,
134
130
},
135
131
{
@@ -142,7 +138,7 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) {
142
138
removeFile : func (string ) error { return nil },
143
139
runner : oscommands .NewFakeRunner (t ).
144
140
ExpectGitArgs ([]string {"reset" , "--" , "test" }, "" , nil ).
145
- ExpectGitArgs ([]string {"-c" , disableHooksFlag , " checkout" , "--" , "test" }, "" , nil ),
141
+ ExpectGitArgs ([]string {"checkout" , "--" , "test" }, "" , nil ),
146
142
expectedError : "" ,
147
143
},
148
144
{
@@ -155,7 +151,7 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) {
155
151
removeFile : func (string ) error { return nil },
156
152
runner : oscommands .NewFakeRunner (t ).
157
153
ExpectGitArgs ([]string {"reset" , "--" , "test" }, "" , nil ).
158
- ExpectGitArgs ([]string {"-c" , disableHooksFlag , " checkout" , "--" , "test" }, "" , nil ),
154
+ ExpectGitArgs ([]string {"checkout" , "--" , "test" }, "" , nil ),
159
155
expectedError : "" ,
160
156
},
161
157
{
@@ -432,7 +428,7 @@ func TestWorkingTreeCheckoutFile(t *testing.T) {
432
428
commitHash : "11af912" ,
433
429
fileName : "test999.txt" ,
434
430
runner : oscommands .NewFakeRunner (t ).
435
- ExpectGitArgs ([]string {"-c" , disableHooksFlag , " checkout" , "11af912" , "--" , "test999.txt" }, "" , nil ),
431
+ ExpectGitArgs ([]string {"checkout" , "11af912" , "--" , "test999.txt" }, "" , nil ),
436
432
test : func (err error ) {
437
433
assert .NoError (t , err )
438
434
},
@@ -442,7 +438,7 @@ func TestWorkingTreeCheckoutFile(t *testing.T) {
442
438
commitHash : "11af912" ,
443
439
fileName : "test999.txt" ,
444
440
runner : oscommands .NewFakeRunner (t ).
445
- ExpectGitArgs ([]string {"-c" , disableHooksFlag , " checkout" , "11af912" , "--" , "test999.txt" }, "" , errors .New ("error" )),
441
+ ExpectGitArgs ([]string {"checkout" , "11af912" , "--" , "test999.txt" }, "" , errors .New ("error" )),
446
442
test : func (err error ) {
447
443
assert .Error (t , err )
448
444
},
@@ -472,7 +468,7 @@ func TestWorkingTreeDiscardUnstagedFileChanges(t *testing.T) {
472
468
testName : "valid case" ,
473
469
file : & models.File {Name : "test.txt" },
474
470
runner : oscommands .NewFakeRunner (t ).
475
- ExpectGitArgs ([]string {"-c" , disableHooksFlag , " checkout" , "--" , "test.txt" }, "" , nil ),
471
+ ExpectGitArgs ([]string {"checkout" , "--" , "test.txt" }, "" , nil ),
476
472
test : func (err error ) {
477
473
assert .NoError (t , err )
478
474
},
@@ -499,7 +495,7 @@ func TestWorkingTreeDiscardAnyUnstagedFileChanges(t *testing.T) {
499
495
{
500
496
testName : "valid case" ,
501
497
runner : oscommands .NewFakeRunner (t ).
502
- ExpectGitArgs ([]string {"-c" , disableHooksFlag , " checkout" , "--" , "." }, "" , nil ),
498
+ ExpectGitArgs ([]string {"checkout" , "--" , "." }, "" , nil ),
503
499
test : func (err error ) {
504
500
assert .NoError (t , err )
505
501
},
0 commit comments