Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GetAffectedFiles failed when encountering a null old commit #26881

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions modules/git/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ func CutDiffAroundLine(originalDiff io.Reader, line int64, old bool, numbersOfLi

// GetAffectedFiles returns the affected files between two commits
func GetAffectedFiles(repo *Repository, oldCommitID, newCommitID string, env []string) ([]string, error) {
// If the old commit is the null commit, then we need to use the empty tree
if oldCommitID == "0000000000000000000000000000000000000000" {
oldCommitID = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
lng2020 marked this conversation as resolved.
Show resolved Hide resolved
}
stdoutReader, stdoutWriter, err := os.Pipe()
if err != nil {
log.Error("Unable to create os.Pipe for %s", repo.Path)
Expand Down