8
8
"github.com/go-errors/errors"
9
9
"github.com/jesseduffield/lazygit/pkg/commands/models"
10
10
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
11
- "github.com/jesseduffield/lazygit/pkg/commands/types/enums"
12
11
"github.com/jesseduffield/lazygit/pkg/config"
13
12
"github.com/jesseduffield/lazygit/pkg/utils"
14
13
"github.com/stefanhaller/git-todo-parser/todo"
@@ -33,17 +32,15 @@ func TestGetCommits(t *testing.T) {
33
32
expectedCommits []* models.Commit
34
33
expectedError error
35
34
logOrder string
36
- rebaseMode enums.RebaseMode
37
35
opts GetCommitsOptions
38
36
mainBranches []string
39
37
}
40
38
41
39
scenarios := []scenario {
42
40
{
43
- testName : "should return no commits if there are none" ,
44
- logOrder : "topo-order" ,
45
- rebaseMode : enums .REBASE_MODE_NONE ,
46
- opts : GetCommitsOptions {RefName : "HEAD" , RefForPushedStatus : "mybranch" , IncludeRebaseCommits : false },
41
+ testName : "should return no commits if there are none" ,
42
+ logOrder : "topo-order" ,
43
+ opts : GetCommitsOptions {RefName : "HEAD" , RefForPushedStatus : "mybranch" , IncludeRebaseCommits : false },
47
44
runner : oscommands .NewFakeRunner (t ).
48
45
ExpectGitArgs ([]string {"merge-base" , "mybranch" , "mybranch@{u}" }, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164" , nil ).
49
46
ExpectGitArgs ([]string {"log" , "HEAD" , "--topo-order" , "--oneline" , "--pretty=format:%H%x00%at%x00%aN%x00%ae%x00%D%x00%p%x00%m%x00%s" , "--abbrev=40" , "--no-show-signature" , "--" }, "" , nil ),
@@ -52,10 +49,9 @@ func TestGetCommits(t *testing.T) {
52
49
expectedError : nil ,
53
50
},
54
51
{
55
- testName : "should use proper upstream name for branch" ,
56
- logOrder : "topo-order" ,
57
- rebaseMode : enums .REBASE_MODE_NONE ,
58
- opts : GetCommitsOptions {RefName : "refs/heads/mybranch" , RefForPushedStatus : "refs/heads/mybranch" , IncludeRebaseCommits : false },
52
+ testName : "should use proper upstream name for branch" ,
53
+ logOrder : "topo-order" ,
54
+ opts : GetCommitsOptions {RefName : "refs/heads/mybranch" , RefForPushedStatus : "refs/heads/mybranch" , IncludeRebaseCommits : false },
59
55
runner : oscommands .NewFakeRunner (t ).
60
56
ExpectGitArgs ([]string {"merge-base" , "refs/heads/mybranch" , "mybranch@{u}" }, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164" , nil ).
61
57
ExpectGitArgs ([]string {"log" , "refs/heads/mybranch" , "--topo-order" , "--oneline" , "--pretty=format:%H%x00%at%x00%aN%x00%ae%x00%D%x00%p%x00%m%x00%s" , "--abbrev=40" , "--no-show-signature" , "--" }, "" , nil ),
@@ -66,7 +62,6 @@ func TestGetCommits(t *testing.T) {
66
62
{
67
63
testName : "should return commits if they are present" ,
68
64
logOrder : "topo-order" ,
69
- rebaseMode : enums .REBASE_MODE_NONE ,
70
65
opts : GetCommitsOptions {RefName : "HEAD" , RefForPushedStatus : "mybranch" , IncludeRebaseCommits : false },
71
66
mainBranches : []string {"master" , "main" , "develop" },
72
67
runner : oscommands .NewFakeRunner (t ).
@@ -203,7 +198,6 @@ func TestGetCommits(t *testing.T) {
203
198
{
204
199
testName : "should not call merge-base for mainBranches if none exist" ,
205
200
logOrder : "topo-order" ,
206
- rebaseMode : enums .REBASE_MODE_NONE ,
207
201
opts : GetCommitsOptions {RefName : "HEAD" , RefForPushedStatus : "mybranch" , IncludeRebaseCommits : false },
208
202
mainBranches : []string {"master" , "main" },
209
203
runner : oscommands .NewFakeRunner (t ).
@@ -240,7 +234,6 @@ func TestGetCommits(t *testing.T) {
240
234
{
241
235
testName : "should call merge-base for all main branches that exist" ,
242
236
logOrder : "topo-order" ,
243
- rebaseMode : enums .REBASE_MODE_NONE ,
244
237
opts : GetCommitsOptions {RefName : "HEAD" , RefForPushedStatus : "mybranch" , IncludeRebaseCommits : false },
245
238
mainBranches : []string {"master" , "main" , "develop" , "1.0-hotfixes" },
246
239
runner : oscommands .NewFakeRunner (t ).
@@ -277,10 +270,9 @@ func TestGetCommits(t *testing.T) {
277
270
expectedError : nil ,
278
271
},
279
272
{
280
- testName : "should not specify order if `log.order` is `default`" ,
281
- logOrder : "default" ,
282
- rebaseMode : enums .REBASE_MODE_NONE ,
283
- opts : GetCommitsOptions {RefName : "HEAD" , RefForPushedStatus : "mybranch" , IncludeRebaseCommits : false },
273
+ testName : "should not specify order if `log.order` is `default`" ,
274
+ logOrder : "default" ,
275
+ opts : GetCommitsOptions {RefName : "HEAD" , RefForPushedStatus : "mybranch" , IncludeRebaseCommits : false },
284
276
runner : oscommands .NewFakeRunner (t ).
285
277
ExpectGitArgs ([]string {"merge-base" , "mybranch" , "mybranch@{u}" }, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164" , nil ).
286
278
ExpectGitArgs ([]string {"log" , "HEAD" , "--oneline" , "--pretty=format:%H%x00%at%x00%aN%x00%ae%x00%D%x00%p%x00%m%x00%s" , "--abbrev=40" , "--no-show-signature" , "--" }, "" , nil ),
@@ -289,10 +281,9 @@ func TestGetCommits(t *testing.T) {
289
281
expectedError : nil ,
290
282
},
291
283
{
292
- testName : "should set filter path" ,
293
- logOrder : "default" ,
294
- rebaseMode : enums .REBASE_MODE_NONE ,
295
- opts : GetCommitsOptions {RefName : "HEAD" , RefForPushedStatus : "mybranch" , FilterPath : "src" },
284
+ testName : "should set filter path" ,
285
+ logOrder : "default" ,
286
+ opts : GetCommitsOptions {RefName : "HEAD" , RefForPushedStatus : "mybranch" , FilterPath : "src" },
296
287
runner : oscommands .NewFakeRunner (t ).
297
288
ExpectGitArgs ([]string {"merge-base" , "mybranch" , "mybranch@{u}" }, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164" , nil ).
298
289
ExpectGitArgs ([]string {"log" , "HEAD" , "--oneline" , "--pretty=format:%H%x00%at%x00%aN%x00%ae%x00%D%x00%p%x00%m%x00%s" , "--abbrev=40" , "--follow" , "--no-show-signature" , "--" , "src" }, "" , nil ),
@@ -310,10 +301,10 @@ func TestGetCommits(t *testing.T) {
310
301
cmd := oscommands .NewDummyCmdObjBuilder (scenario .runner )
311
302
312
303
builder := & CommitLoader {
313
- Common : common ,
314
- cmd : cmd ,
315
- getRebaseMode : func () (enums. RebaseMode , error ) { return scenario . rebaseMode , nil },
316
- dotGitDir : ".git" ,
304
+ Common : common ,
305
+ cmd : cmd ,
306
+ getWorkingTreeState : func () models. WorkingTreeState { return models. WorkingTreeState {} },
307
+ dotGitDir : ".git" ,
317
308
readFile : func (filename string ) ([]byte , error ) {
318
309
return []byte ("" ), nil
319
310
},
@@ -493,10 +484,10 @@ func TestCommitLoader_getConflictedCommitImpl(t *testing.T) {
493
484
common := utils .NewDummyCommon ()
494
485
495
486
builder := & CommitLoader {
496
- Common : common ,
497
- cmd : oscommands .NewDummyCmdObjBuilder (oscommands .NewFakeRunner (t )),
498
- getRebaseMode : func () (enums. RebaseMode , error ) { return enums . REBASE_MODE_INTERACTIVE , nil },
499
- dotGitDir : ".git" ,
487
+ Common : common ,
488
+ cmd : oscommands .NewDummyCmdObjBuilder (oscommands .NewFakeRunner (t )),
489
+ getWorkingTreeState : func () models. WorkingTreeState { return models. WorkingTreeState { Rebasing : true } },
490
+ dotGitDir : ".git" ,
500
491
readFile : func (filename string ) ([]byte , error ) {
501
492
return []byte ("" ), nil
502
493
},
0 commit comments