mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-23 02:29:43 +08:00
Fix /repos/{owner}/{repo}/pulls/{index}/files
endpoint not populating previous_filename
(#32017) (#32028)
Backport #32017 by @charles-plutohealth --- `status == "rename"` should have read `status == "renamed"`. The typo means that file.PreviousFilename would never be populated, which e.g. breaks usage of the Github Action at https://github.com/dorny/paths-filter. Co-authored-by: charles-plutohealth <143208583+charles-plutohealth@users.noreply.github.com>
This commit is contained in:
parent
0629c08a6d
commit
b3af359cc6
|
@ -424,6 +424,7 @@ func ToLFSLock(ctx context.Context, l *git_model.LFSLock) *api.LFSLock {
|
||||||
// ToChangedFile convert a gitdiff.DiffFile to api.ChangedFile
|
// ToChangedFile convert a gitdiff.DiffFile to api.ChangedFile
|
||||||
func ToChangedFile(f *gitdiff.DiffFile, repo *repo_model.Repository, commit string) *api.ChangedFile {
|
func ToChangedFile(f *gitdiff.DiffFile, repo *repo_model.Repository, commit string) *api.ChangedFile {
|
||||||
status := "changed"
|
status := "changed"
|
||||||
|
previousFilename := ""
|
||||||
if f.IsDeleted {
|
if f.IsDeleted {
|
||||||
status = "deleted"
|
status = "deleted"
|
||||||
} else if f.IsCreated {
|
} else if f.IsCreated {
|
||||||
|
@ -432,6 +433,7 @@ func ToChangedFile(f *gitdiff.DiffFile, repo *repo_model.Repository, commit stri
|
||||||
status = "copied"
|
status = "copied"
|
||||||
} else if f.IsRenamed && f.Type == gitdiff.DiffFileRename {
|
} else if f.IsRenamed && f.Type == gitdiff.DiffFileRename {
|
||||||
status = "renamed"
|
status = "renamed"
|
||||||
|
previousFilename = f.OldName
|
||||||
} else if f.Addition == 0 && f.Deletion == 0 {
|
} else if f.Addition == 0 && f.Deletion == 0 {
|
||||||
status = "unchanged"
|
status = "unchanged"
|
||||||
}
|
}
|
||||||
|
@ -442,14 +444,11 @@ func ToChangedFile(f *gitdiff.DiffFile, repo *repo_model.Repository, commit stri
|
||||||
Additions: f.Addition,
|
Additions: f.Addition,
|
||||||
Deletions: f.Deletion,
|
Deletions: f.Deletion,
|
||||||
Changes: f.Addition + f.Deletion,
|
Changes: f.Addition + f.Deletion,
|
||||||
|
PreviousFilename: previousFilename,
|
||||||
HTMLURL: fmt.Sprint(repo.HTMLURL(), "/src/commit/", commit, "/", util.PathEscapeSegments(f.GetDiffFileName())),
|
HTMLURL: fmt.Sprint(repo.HTMLURL(), "/src/commit/", commit, "/", util.PathEscapeSegments(f.GetDiffFileName())),
|
||||||
ContentsURL: fmt.Sprint(repo.APIURL(), "/contents/", util.PathEscapeSegments(f.GetDiffFileName()), "?ref=", commit),
|
ContentsURL: fmt.Sprint(repo.APIURL(), "/contents/", util.PathEscapeSegments(f.GetDiffFileName()), "?ref=", commit),
|
||||||
RawURL: fmt.Sprint(repo.HTMLURL(), "/raw/commit/", commit, "/", util.PathEscapeSegments(f.GetDiffFileName())),
|
RawURL: fmt.Sprint(repo.HTMLURL(), "/raw/commit/", commit, "/", util.PathEscapeSegments(f.GetDiffFileName())),
|
||||||
}
|
}
|
||||||
|
|
||||||
if status == "rename" {
|
|
||||||
file.PreviousFilename = f.OldName
|
|
||||||
}
|
|
||||||
|
|
||||||
return file
|
return file
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user