mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 20:01:24 +01:00
Fix /repos/{owner}/{repo}/pulls/{index}/files
endpoint not populating previous_filename
(#32017)
--- `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. (cherry picked from commit 7c6edf1ba06d4c3269eaa78f4039c9123b006c51)
This commit is contained in:
parent
2da0ebbd23
commit
5af168fb92
1 changed files with 11 additions and 12 deletions
|
@ -480,6 +480,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 {
|
||||||
|
@ -488,23 +489,21 @@ 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"
|
||||||
}
|
}
|
||||||
|
|
||||||
file := &api.ChangedFile{
|
file := &api.ChangedFile{
|
||||||
Filename: f.GetDiffFileName(),
|
Filename: f.GetDiffFileName(),
|
||||||
Status: status,
|
Status: status,
|
||||||
Additions: f.Addition,
|
Additions: f.Addition,
|
||||||
Deletions: f.Deletion,
|
Deletions: f.Deletion,
|
||||||
Changes: f.Addition + f.Deletion,
|
Changes: f.Addition + f.Deletion,
|
||||||
HTMLURL: fmt.Sprint(repo.HTMLURL(), "/src/commit/", commit, "/", util.PathEscapeSegments(f.GetDiffFileName())),
|
PreviousFilename: previousFilename,
|
||||||
ContentsURL: fmt.Sprint(repo.APIURL(), "/contents/", util.PathEscapeSegments(f.GetDiffFileName()), "?ref=", commit),
|
HTMLURL: fmt.Sprint(repo.HTMLURL(), "/src/commit/", commit, "/", util.PathEscapeSegments(f.GetDiffFileName())),
|
||||||
RawURL: fmt.Sprint(repo.HTMLURL(), "/raw/commit/", commit, "/", util.PathEscapeSegments(f.GetDiffFileName())),
|
ContentsURL: fmt.Sprint(repo.APIURL(), "/contents/", util.PathEscapeSegments(f.GetDiffFileName()), "?ref=", commit),
|
||||||
}
|
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 a new issue