Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 2 additions & 8 deletions api/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,14 +471,8 @@ func PostWebhook(c *gin.Context) {
}

// update repo fields with any changes from SCM process
// TODO: eventually remove this in favor of some sync scripting?
if len(r.GetTopics()) != 0 {
repo.SetTopics(r.GetTopics())
}

if !strings.EqualFold(repo.GetBranch(), r.GetBranch()) {
repo.SetBranch(r.GetBranch())
}
repo.SetTopics(r.GetTopics())
repo.SetBranch(r.GetBranch())

// set the parent equal to the current repo counter
b.SetParent(repo.GetCounter())
Expand Down
6 changes: 5 additions & 1 deletion scm/github/testdata/hooks/push.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@
"watchers": 0,
"default_branch": "master",
"stargazers": 0,
"master_branch": "master"
"master_branch": "master",
"topics": [
"go",
"vela"
]
},
"pusher": {
"name": "Codertocat",
Expand Down
6 changes: 5 additions & 1 deletion scm/github/testdata/hooks/push_no_sender.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@
"watchers": 0,
"default_branch": "master",
"stargazers": 0,
"master_branch": "master"
"master_branch": "master",
"topics": [
"go",
"vela"
]
},
"pusher": {
"name": "Codertocat",
Expand Down
3 changes: 1 addition & 2 deletions scm/github/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ func (c *client) processPushEvent(h *library.Hook, payload *github.PushEvent) (*
r.SetClone(repo.GetCloneURL())
r.SetBranch(repo.GetDefaultBranch())
r.SetPrivate(repo.GetPrivate())
// uncomment this line when next version (>v51.0.0) of go-github is released
// r.SetTopics(repo.Topics)
r.SetTopics(repo.Topics)

// convert payload to library build
b := new(library.Build)
Expand Down
2 changes: 2 additions & 0 deletions scm/github/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func TestGithub_ProcessWebhook_Push(t *testing.T) {
wantRepo.SetClone("https://github.com/Codertocat/Hello-World.git")
wantRepo.SetBranch("master")
wantRepo.SetPrivate(false)
wantRepo.SetTopics([]string{"go", "vela"})

wantBuild := new(library.Build)
wantBuild.SetEvent("push")
Expand Down Expand Up @@ -144,6 +145,7 @@ func TestGithub_ProcessWebhook_Push_NoSender(t *testing.T) {
wantRepo.SetClone("https://github.com/Codertocat/Hello-World.git")
wantRepo.SetBranch("master")
wantRepo.SetPrivate(false)
wantRepo.SetTopics([]string{"go", "vela"})

wantBuild := new(library.Build)
wantBuild.SetEvent("push")
Expand Down