Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webhook tag sha fix (#286) #300

Merged
merged 4 commits into from
Nov 29, 2016
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
20 changes: 20 additions & 0 deletions models/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {

apiPusher := pusher.APIFormat()
apiRepo := repo.APIFormat(nil)

var shaSum string
switch opType {
case ActionCommitRepo: // Push
if err = PrepareWebhooks(repo, HookEventPush, &api.PushPayload{
Expand All @@ -556,17 +558,35 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
}

if isNewBranch {
gitRepo, err := git.OpenRepository(repo.RepoPath())
if err != nil {
log.Error(4, "OpenRepository[%s]: %v", repo.RepoPath(), err)
}
shaSum, err = gitRepo.GetBranchCommitID(opts.RefFullName)
if err != nil {
log.Error(4, "GetBranchCommitID[%s]: %v", opts.RefFullName, err)
}
return PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{
Ref: refName,
Sha: shaSum,
RefType: "branch",
Repo: apiRepo,
Sender: apiPusher,
})
}

case ActionPushTag: // Create
gitRepo, err := git.OpenRepository(repo.RepoPath())
if err != nil {
log.Error(4, "OpenRepository[%s]: %v", repo.RepoPath(), err)
}
shaSum, err = gitRepo.GetTagCommitID(opts.RefFullName)
if err != nil {
log.Error(4, "GetTagCommitID[%s]: %v", opts.RefFullName, err)
}
return PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{
Ref: refName,
Sha: shaSum,
RefType: "tag",
Repo: apiRepo,
Sender: apiPusher,
Expand Down
10 changes: 5 additions & 5 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ func (issue *Issue) HTMLURL() string {
// State returns string representation of issue status.
func (issue *Issue) State() api.StateType {
if issue.IsClosed {
return api.STATE_CLOSED
return api.StateClosed
}
return api.STATE_OPEN
return api.StateOpen
}

// APIFormat assumes some fields assigned with values:
Expand Down Expand Up @@ -483,7 +483,7 @@ func (issue *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (e
if isClosed {
apiPullRequest.Action = api.HookIssueClosed
} else {
apiPullRequest.Action = api.HookIssueReopened
apiPullRequest.Action = api.HookIssueReOpened
}
err = PrepareWebhooks(repo, HookEventPullRequest, apiPullRequest)
}
Expand Down Expand Up @@ -1409,9 +1409,9 @@ func (m *Milestone) AfterSet(colName string, _ xorm.Cell) {
// State returns string representation of milestone status.
func (m *Milestone) State() api.StateType {
if m.IsClosed {
return api.STATE_CLOSED
return api.StateClosed
}
return api.STATE_OPEN
return api.StateOpen
}

// APIFormat returns this Milestone in API format.
Expand Down
2 changes: 1 addition & 1 deletion models/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (pr *PullRequest) APIFormat() *api.PullRequest {

if pr.Status != PullRequestStatusChecking {
mergeable := pr.Status != PullRequestStatusConflict
apiPullRequest.Mergeable = &mergeable
apiPullRequest.Mergeable = mergeable
}
if pr.HasMerged {
apiPullRequest.Merged = &pr.Merged
Expand Down
2 changes: 1 addition & 1 deletion models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (u *User) APIFormat() *api.User {
UserName: u.Name,
FullName: u.FullName,
Email: u.Email,
AvatarUrl: u.AvatarLink(),
AvatarURL: u.AvatarLink(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion models/webhook_slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*S
} else {
text = fmt.Sprintf("[%s] Pull request closed: %s by %s", p.Repository.FullName, titleLink, senderLink)
}
case api.HookIssueReopened:
case api.HookIssueReOpened:
text = fmt.Sprintf("[%s] Pull request re-opened: %s by %s", p.Repository.FullName, titleLink, senderLink)
case api.HookIssueEdited:
text = fmt.Sprintf("[%s] Pull request edited: %s by %s", p.Repository.FullName, titleLink, senderLink)
Expand Down
2 changes: 1 addition & 1 deletion routers/api/v1/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func ToDeployKey(apiLink string, key *models.DeployKey) *api.DeployKey {
func ToOrganization(org *models.User) *api.Organization {
return &api.Organization{
ID: org.ID,
AvatarUrl: org.AvatarLink(),
AvatarURL: org.AvatarLink(),
UserName: org.Name,
FullName: org.FullName,
Description: org.Description,
Expand Down
2 changes: 1 addition & 1 deletion routers/api/v1/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
return
}
if form.State != nil {
if err = issue.ChangeStatus(ctx.User, ctx.Repo.Repository, api.STATE_CLOSED == api.StateType(*form.State)); err != nil {
if err = issue.ChangeStatus(ctx.User, ctx.Repo.Repository, api.StateClosed == api.StateType(*form.State)); err != nil {
ctx.Error(500, "ChangeStatus", err)
return
}
Expand Down
2 changes: 1 addition & 1 deletion routers/api/v1/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func Search(ctx *context.APIContext) {
results[i] = &api.User{
ID: users[i].ID,
UserName: users[i].Name,
AvatarUrl: users[i].AvatarLink(),
AvatarURL: users[i].AvatarLink(),
FullName: users[i].FullName,
}
if ctx.IsSigned {
Expand Down
1 change: 1 addition & 0 deletions vendor/code.gitea.io/sdk/gitea/admin_org.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/code.gitea.io/sdk/gitea/admin_repo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions vendor/code.gitea.io/sdk/gitea/admin_user.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/code.gitea.io/sdk/gitea/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions vendor/code.gitea.io/sdk/gitea/gitea.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 28 additions & 3 deletions vendor/code.gitea.io/sdk/gitea/issue.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 20 additions & 5 deletions vendor/code.gitea.io/sdk/gitea/issue_comment.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading