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: 10 additions & 0 deletions api/repo/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,18 @@ func CreateRepo(c *gin.Context) {
}

h := new(library.Hook)

// err being nil means we have a record of this repo (dbRepo)
if err == nil {
h, _ = database.FromContext(c).LastHookForRepo(dbRepo)

// make sure our record of the repo allowed events matches what we send to SCM
// what the dbRepo has should override default events on enable
r.SetAllowComment(dbRepo.GetAllowComment())
r.SetAllowDeploy(dbRepo.GetAllowDeploy())
r.SetAllowPull(dbRepo.GetAllowPull())
r.SetAllowPush(dbRepo.GetAllowPush())
r.SetAllowTag(dbRepo.GetAllowTag())
}

// check if we should create the webhook
Expand Down
1 change: 1 addition & 0 deletions scm/github/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ func (c *client) Enable(u *library.User, r *library.Repo, h *library.Hook) (*lib
webhook.SetCreated(hookInfo.GetCreatedAt().Unix())
webhook.SetEvent(eventInitialize)
webhook.SetNumber(h.GetNumber() + 1)
webhook.SetStatus(constants.StatusSuccess)

switch resp.StatusCode {
case http.StatusUnprocessableEntity:
Expand Down
1 change: 1 addition & 0 deletions scm/github/repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ func TestGithub_Enable(t *testing.T) {
wantHook.SetCreated(1315329987)
wantHook.SetNumber(1)
wantHook.SetEvent("initialize")
wantHook.SetStatus("success")

r := new(library.Repo)
r.SetID(1)
Expand Down