mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-06-07 18:08:48 +00:00
Gitea: push webhook notice changed files of all related commits (#675)
* getChangedFilesFromPushHook: use all commits * add test
This commit is contained in:
parent
1588495b1a
commit
8489b5bd37
2 changed files with 5 additions and 6 deletions
|
@ -112,14 +112,12 @@ func buildFromPush(hook *pushHook) *model.Build {
|
||||||
func getChangedFilesFromPushHook(hook *pushHook) []string {
|
func getChangedFilesFromPushHook(hook *pushHook) []string {
|
||||||
files := make([]string, 0)
|
files := make([]string, 0)
|
||||||
|
|
||||||
if len(hook.Commits) == 0 {
|
for _, c := range hook.Commits {
|
||||||
return files
|
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
|
return files
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,7 @@ func Test_parse(t *testing.T) {
|
||||||
g.Assert(build.Message).Equal(hook.Commits[0].Message)
|
g.Assert(build.Message).Equal(hook.Commits[0].Message)
|
||||||
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||||
g.Assert(build.Author).Equal(hook.Sender.Login)
|
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() {
|
g.It("Should return a Repo struct from a push hook", func() {
|
||||||
|
|
Loading…
Reference in a new issue