Skip to content

Commit 14fddcb

Browse files
felixjungdaveshanley
authored andcommitted
At limit commit read file content at previous commit
When processing the earliest commit of the commit history, no data from the file outside of the history is present. This means that no changes can be calculated for the first commit. This issue was likely always present but surfaced by the introduction of the `--global-revisions` flag. Previously, the issue would only appear when reaching the commit that introduced a file. To address the problem, we now read the file's content at the previous commit in the repo. This still does not resolve the problem caused by a file simply not being present at the previous commit.
1 parent e103ec0 commit 14fddcb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

git/read_local.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ func BuildCommitChangelog(commitHistory []*model.Commit,
215215
var oldBits, newBits []byte
216216
if len(commitHistory) == c+1 {
217217
newBits = commitHistory[c].Data
218+
219+
// Obtain data from the previous commit
220+
var err []error
221+
oldBits, err = readFile(commitHistory[c].RepoDirectory, fmt.Sprintf("%s~1", commitHistory[c].Hash), commitHistory[c].FilePath)
222+
if err != nil {
223+
return nil, err
224+
}
218225
} else {
219226
oldBits = commitHistory[c+1].Data
220227
commitHistory[c].OldData = oldBits

0 commit comments

Comments
 (0)