Gitea: push webhook notice changed files of all related commits (#675)

* getChangedFilesFromPushHook: use all commits

* add test
This commit is contained in:
6543 2022-01-08 22:16:07 +01:00 committed by GitHub
parent 1588495b1a
commit 8489b5bd37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View file

@ -112,14 +112,12 @@ func buildFromPush(hook *pushHook) *model.Build {
func getChangedFilesFromPushHook(hook *pushHook) []string {
files := make([]string, 0)
if len(hook.Commits) == 0 {
return files
for _, c := range hook.Commits {
files = append(files, c.Added...)
files = append(files, c.Removed...)
files = append(files, c.Modified...)
}
files = append(files, hook.Commits[0].Added...)
files = append(files, hook.Commits[0].Removed...)
files = append(files, hook.Commits[0].Modified...)
return files
}

View file

@ -106,6 +106,7 @@ func Test_parse(t *testing.T) {
g.Assert(build.Message).Equal(hook.Commits[0].Message)
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
g.Assert(build.Author).Equal(hook.Sender.Login)
g.Assert(build.ChangedFiles).Equal([]string{"CHANGELOG.md", "app/controller/application.rb"})
})
g.It("Should return a Repo struct from a push hook", func() {