Skip to content

Commit be18643

Browse files
committed
Add test and comment
1 parent 99b5634 commit be18643

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

modules/git/diff_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,15 @@ func TestParseDiffHunkString(t *testing.T) {
194194
assert.Equal(t, 2, rightLine)
195195
assert.Equal(t, 1, rightHunk)
196196
}
197+
198+
func Test_GetAffectedHunksForTwoCommitsSpecialFile(t *testing.T) {
199+
repoPath := "./tests/repos/repo4_commitsbetween"
200+
hunks, err := GetAffectedHunksForTwoCommitsSpecialFile(t.Context(), repoPath, "fdc1b615bdcff0f0658b216df0c9209e5ecb7c78", "a78e5638b66ccfe7e1b4689d3d5684e42c97d7ca", "test.txt")
201+
assert.NoError(t, err)
202+
assert.Len(t, hunks, 1)
203+
// @@ -1 +1 @@
204+
assert.Equal(t, int64(1), hunks[0].LeftLine)
205+
assert.Equal(t, int64(1), hunks[0].LeftHunk)
206+
assert.Equal(t, int64(1), hunks[0].RightLine)
207+
assert.Equal(t, int64(1), hunks[0].RightHunk)
208+
}

modules/git/repo_commit.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ func (repo *Repository) CommitsBetween(lastCommitID, beforeCommitID string) ([]*
322322
return commits, nil
323323
}
324324

325+
// CommitIDsBetween returns a list that contains commit IDs between (beforeCommitID, afterCommitID].
326+
// If beforeCommitID is empty, it will return all commits before afterCommitID.
327+
// If beforeCommitID is given, it will not be included in the result.
325328
func CommitIDsBetween(ctx context.Context, repoPath, beforeCommitID, afterCommitID string) ([]string, error) {
326329
var stdout []byte
327330
var err error

0 commit comments

Comments
 (0)