Skip to content

Commit a3be6c0

Browse files
refactor: allow depth and base commit simultaneously
1 parent a1dff13 commit a3be6c0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

plugins/git.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,10 @@ func (p *GitPlugin) buildScanOptions() string {
303303
options = append(options, "--all")
304304
}
305305

306-
// If base commit is specified, use commit range instead of depth
307306
if p.baseCommit != "" {
308307
options = append(options, fmt.Sprintf("%s..HEAD", p.baseCommit))
309-
} else if p.depth > 0 {
308+
}
309+
if p.depth > 0 {
310310
options = append(options, fmt.Sprintf("-n %d", p.depth))
311311
}
312312

plugins/git_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,18 @@ func TestBuildScanOptions(t *testing.T) {
7171
expectedOptions: "--full-history --all def456..HEAD",
7272
},
7373
{
74-
name: "Base commit takes precedence over depth",
74+
name: "Base commit with depth: both flags are used",
7575
scanAllBranches: false,
7676
depth: 10,
7777
baseCommit: "ghi789",
78-
expectedOptions: "--full-history ghi789..HEAD",
78+
expectedOptions: "--full-history ghi789..HEAD -n 10",
7979
},
8080
{
81-
name: "Base commit with all branches takes precedence over depth",
81+
name: "Base commit with all branches and depth: all flags are used",
8282
scanAllBranches: true,
8383
depth: 15,
8484
baseCommit: "jkl012",
85-
expectedOptions: "--full-history --all jkl012..HEAD",
85+
expectedOptions: "--full-history --all jkl012..HEAD -n 15",
8686
},
8787
}
8888

0 commit comments

Comments
 (0)