Use MixedCase constant names
See https://github.com/golang/go/wiki/CodeReviewComments#mixed-caps
This commit is contained in:
		
							parent
							
								
									5d430c9e68
								
							
						
					
					
						commit
						80eea77953
					
				| 
						 | 
					@ -27,21 +27,21 @@ import (
 | 
				
			||||||
type ActionType int
 | 
					type ActionType int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	ACTION_CREATE_REPO         ActionType = iota + 1 // 1
 | 
						ActionCreateRepo         ActionType = iota + 1 // 1
 | 
				
			||||||
	ACTION_RENAME_REPO                               // 2
 | 
						ActionRenameRepo                               // 2
 | 
				
			||||||
	ACTION_STAR_REPO                                 // 3
 | 
						ActionStarRepo                                 // 3
 | 
				
			||||||
	ACTION_WATCH_REPO                                // 4
 | 
						ActionWatchRepo                                // 4
 | 
				
			||||||
	ACTION_COMMIT_REPO                               // 5
 | 
						ActionCommitRepo                               // 5
 | 
				
			||||||
	ACTION_CREATE_ISSUE                              // 6
 | 
						ActionCreateIssue                              // 6
 | 
				
			||||||
	ACTION_CREATE_PULL_REQUEST                       // 7
 | 
						ActionCreatePullRequest                       // 7
 | 
				
			||||||
	ACTION_TRANSFER_REPO                             // 8
 | 
						ActionTransferRepo                             // 8
 | 
				
			||||||
	ACTION_PUSH_TAG                                  // 9
 | 
						ActionPushTag                                  // 9
 | 
				
			||||||
	ACTION_COMMENT_ISSUE                             // 10
 | 
						ActionCommentIssue                             // 10
 | 
				
			||||||
	ACTION_MERGE_PULL_REQUEST                        // 11
 | 
						ActionMergePullRequest                        // 11
 | 
				
			||||||
	ACTION_CLOSE_ISSUE                               // 12
 | 
						ActionCloseIssue                               // 12
 | 
				
			||||||
	ACTION_REOPEN_ISSUE                              // 13
 | 
						ActionReopenIssue                              // 13
 | 
				
			||||||
	ACTION_CLOSE_PULL_REQUEST                        // 14
 | 
						ActionClosePullRequest                        // 14
 | 
				
			||||||
	ACTION_REOPEN_PULL_REQUEST                       // 15
 | 
						ActionReopenPullRequest                       // 15
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
| 
						 | 
					@ -176,7 +176,7 @@ func newRepoAction(e Engine, u *User, repo *Repository) (err error) {
 | 
				
			||||||
	if err = notifyWatchers(e, &Action{
 | 
						if err = notifyWatchers(e, &Action{
 | 
				
			||||||
		ActUserID:    u.ID,
 | 
							ActUserID:    u.ID,
 | 
				
			||||||
		ActUserName:  u.Name,
 | 
							ActUserName:  u.Name,
 | 
				
			||||||
		OpType:       ACTION_CREATE_REPO,
 | 
							OpType:       ActionCreateRepo,
 | 
				
			||||||
		RepoID:       repo.ID,
 | 
							RepoID:       repo.ID,
 | 
				
			||||||
		RepoUserName: repo.Owner.Name,
 | 
							RepoUserName: repo.Owner.Name,
 | 
				
			||||||
		RepoName:     repo.Name,
 | 
							RepoName:     repo.Name,
 | 
				
			||||||
| 
						 | 
					@ -198,7 +198,7 @@ func renameRepoAction(e Engine, actUser *User, oldRepoName string, repo *Reposit
 | 
				
			||||||
	if err = notifyWatchers(e, &Action{
 | 
						if err = notifyWatchers(e, &Action{
 | 
				
			||||||
		ActUserID:    actUser.ID,
 | 
							ActUserID:    actUser.ID,
 | 
				
			||||||
		ActUserName:  actUser.Name,
 | 
							ActUserName:  actUser.Name,
 | 
				
			||||||
		OpType:       ACTION_RENAME_REPO,
 | 
							OpType:       ActionRenameRepo,
 | 
				
			||||||
		RepoID:       repo.ID,
 | 
							RepoID:       repo.ID,
 | 
				
			||||||
		RepoUserName: repo.Owner.Name,
 | 
							RepoUserName: repo.Owner.Name,
 | 
				
			||||||
		RepoName:     repo.Name,
 | 
							RepoName:     repo.Name,
 | 
				
			||||||
| 
						 | 
					@ -454,10 +454,10 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	isNewBranch := false
 | 
						isNewBranch := false
 | 
				
			||||||
	opType := ACTION_COMMIT_REPO
 | 
						opType := ActionCommitRepo
 | 
				
			||||||
	// Check it's tag push or branch.
 | 
						// Check it's tag push or branch.
 | 
				
			||||||
	if strings.HasPrefix(opts.RefFullName, git.TAG_PREFIX) {
 | 
						if strings.HasPrefix(opts.RefFullName, git.TAG_PREFIX) {
 | 
				
			||||||
		opType = ACTION_PUSH_TAG
 | 
							opType = ActionPushTag
 | 
				
			||||||
		opts.Commits = &PushCommits{}
 | 
							opts.Commits = &PushCommits{}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		// if not the first commit, set the compare URL.
 | 
							// if not the first commit, set the compare URL.
 | 
				
			||||||
| 
						 | 
					@ -503,8 +503,8 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
 | 
				
			||||||
	apiPusher := pusher.APIFormat()
 | 
						apiPusher := pusher.APIFormat()
 | 
				
			||||||
	apiRepo := repo.APIFormat(nil)
 | 
						apiRepo := repo.APIFormat(nil)
 | 
				
			||||||
	switch opType {
 | 
						switch opType {
 | 
				
			||||||
	case ACTION_COMMIT_REPO: // Push
 | 
						case ActionCommitRepo: // Push
 | 
				
			||||||
		if err = PrepareWebhooks(repo, HOOK_EVENT_PUSH, &api.PushPayload{
 | 
							if err = PrepareWebhooks(repo, HookEventPush, &api.PushPayload{
 | 
				
			||||||
			Ref:        opts.RefFullName,
 | 
								Ref:        opts.RefFullName,
 | 
				
			||||||
			Before:     opts.OldCommitID,
 | 
								Before:     opts.OldCommitID,
 | 
				
			||||||
			After:      opts.NewCommitID,
 | 
								After:      opts.NewCommitID,
 | 
				
			||||||
| 
						 | 
					@ -518,7 +518,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if isNewBranch {
 | 
							if isNewBranch {
 | 
				
			||||||
			return PrepareWebhooks(repo, HOOK_EVENT_CREATE, &api.CreatePayload{
 | 
								return PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{
 | 
				
			||||||
				Ref:     refName,
 | 
									Ref:     refName,
 | 
				
			||||||
				RefType: "branch",
 | 
									RefType: "branch",
 | 
				
			||||||
				Repo:    apiRepo,
 | 
									Repo:    apiRepo,
 | 
				
			||||||
| 
						 | 
					@ -526,8 +526,8 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case ACTION_PUSH_TAG: // Create
 | 
						case ActionPushTag: // Create
 | 
				
			||||||
		return PrepareWebhooks(repo, HOOK_EVENT_CREATE, &api.CreatePayload{
 | 
							return PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{
 | 
				
			||||||
			Ref:     refName,
 | 
								Ref:     refName,
 | 
				
			||||||
			RefType: "tag",
 | 
								RefType: "tag",
 | 
				
			||||||
			Repo:    apiRepo,
 | 
								Repo:    apiRepo,
 | 
				
			||||||
| 
						 | 
					@ -542,7 +542,7 @@ func transferRepoAction(e Engine, doer, oldOwner *User, repo *Repository) (err e
 | 
				
			||||||
	if err = notifyWatchers(e, &Action{
 | 
						if err = notifyWatchers(e, &Action{
 | 
				
			||||||
		ActUserID:    doer.ID,
 | 
							ActUserID:    doer.ID,
 | 
				
			||||||
		ActUserName:  doer.Name,
 | 
							ActUserName:  doer.Name,
 | 
				
			||||||
		OpType:       ACTION_TRANSFER_REPO,
 | 
							OpType:       ActionTransferRepo,
 | 
				
			||||||
		RepoID:       repo.ID,
 | 
							RepoID:       repo.ID,
 | 
				
			||||||
		RepoUserName: repo.Owner.Name,
 | 
							RepoUserName: repo.Owner.Name,
 | 
				
			||||||
		RepoName:     repo.Name,
 | 
							RepoName:     repo.Name,
 | 
				
			||||||
| 
						 | 
					@ -572,7 +572,7 @@ func mergePullRequestAction(e Engine, doer *User, repo *Repository, issue *Issue
 | 
				
			||||||
	return notifyWatchers(e, &Action{
 | 
						return notifyWatchers(e, &Action{
 | 
				
			||||||
		ActUserID:    doer.ID,
 | 
							ActUserID:    doer.ID,
 | 
				
			||||||
		ActUserName:  doer.Name,
 | 
							ActUserName:  doer.Name,
 | 
				
			||||||
		OpType:       ACTION_MERGE_PULL_REQUEST,
 | 
							OpType:       ActionMergePullRequest,
 | 
				
			||||||
		Content:      fmt.Sprintf("%d|%s", issue.Index, issue.Title),
 | 
							Content:      fmt.Sprintf("%d|%s", issue.Index, issue.Title),
 | 
				
			||||||
		RepoID:       repo.ID,
 | 
							RepoID:       repo.ID,
 | 
				
			||||||
		RepoUserName: repo.Owner.Name,
 | 
							RepoUserName: repo.Owner.Name,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -239,8 +239,8 @@ func (issue *Issue) sendLabelUpdatedWebhook(doer *User) {
 | 
				
			||||||
			log.Error(4, "LoadIssue: %v", err)
 | 
								log.Error(4, "LoadIssue: %v", err)
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
 | 
							err = PrepareWebhooks(issue.Repo, HookEventPullRequest, &api.PullRequestPayload{
 | 
				
			||||||
			Action:      api.HOOK_ISSUE_LABEL_UPDATED,
 | 
								Action:      api.HookIssueLabelUpdated,
 | 
				
			||||||
			Index:       issue.Index,
 | 
								Index:       issue.Index,
 | 
				
			||||||
			PullRequest: issue.PullRequest.APIFormat(),
 | 
								PullRequest: issue.PullRequest.APIFormat(),
 | 
				
			||||||
			Repository:  issue.Repo.APIFormat(nil),
 | 
								Repository:  issue.Repo.APIFormat(nil),
 | 
				
			||||||
| 
						 | 
					@ -343,8 +343,8 @@ func (issue *Issue) ClearLabels(doer *User) (err error) {
 | 
				
			||||||
			log.Error(4, "LoadIssue: %v", err)
 | 
								log.Error(4, "LoadIssue: %v", err)
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
 | 
							err = PrepareWebhooks(issue.Repo, HookEventPullRequest, &api.PullRequestPayload{
 | 
				
			||||||
			Action:      api.HOOK_ISSUE_LABEL_CLEARED,
 | 
								Action:      api.HookIssueLabelCleared,
 | 
				
			||||||
			Index:       issue.Index,
 | 
								Index:       issue.Index,
 | 
				
			||||||
			PullRequest: issue.PullRequest.APIFormat(),
 | 
								PullRequest: issue.PullRequest.APIFormat(),
 | 
				
			||||||
			Repository:  issue.Repo.APIFormat(nil),
 | 
								Repository:  issue.Repo.APIFormat(nil),
 | 
				
			||||||
| 
						 | 
					@ -471,11 +471,11 @@ func (issue *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (e
 | 
				
			||||||
			Sender:      doer.APIFormat(),
 | 
								Sender:      doer.APIFormat(),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if isClosed {
 | 
							if isClosed {
 | 
				
			||||||
			apiPullRequest.Action = api.HOOK_ISSUE_CLOSED
 | 
								apiPullRequest.Action = api.HookIssueClosed
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			apiPullRequest.Action = api.HOOK_ISSUE_REOPENED
 | 
								apiPullRequest.Action = api.HookIssueReopened
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		err = PrepareWebhooks(repo, HOOK_EVENT_PULL_REQUEST, apiPullRequest)
 | 
							err = PrepareWebhooks(repo, HookEventPullRequest, apiPullRequest)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		log.Error(4, "PrepareWebhooks [is_pull: %v, is_closed: %v]: %v", issue.IsPull, isClosed, err)
 | 
							log.Error(4, "PrepareWebhooks [is_pull: %v, is_closed: %v]: %v", issue.IsPull, isClosed, err)
 | 
				
			||||||
| 
						 | 
					@ -495,8 +495,8 @@ func (issue *Issue) ChangeTitle(doer *User, title string) (err error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if issue.IsPull {
 | 
						if issue.IsPull {
 | 
				
			||||||
		issue.PullRequest.Issue = issue
 | 
							issue.PullRequest.Issue = issue
 | 
				
			||||||
		err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
 | 
							err = PrepareWebhooks(issue.Repo, HookEventPullRequest, &api.PullRequestPayload{
 | 
				
			||||||
			Action: api.HOOK_ISSUE_EDITED,
 | 
								Action: api.HookIssueEdited,
 | 
				
			||||||
			Index:  issue.Index,
 | 
								Index:  issue.Index,
 | 
				
			||||||
			Changes: &api.ChangesPayload{
 | 
								Changes: &api.ChangesPayload{
 | 
				
			||||||
				Title: &api.ChangesFromPayload{
 | 
									Title: &api.ChangesFromPayload{
 | 
				
			||||||
| 
						 | 
					@ -526,8 +526,8 @@ func (issue *Issue) ChangeContent(doer *User, content string) (err error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if issue.IsPull {
 | 
						if issue.IsPull {
 | 
				
			||||||
		issue.PullRequest.Issue = issue
 | 
							issue.PullRequest.Issue = issue
 | 
				
			||||||
		err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
 | 
							err = PrepareWebhooks(issue.Repo, HookEventPullRequest, &api.PullRequestPayload{
 | 
				
			||||||
			Action: api.HOOK_ISSUE_EDITED,
 | 
								Action: api.HookIssueEdited,
 | 
				
			||||||
			Index:  issue.Index,
 | 
								Index:  issue.Index,
 | 
				
			||||||
			Changes: &api.ChangesPayload{
 | 
								Changes: &api.ChangesPayload{
 | 
				
			||||||
				Body: &api.ChangesFromPayload{
 | 
									Body: &api.ChangesFromPayload{
 | 
				
			||||||
| 
						 | 
					@ -571,11 +571,11 @@ func (issue *Issue) ChangeAssignee(doer *User, assigneeID int64) (err error) {
 | 
				
			||||||
			Sender:      doer.APIFormat(),
 | 
								Sender:      doer.APIFormat(),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if isRemoveAssignee {
 | 
							if isRemoveAssignee {
 | 
				
			||||||
			apiPullRequest.Action = api.HOOK_ISSUE_UNASSIGNED
 | 
								apiPullRequest.Action = api.HookIssueUnassigned
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			apiPullRequest.Action = api.HOOK_ISSUE_ASSIGNED
 | 
								apiPullRequest.Action = api.HookIssueAssigned
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, apiPullRequest)
 | 
							err = PrepareWebhooks(issue.Repo, HookEventPullRequest, apiPullRequest)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		log.Error(4, "PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, isRemoveAssignee, err)
 | 
							log.Error(4, "PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, isRemoveAssignee, err)
 | 
				
			||||||
| 
						 | 
					@ -714,7 +714,7 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string)
 | 
				
			||||||
	if err = NotifyWatchers(&Action{
 | 
						if err = NotifyWatchers(&Action{
 | 
				
			||||||
		ActUserID:    issue.Poster.ID,
 | 
							ActUserID:    issue.Poster.ID,
 | 
				
			||||||
		ActUserName:  issue.Poster.Name,
 | 
							ActUserName:  issue.Poster.Name,
 | 
				
			||||||
		OpType:       ACTION_CREATE_ISSUE,
 | 
							OpType:       ActionCreateIssue,
 | 
				
			||||||
		Content:      fmt.Sprintf("%d|%s", issue.Index, issue.Title),
 | 
							Content:      fmt.Sprintf("%d|%s", issue.Index, issue.Title),
 | 
				
			||||||
		RepoID:       repo.ID,
 | 
							RepoID:       repo.ID,
 | 
				
			||||||
		RepoUserName: repo.Owner.Name,
 | 
							RepoUserName: repo.Owner.Name,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -144,11 +144,11 @@ func (cmt *Comment) MailParticipants(opType ActionType, issue *Issue) (err error
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch opType {
 | 
						switch opType {
 | 
				
			||||||
	case ACTION_COMMENT_ISSUE:
 | 
						case ActionCommentIssue:
 | 
				
			||||||
		issue.Content = cmt.Content
 | 
							issue.Content = cmt.Content
 | 
				
			||||||
	case ACTION_CLOSE_ISSUE:
 | 
						case ActionCloseIssue:
 | 
				
			||||||
		issue.Content = fmt.Sprintf("Closed #%d", issue.Index)
 | 
							issue.Content = fmt.Sprintf("Closed #%d", issue.Index)
 | 
				
			||||||
	case ACTION_REOPEN_ISSUE:
 | 
						case ActionReopenIssue:
 | 
				
			||||||
		issue.Content = fmt.Sprintf("Reopened #%d", issue.Index)
 | 
							issue.Content = fmt.Sprintf("Reopened #%d", issue.Index)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err = mailIssueCommentToParticipants(issue, cmt.Poster, mentions); err != nil {
 | 
						if err = mailIssueCommentToParticipants(issue, cmt.Poster, mentions); err != nil {
 | 
				
			||||||
| 
						 | 
					@ -188,7 +188,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
 | 
				
			||||||
	// Check comment type.
 | 
						// Check comment type.
 | 
				
			||||||
	switch opts.Type {
 | 
						switch opts.Type {
 | 
				
			||||||
	case COMMENT_TYPE_COMMENT:
 | 
						case COMMENT_TYPE_COMMENT:
 | 
				
			||||||
		act.OpType = ACTION_COMMENT_ISSUE
 | 
							act.OpType = ActionCommentIssue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if _, err = e.Exec("UPDATE `issue` SET num_comments=num_comments+1 WHERE id=?", opts.Issue.ID); err != nil {
 | 
							if _, err = e.Exec("UPDATE `issue` SET num_comments=num_comments+1 WHERE id=?", opts.Issue.ID); err != nil {
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
| 
						 | 
					@ -217,9 +217,9 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case COMMENT_TYPE_REOPEN:
 | 
						case COMMENT_TYPE_REOPEN:
 | 
				
			||||||
		act.OpType = ACTION_REOPEN_ISSUE
 | 
							act.OpType = ActionReopenIssue
 | 
				
			||||||
		if opts.Issue.IsPull {
 | 
							if opts.Issue.IsPull {
 | 
				
			||||||
			act.OpType = ACTION_REOPEN_PULL_REQUEST
 | 
								act.OpType = ActionReopenPullRequest
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if opts.Issue.IsPull {
 | 
							if opts.Issue.IsPull {
 | 
				
			||||||
| 
						 | 
					@ -232,9 +232,9 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case COMMENT_TYPE_CLOSE:
 | 
						case COMMENT_TYPE_CLOSE:
 | 
				
			||||||
		act.OpType = ACTION_CLOSE_ISSUE
 | 
							act.OpType = ActionCloseIssue
 | 
				
			||||||
		if opts.Issue.IsPull {
 | 
							if opts.Issue.IsPull {
 | 
				
			||||||
			act.OpType = ACTION_CLOSE_PULL_REQUEST
 | 
								act.OpType = ActionClosePullRequest
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if opts.Issue.IsPull {
 | 
							if opts.Issue.IsPull {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,16 +26,16 @@ var PullRequestQueue = sync.NewUniqueQueue(setting.Repository.PullRequestQueueLe
 | 
				
			||||||
type PullRequestType int
 | 
					type PullRequestType int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	PULL_REQUEST_GITEA PullRequestType = iota
 | 
						PullRequestGitea PullRequestType = iota
 | 
				
			||||||
	PULL_REQUEST_GIT
 | 
						PullRequestGit
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type PullRequestStatus int
 | 
					type PullRequestStatus int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	PULL_REQUEST_STATUS_CONFLICT PullRequestStatus = iota
 | 
						PullRequestStatusConflict PullRequestStatus = iota
 | 
				
			||||||
	PULL_REQUEST_STATUS_CHECKING
 | 
						PullRequestStatusChecking
 | 
				
			||||||
	PULL_REQUEST_STATUS_MERGEABLE
 | 
						PullRequestStatusMergeable
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// PullRequest represents relation between pull request and repositories.
 | 
					// PullRequest represents relation between pull request and repositories.
 | 
				
			||||||
| 
						 | 
					@ -129,8 +129,8 @@ func (pr *PullRequest) APIFormat() *api.PullRequest {
 | 
				
			||||||
		HasMerged: pr.HasMerged,
 | 
							HasMerged: pr.HasMerged,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if pr.Status != PULL_REQUEST_STATUS_CHECKING {
 | 
						if pr.Status != PullRequestStatusChecking {
 | 
				
			||||||
		mergeable := pr.Status != PULL_REQUEST_STATUS_CONFLICT
 | 
							mergeable := pr.Status != PullRequestStatusConflict
 | 
				
			||||||
		apiPullRequest.Mergeable = &mergeable
 | 
							apiPullRequest.Mergeable = &mergeable
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if pr.HasMerged {
 | 
						if pr.HasMerged {
 | 
				
			||||||
| 
						 | 
					@ -168,12 +168,12 @@ func (pr *PullRequest) GetBaseRepo() (err error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// IsChecking returns true if this pull request is still checking conflict.
 | 
					// IsChecking returns true if this pull request is still checking conflict.
 | 
				
			||||||
func (pr *PullRequest) IsChecking() bool {
 | 
					func (pr *PullRequest) IsChecking() bool {
 | 
				
			||||||
	return pr.Status == PULL_REQUEST_STATUS_CHECKING
 | 
						return pr.Status == PullRequestStatusChecking
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// CanAutoMerge returns true if this pull request can be merged automatically.
 | 
					// CanAutoMerge returns true if this pull request can be merged automatically.
 | 
				
			||||||
func (pr *PullRequest) CanAutoMerge() bool {
 | 
					func (pr *PullRequest) CanAutoMerge() bool {
 | 
				
			||||||
	return pr.Status == PULL_REQUEST_STATUS_MERGEABLE
 | 
						return pr.Status == PullRequestStatusMergeable
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Merge merges pull request to base repository.
 | 
					// Merge merges pull request to base repository.
 | 
				
			||||||
| 
						 | 
					@ -285,8 +285,8 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error
 | 
				
			||||||
		log.Error(4, "LoadAttributes: %v", err)
 | 
							log.Error(4, "LoadAttributes: %v", err)
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err = PrepareWebhooks(pr.Issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
 | 
						if err = PrepareWebhooks(pr.Issue.Repo, HookEventPullRequest, &api.PullRequestPayload{
 | 
				
			||||||
		Action:      api.HOOK_ISSUE_CLOSED,
 | 
							Action:      api.HookIssueClosed,
 | 
				
			||||||
		Index:       pr.Index,
 | 
							Index:       pr.Index,
 | 
				
			||||||
		PullRequest: pr.APIFormat(),
 | 
							PullRequest: pr.APIFormat(),
 | 
				
			||||||
		Repository:  pr.Issue.Repo.APIFormat(nil),
 | 
							Repository:  pr.Issue.Repo.APIFormat(nil),
 | 
				
			||||||
| 
						 | 
					@ -323,7 +323,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error
 | 
				
			||||||
		Pusher:     pr.HeadRepo.MustOwner().APIFormat(),
 | 
							Pusher:     pr.HeadRepo.MustOwner().APIFormat(),
 | 
				
			||||||
		Sender:     doer.APIFormat(),
 | 
							Sender:     doer.APIFormat(),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err = PrepareWebhooks(pr.BaseRepo, HOOK_EVENT_PUSH, p); err != nil {
 | 
						if err = PrepareWebhooks(pr.BaseRepo, HookEventPush, p); err != nil {
 | 
				
			||||||
		return fmt.Errorf("PrepareWebhooks: %v", err)
 | 
							return fmt.Errorf("PrepareWebhooks: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
| 
						 | 
					@ -367,7 +367,7 @@ func (pr *PullRequest) testPatch() (err error) {
 | 
				
			||||||
		return fmt.Errorf("UpdateLocalCopy: %v", err)
 | 
							return fmt.Errorf("UpdateLocalCopy: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pr.Status = PULL_REQUEST_STATUS_CHECKING
 | 
						pr.Status = PullRequestStatusChecking
 | 
				
			||||||
	_, stderr, err := process.ExecDir(-1, pr.BaseRepo.LocalCopyPath(),
 | 
						_, stderr, err := process.ExecDir(-1, pr.BaseRepo.LocalCopyPath(),
 | 
				
			||||||
		fmt.Sprintf("testPatch (git apply --check): %d", pr.BaseRepo.ID),
 | 
							fmt.Sprintf("testPatch (git apply --check): %d", pr.BaseRepo.ID),
 | 
				
			||||||
		"git", "apply", "--check", patchPath)
 | 
							"git", "apply", "--check", patchPath)
 | 
				
			||||||
| 
						 | 
					@ -376,7 +376,7 @@ func (pr *PullRequest) testPatch() (err error) {
 | 
				
			||||||
			if strings.Contains(stderr, patchConflicts[i]) {
 | 
								if strings.Contains(stderr, patchConflicts[i]) {
 | 
				
			||||||
				log.Trace("PullRequest[%d].testPatch (apply): has conflit", pr.ID)
 | 
									log.Trace("PullRequest[%d].testPatch (apply): has conflit", pr.ID)
 | 
				
			||||||
				fmt.Println(stderr)
 | 
									fmt.Println(stderr)
 | 
				
			||||||
				pr.Status = PULL_REQUEST_STATUS_CONFLICT
 | 
									pr.Status = PullRequestStatusConflict
 | 
				
			||||||
				return nil
 | 
									return nil
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -414,8 +414,8 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
 | 
				
			||||||
		return fmt.Errorf("testPatch: %v", err)
 | 
							return fmt.Errorf("testPatch: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// No conflict appears after test means mergeable.
 | 
						// No conflict appears after test means mergeable.
 | 
				
			||||||
	if pr.Status == PULL_REQUEST_STATUS_CHECKING {
 | 
						if pr.Status == PullRequestStatusChecking {
 | 
				
			||||||
		pr.Status = PULL_REQUEST_STATUS_MERGEABLE
 | 
							pr.Status = PullRequestStatusMergeable
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pr.IssueID = pull.ID
 | 
						pr.IssueID = pull.ID
 | 
				
			||||||
| 
						 | 
					@ -430,7 +430,7 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
 | 
				
			||||||
	if err = NotifyWatchers(&Action{
 | 
						if err = NotifyWatchers(&Action{
 | 
				
			||||||
		ActUserID:    pull.Poster.ID,
 | 
							ActUserID:    pull.Poster.ID,
 | 
				
			||||||
		ActUserName:  pull.Poster.Name,
 | 
							ActUserName:  pull.Poster.Name,
 | 
				
			||||||
		OpType:       ACTION_CREATE_PULL_REQUEST,
 | 
							OpType:       ActionCreatePullRequest,
 | 
				
			||||||
		Content:      fmt.Sprintf("%d|%s", pull.Index, pull.Title),
 | 
							Content:      fmt.Sprintf("%d|%s", pull.Index, pull.Title),
 | 
				
			||||||
		RepoID:       repo.ID,
 | 
							RepoID:       repo.ID,
 | 
				
			||||||
		RepoUserName: repo.Owner.Name,
 | 
							RepoUserName: repo.Owner.Name,
 | 
				
			||||||
| 
						 | 
					@ -444,8 +444,8 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pr.Issue = pull
 | 
						pr.Issue = pull
 | 
				
			||||||
	pull.PullRequest = pr
 | 
						pull.PullRequest = pr
 | 
				
			||||||
	if err = PrepareWebhooks(repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
 | 
						if err = PrepareWebhooks(repo, HookEventPullRequest, &api.PullRequestPayload{
 | 
				
			||||||
		Action:      api.HOOK_ISSUE_OPENED,
 | 
							Action:      api.HookIssueOpened,
 | 
				
			||||||
		Index:       pull.Index,
 | 
							Index:       pull.Index,
 | 
				
			||||||
		PullRequest: pr.APIFormat(),
 | 
							PullRequest: pr.APIFormat(),
 | 
				
			||||||
		Repository:  repo.APIFormat(nil),
 | 
							Repository:  repo.APIFormat(nil),
 | 
				
			||||||
| 
						 | 
					@ -618,7 +618,7 @@ func (pr *PullRequest) PushToBaseRepo() (err error) {
 | 
				
			||||||
// AddToTaskQueue adds itself to pull request test task queue.
 | 
					// AddToTaskQueue adds itself to pull request test task queue.
 | 
				
			||||||
func (pr *PullRequest) AddToTaskQueue() {
 | 
					func (pr *PullRequest) AddToTaskQueue() {
 | 
				
			||||||
	go PullRequestQueue.AddFunc(pr.ID, func() {
 | 
						go PullRequestQueue.AddFunc(pr.ID, func() {
 | 
				
			||||||
		pr.Status = PULL_REQUEST_STATUS_CHECKING
 | 
							pr.Status = PullRequestStatusChecking
 | 
				
			||||||
		if err := pr.UpdateCols("status"); err != nil {
 | 
							if err := pr.UpdateCols("status"); err != nil {
 | 
				
			||||||
			log.Error(5, "AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err)
 | 
								log.Error(5, "AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -693,8 +693,8 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool
 | 
				
			||||||
					log.Error(4, "LoadAttributes: %v", err)
 | 
										log.Error(4, "LoadAttributes: %v", err)
 | 
				
			||||||
					continue
 | 
										continue
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				if err = PrepareWebhooks(pr.Issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
 | 
									if err = PrepareWebhooks(pr.Issue.Repo, HookEventPullRequest, &api.PullRequestPayload{
 | 
				
			||||||
					Action:      api.HOOK_ISSUE_SYNCHRONIZED,
 | 
										Action:      api.HookIssueSynchronized,
 | 
				
			||||||
					Index:       pr.Issue.Index,
 | 
										Index:       pr.Issue.Index,
 | 
				
			||||||
					PullRequest: pr.Issue.PullRequest.APIFormat(),
 | 
										PullRequest: pr.Issue.PullRequest.APIFormat(),
 | 
				
			||||||
					Repository:  pr.Issue.Repo.APIFormat(nil),
 | 
										Repository:  pr.Issue.Repo.APIFormat(nil),
 | 
				
			||||||
| 
						 | 
					@ -733,8 +733,8 @@ func ChangeUsernameInPullRequests(oldUserName, newUserName string) error {
 | 
				
			||||||
// and set to be either conflict or mergeable.
 | 
					// and set to be either conflict or mergeable.
 | 
				
			||||||
func (pr *PullRequest) checkAndUpdateStatus() {
 | 
					func (pr *PullRequest) checkAndUpdateStatus() {
 | 
				
			||||||
	// Status is not changed to conflict means mergeable.
 | 
						// Status is not changed to conflict means mergeable.
 | 
				
			||||||
	if pr.Status == PULL_REQUEST_STATUS_CHECKING {
 | 
						if pr.Status == PullRequestStatusChecking {
 | 
				
			||||||
		pr.Status = PULL_REQUEST_STATUS_MERGEABLE
 | 
							pr.Status = PullRequestStatusMergeable
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Make sure there is no waiting test to process before levaing the checking status.
 | 
						// Make sure there is no waiting test to process before levaing the checking status.
 | 
				
			||||||
| 
						 | 
					@ -750,7 +750,7 @@ func (pr *PullRequest) checkAndUpdateStatus() {
 | 
				
			||||||
func TestPullRequests() {
 | 
					func TestPullRequests() {
 | 
				
			||||||
	prs := make([]*PullRequest, 0, 10)
 | 
						prs := make([]*PullRequest, 0, 10)
 | 
				
			||||||
	x.Iterate(PullRequest{
 | 
						x.Iterate(PullRequest{
 | 
				
			||||||
		Status: PULL_REQUEST_STATUS_CHECKING,
 | 
							Status: PullRequestStatusChecking,
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
		func(idx int, bean interface{}) error {
 | 
							func(idx int, bean interface{}) error {
 | 
				
			||||||
			pr := bean.(*PullRequest)
 | 
								pr := bean.(*PullRequest)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,8 +77,8 @@ type HookStatus int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	HOOK_STATUS_NONE = iota
 | 
						HOOK_STATUS_NONE = iota
 | 
				
			||||||
	HOOK_STATUS_SUCCEED
 | 
						HookStatusSucceed
 | 
				
			||||||
	HOOK_STATUS_FAILED
 | 
						HookStatusFail
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Webhook represents a web hook object.
 | 
					// Webhook represents a web hook object.
 | 
				
			||||||
| 
						 | 
					@ -323,9 +323,9 @@ func IsValidHookTaskType(name string) bool {
 | 
				
			||||||
type HookEventType string
 | 
					type HookEventType string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	HOOK_EVENT_CREATE       HookEventType = "create"
 | 
						HookEventCreate       HookEventType = "create"
 | 
				
			||||||
	HOOK_EVENT_PUSH         HookEventType = "push"
 | 
						HookEventPush         HookEventType = "push"
 | 
				
			||||||
	HOOK_EVENT_PULL_REQUEST HookEventType = "pull_request"
 | 
						HookEventPullRequest HookEventType = "pull_request"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// HookRequest represents hook task request information.
 | 
					// HookRequest represents hook task request information.
 | 
				
			||||||
| 
						 | 
					@ -459,15 +459,15 @@ func PrepareWebhooks(repo *Repository, event HookEventType, p api.Payloader) err
 | 
				
			||||||
	var payloader api.Payloader
 | 
						var payloader api.Payloader
 | 
				
			||||||
	for _, w := range ws {
 | 
						for _, w := range ws {
 | 
				
			||||||
		switch event {
 | 
							switch event {
 | 
				
			||||||
		case HOOK_EVENT_CREATE:
 | 
							case HookEventCreate:
 | 
				
			||||||
			if !w.HasCreateEvent() {
 | 
								if !w.HasCreateEvent() {
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		case HOOK_EVENT_PUSH:
 | 
							case HookEventPush:
 | 
				
			||||||
			if !w.HasPushEvent() {
 | 
								if !w.HasPushEvent() {
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		case HOOK_EVENT_PULL_REQUEST:
 | 
							case HookEventPullRequest:
 | 
				
			||||||
			if !w.HasPullRequestEvent() {
 | 
								if !w.HasPullRequestEvent() {
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					@ -544,9 +544,9 @@ func (t *HookTask) deliver() {
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if t.IsSucceed {
 | 
							if t.IsSucceed {
 | 
				
			||||||
			w.LastStatus = HOOK_STATUS_SUCCEED
 | 
								w.LastStatus = HookStatusSucceed
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			w.LastStatus = HOOK_STATUS_FAILED
 | 
								w.LastStatus = HookStatusFail
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if err = UpdateWebhook(w); err != nil {
 | 
							if err = UpdateWebhook(w); err != nil {
 | 
				
			||||||
			log.Error(5, "UpdateWebhook: %v", err)
 | 
								log.Error(5, "UpdateWebhook: %v", err)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -139,32 +139,32 @@ func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*S
 | 
				
			||||||
		fmt.Sprintf("#%d %s", p.Index, p.PullRequest.Title))
 | 
							fmt.Sprintf("#%d %s", p.Index, p.PullRequest.Title))
 | 
				
			||||||
	var text, title, attachmentText string
 | 
						var text, title, attachmentText string
 | 
				
			||||||
	switch p.Action {
 | 
						switch p.Action {
 | 
				
			||||||
	case api.HOOK_ISSUE_OPENED:
 | 
						case api.HookIssueOpened:
 | 
				
			||||||
		text = fmt.Sprintf("[%s] Pull request submitted by %s", p.Repository.FullName, senderLink)
 | 
							text = fmt.Sprintf("[%s] Pull request submitted by %s", p.Repository.FullName, senderLink)
 | 
				
			||||||
		title = titleLink
 | 
							title = titleLink
 | 
				
			||||||
		attachmentText = SlackTextFormatter(p.PullRequest.Body)
 | 
							attachmentText = SlackTextFormatter(p.PullRequest.Body)
 | 
				
			||||||
	case api.HOOK_ISSUE_CLOSED:
 | 
						case api.HookIssueClosed:
 | 
				
			||||||
		if p.PullRequest.HasMerged {
 | 
							if p.PullRequest.HasMerged {
 | 
				
			||||||
			text = fmt.Sprintf("[%s] Pull request merged: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
								text = fmt.Sprintf("[%s] Pull request merged: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			text = fmt.Sprintf("[%s] Pull request closed: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
								text = fmt.Sprintf("[%s] Pull request closed: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case api.HOOK_ISSUE_REOPENED:
 | 
						case api.HookIssueReopened:
 | 
				
			||||||
		text = fmt.Sprintf("[%s] Pull request re-opened: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
							text = fmt.Sprintf("[%s] Pull request re-opened: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
				
			||||||
	case api.HOOK_ISSUE_EDITED:
 | 
						case api.HookIssueEdited:
 | 
				
			||||||
		text = fmt.Sprintf("[%s] Pull request edited: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
							text = fmt.Sprintf("[%s] Pull request edited: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
				
			||||||
		attachmentText = SlackTextFormatter(p.PullRequest.Body)
 | 
							attachmentText = SlackTextFormatter(p.PullRequest.Body)
 | 
				
			||||||
	case api.HOOK_ISSUE_ASSIGNED:
 | 
						case api.HookIssueAssigned:
 | 
				
			||||||
		text = fmt.Sprintf("[%s] Pull request assigned to %s: %s by %s", p.Repository.FullName,
 | 
							text = fmt.Sprintf("[%s] Pull request assigned to %s: %s by %s", p.Repository.FullName,
 | 
				
			||||||
			SlackLinkFormatter(setting.AppUrl+p.PullRequest.Assignee.UserName, p.PullRequest.Assignee.UserName),
 | 
								SlackLinkFormatter(setting.AppUrl+p.PullRequest.Assignee.UserName, p.PullRequest.Assignee.UserName),
 | 
				
			||||||
			titleLink, senderLink)
 | 
								titleLink, senderLink)
 | 
				
			||||||
	case api.HOOK_ISSUE_UNASSIGNED:
 | 
						case api.HookIssueUnassigned:
 | 
				
			||||||
		text = fmt.Sprintf("[%s] Pull request unassigned: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
							text = fmt.Sprintf("[%s] Pull request unassigned: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
				
			||||||
	case api.HOOK_ISSUE_LABEL_UPDATED:
 | 
						case api.HookIssueLabelUpdated:
 | 
				
			||||||
		text = fmt.Sprintf("[%s] Pull request labels updated: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
							text = fmt.Sprintf("[%s] Pull request labels updated: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
				
			||||||
	case api.HOOK_ISSUE_LABEL_CLEARED:
 | 
						case api.HookIssueLabelCleared:
 | 
				
			||||||
		text = fmt.Sprintf("[%s] Pull request labels cleared: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
							text = fmt.Sprintf("[%s] Pull request labels cleared: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
				
			||||||
	case api.HOOK_ISSUE_SYNCHRONIZED:
 | 
						case api.HookIssueSynchronized:
 | 
				
			||||||
		text = fmt.Sprintf("[%s] Pull request synchronized: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
							text = fmt.Sprintf("[%s] Pull request synchronized: %s by %s", p.Repository.FullName, titleLink, senderLink)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -190,11 +190,11 @@ func GetSlackPayload(p api.Payloader, event HookEventType, meta string) (*SlackP
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch event {
 | 
						switch event {
 | 
				
			||||||
	case HOOK_EVENT_CREATE:
 | 
						case HookEventCreate:
 | 
				
			||||||
		return getSlackCreatePayload(p.(*api.CreatePayload), slack)
 | 
							return getSlackCreatePayload(p.(*api.CreatePayload), slack)
 | 
				
			||||||
	case HOOK_EVENT_PUSH:
 | 
						case HookEventPush:
 | 
				
			||||||
		return getSlackPushPayload(p.(*api.PushPayload), slack)
 | 
							return getSlackPushPayload(p.(*api.PushPayload), slack)
 | 
				
			||||||
	case HOOK_EVENT_PULL_REQUEST:
 | 
						case HookEventPullRequest:
 | 
				
			||||||
		return getSlackPullRequestPayload(p.(*api.PullRequestPayload), slack)
 | 
							return getSlackPullRequestPayload(p.(*api.PullRequestPayload), slack)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,9 +59,9 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
 | 
				
			||||||
		HookEvent: &models.HookEvent{
 | 
							HookEvent: &models.HookEvent{
 | 
				
			||||||
			ChooseEvents: true,
 | 
								ChooseEvents: true,
 | 
				
			||||||
			HookEvents: models.HookEvents{
 | 
								HookEvents: models.HookEvents{
 | 
				
			||||||
				Create:      com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_CREATE)),
 | 
									Create:      com.IsSliceContainsStr(form.Events, string(models.HookEventCreate)),
 | 
				
			||||||
				Push:        com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PUSH)),
 | 
									Push:        com.IsSliceContainsStr(form.Events, string(models.HookEventPush)),
 | 
				
			||||||
				PullRequest: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PULL_REQUEST)),
 | 
									PullRequest: com.IsSliceContainsStr(form.Events, string(models.HookEventPullRequest)),
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		IsActive:     form.Active,
 | 
							IsActive:     form.Active,
 | 
				
			||||||
| 
						 | 
					@ -145,9 +145,9 @@ func EditHook(ctx *context.APIContext, form api.EditHookOption) {
 | 
				
			||||||
	w.PushOnly = false
 | 
						w.PushOnly = false
 | 
				
			||||||
	w.SendEverything = false
 | 
						w.SendEverything = false
 | 
				
			||||||
	w.ChooseEvents = true
 | 
						w.ChooseEvents = true
 | 
				
			||||||
	w.Create = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_CREATE))
 | 
						w.Create = com.IsSliceContainsStr(form.Events, string(models.HookEventCreate))
 | 
				
			||||||
	w.Push = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PUSH))
 | 
						w.Push = com.IsSliceContainsStr(form.Events, string(models.HookEventPush))
 | 
				
			||||||
	w.PullRequest = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PULL_REQUEST))
 | 
						w.PullRequest = com.IsSliceContainsStr(form.Events, string(models.HookEventPullRequest))
 | 
				
			||||||
	if err = w.UpdateEvent(); err != nil {
 | 
						if err = w.UpdateEvent(); err != nil {
 | 
				
			||||||
		ctx.Error(500, "UpdateEvent", err)
 | 
							ctx.Error(500, "UpdateEvent", err)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -687,7 +687,7 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm)
 | 
				
			||||||
		HeadRepo:     headRepo,
 | 
							HeadRepo:     headRepo,
 | 
				
			||||||
		BaseRepo:     repo,
 | 
							BaseRepo:     repo,
 | 
				
			||||||
		MergeBase:    prInfo.MergeBase,
 | 
							MergeBase:    prInfo.MergeBase,
 | 
				
			||||||
		Type:         models.PULL_REQUEST_GITEA,
 | 
							Type:         models.PullRequestGitea,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// FIXME: check error in the case two people send pull request at almost same time, give nice error prompt
 | 
						// FIXME: check error in the case two people send pull request at almost same time, give nice error prompt
 | 
				
			||||||
	// instead of 500.
 | 
						// instead of 500.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -383,7 +383,7 @@ func TestWebhook(ctx *context.Context) {
 | 
				
			||||||
		Pusher: apiUser,
 | 
							Pusher: apiUser,
 | 
				
			||||||
		Sender: apiUser,
 | 
							Sender: apiUser,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err := models.PrepareWebhooks(ctx.Repo.Repository, models.HOOK_EVENT_PUSH, p); err != nil {
 | 
						if err := models.PrepareWebhooks(ctx.Repo.Repository, models.HookEventPush, p); err != nil {
 | 
				
			||||||
		ctx.Flash.Error("PrepareWebhooks: " + err.Error())
 | 
							ctx.Flash.Error("PrepareWebhooks: " + err.Error())
 | 
				
			||||||
		ctx.Status(500)
 | 
							ctx.Status(500)
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -198,15 +198,15 @@ func (p *PushPayload) Branch() string {
 | 
				
			||||||
type HookIssueAction string
 | 
					type HookIssueAction string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	HOOK_ISSUE_OPENED        HookIssueAction = "opened"
 | 
						HookIssueOpened        HookIssueAction = "opened"
 | 
				
			||||||
	HOOK_ISSUE_CLOSED        HookIssueAction = "closed"
 | 
						HookIssueClosed        HookIssueAction = "closed"
 | 
				
			||||||
	HOOK_ISSUE_REOPENED      HookIssueAction = "reopened"
 | 
						HookIssueReopened      HookIssueAction = "reopened"
 | 
				
			||||||
	HOOK_ISSUE_EDITED        HookIssueAction = "edited"
 | 
						HookIssueEdited        HookIssueAction = "edited"
 | 
				
			||||||
	HOOK_ISSUE_ASSIGNED      HookIssueAction = "assigned"
 | 
						HookIssueAssigned      HookIssueAction = "assigned"
 | 
				
			||||||
	HOOK_ISSUE_UNASSIGNED    HookIssueAction = "unassigned"
 | 
						HookIssueUnassigned    HookIssueAction = "unassigned"
 | 
				
			||||||
	HOOK_ISSUE_LABEL_UPDATED HookIssueAction = "label_updated"
 | 
						HookIssueLabelUpdated HookIssueAction = "label_updated"
 | 
				
			||||||
	HOOK_ISSUE_LABEL_CLEARED HookIssueAction = "label_cleared"
 | 
						HookIssueLabelCleared HookIssueAction = "label_cleared"
 | 
				
			||||||
	HOOK_ISSUE_SYNCHRONIZED  HookIssueAction = "synchronized"
 | 
						HookIssueSynchronized  HookIssueAction = "synchronized"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ChangesFromPayload struct {
 | 
					type ChangesFromPayload struct {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue