|
|
@@ -30,28 +30,28 @@ type ActionType int
|
|
|
|
|
|
// Note: To maintain backward compatibility only append to the end of list
|
|
|
const (
|
|
|
- ACTION_CREATE_REPO ActionType = iota + 1 // 1
|
|
|
- ACTION_RENAME_REPO // 2
|
|
|
- ACTION_STAR_REPO // 3
|
|
|
- ACTION_WATCH_REPO // 4
|
|
|
- ACTION_COMMIT_REPO // 5
|
|
|
- ACTION_CREATE_ISSUE // 6
|
|
|
- ACTION_CREATE_PULL_REQUEST // 7
|
|
|
- ACTION_TRANSFER_REPO // 8
|
|
|
- ACTION_PUSH_TAG // 9
|
|
|
- ACTION_COMMENT_ISSUE // 10
|
|
|
- ACTION_MERGE_PULL_REQUEST // 11
|
|
|
- ACTION_CLOSE_ISSUE // 12
|
|
|
- ACTION_REOPEN_ISSUE // 13
|
|
|
- ACTION_CLOSE_PULL_REQUEST // 14
|
|
|
- ACTION_REOPEN_PULL_REQUEST // 15
|
|
|
- ACTION_CREATE_BRANCH // 16
|
|
|
- ACTION_DELETE_BRANCH // 17
|
|
|
- ACTION_DELETE_TAG // 18
|
|
|
- ACTION_FORK_REPO // 19
|
|
|
- ACTION_MIRROR_SYNC_PUSH // 20
|
|
|
- ACTION_MIRROR_SYNC_CREATE // 21
|
|
|
- ACTION_MIRROR_SYNC_DELETE // 22
|
|
|
+ ActionCreateRepo ActionType = iota + 1 // 1
|
|
|
+ ActionRenameRepo // 2
|
|
|
+ ActionStarRepo // 3
|
|
|
+ ActionWatchRepo // 4
|
|
|
+ ActionCommitRepo // 5
|
|
|
+ ActionCreateIssue // 6
|
|
|
+ ActionCreatePullRequest // 7
|
|
|
+ ActionTransferRepo // 8
|
|
|
+ ActionPushTag // 9
|
|
|
+ ActionCommentIssue // 10
|
|
|
+ ActionMergePullRequest // 11
|
|
|
+ ActionCloseIssue // 12
|
|
|
+ ActionReopenIssue // 13
|
|
|
+ ActionClosePullRequest // 14
|
|
|
+ ActionReopenPullRequest // 15
|
|
|
+ ActionCreateBranch // 16
|
|
|
+ ActionDeleteBranch // 17
|
|
|
+ ActionDeleteTag // 18
|
|
|
+ ActionForkRepo // 19
|
|
|
+ ActionMirrorSyncPush // 20
|
|
|
+ ActionMirrorSyncCreate // 21
|
|
|
+ ActionMirrorSyncDelete // 22
|
|
|
)
|
|
|
|
|
|
var (
|
|
|
@@ -180,9 +180,9 @@ func (a *Action) GetIssueContent() string {
|
|
|
}
|
|
|
|
|
|
func newRepoAction(e Engine, doer, owner *User, repo *Repository) (err error) {
|
|
|
- opType := ACTION_CREATE_REPO
|
|
|
+ opType := ActionCreateRepo
|
|
|
if repo.IsFork {
|
|
|
- opType = ACTION_FORK_REPO
|
|
|
+ opType = ActionForkRepo
|
|
|
}
|
|
|
|
|
|
return notifyWatchers(e, &Action{
|
|
|
@@ -205,7 +205,7 @@ func renameRepoAction(e Engine, actUser *User, oldRepoName string, repo *Reposit
|
|
|
if err = notifyWatchers(e, &Action{
|
|
|
ActUserID: actUser.ID,
|
|
|
ActUserName: actUser.Name,
|
|
|
- OpType: ACTION_RENAME_REPO,
|
|
|
+ OpType: ActionRenameRepo,
|
|
|
RepoID: repo.ID,
|
|
|
RepoUserName: repo.Owner.Name,
|
|
|
RepoName: repo.Name,
|
|
|
@@ -481,10 +481,10 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
|
|
isNewRef := opts.OldCommitID == git.EMPTY_SHA
|
|
|
isDelRef := opts.NewCommitID == git.EMPTY_SHA
|
|
|
|
|
|
- opType := ACTION_COMMIT_REPO
|
|
|
+ opType := ActionCommitRepo
|
|
|
// Check if it's tag push or branch.
|
|
|
if strings.HasPrefix(opts.RefFullName, git.TAG_PREFIX) {
|
|
|
- opType = ACTION_PUSH_TAG
|
|
|
+ opType = ActionPushTag
|
|
|
} else {
|
|
|
// if not the first commit, set the compare URL.
|
|
|
if !isNewRef && !isDelRef {
|
|
|
@@ -523,7 +523,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
|
|
apiRepo := repo.APIFormat(nil)
|
|
|
apiPusher := pusher.APIFormat()
|
|
|
switch opType {
|
|
|
- case ACTION_COMMIT_REPO: // Push
|
|
|
+ case ActionCommitRepo: // Push
|
|
|
if isDelRef {
|
|
|
if err = PrepareWebhooks(repo, HOOK_EVENT_DELETE, &api.DeletePayload{
|
|
|
Ref: refName,
|
|
|
@@ -535,7 +535,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
|
|
return fmt.Errorf("PrepareWebhooks.(delete branch): %v", err)
|
|
|
}
|
|
|
|
|
|
- action.OpType = ACTION_DELETE_BRANCH
|
|
|
+ action.OpType = ActionDeleteBranch
|
|
|
if err = NotifyWatchers(action); err != nil {
|
|
|
return fmt.Errorf("NotifyWatchers.(delete branch): %v", err)
|
|
|
}
|
|
|
@@ -557,7 +557,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
|
|
return fmt.Errorf("PrepareWebhooks.(new branch): %v", err)
|
|
|
}
|
|
|
|
|
|
- action.OpType = ACTION_CREATE_BRANCH
|
|
|
+ action.OpType = ActionCreateBranch
|
|
|
if err = NotifyWatchers(action); err != nil {
|
|
|
return fmt.Errorf("NotifyWatchers.(new branch): %v", err)
|
|
|
}
|
|
|
@@ -581,12 +581,12 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
|
|
return fmt.Errorf("PrepareWebhooks.(new commit): %v", err)
|
|
|
}
|
|
|
|
|
|
- action.OpType = ACTION_COMMIT_REPO
|
|
|
+ action.OpType = ActionCommitRepo
|
|
|
if err = NotifyWatchers(action); err != nil {
|
|
|
return fmt.Errorf("NotifyWatchers.(new commit): %v", err)
|
|
|
}
|
|
|
|
|
|
- case ACTION_PUSH_TAG: // Tag
|
|
|
+ case ActionPushTag: // Tag
|
|
|
if isDelRef {
|
|
|
if err = PrepareWebhooks(repo, HOOK_EVENT_DELETE, &api.DeletePayload{
|
|
|
Ref: refName,
|
|
|
@@ -598,7 +598,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
|
|
return fmt.Errorf("PrepareWebhooks.(delete tag): %v", err)
|
|
|
}
|
|
|
|
|
|
- action.OpType = ACTION_DELETE_TAG
|
|
|
+ action.OpType = ActionDeleteTag
|
|
|
if err = NotifyWatchers(action); err != nil {
|
|
|
return fmt.Errorf("NotifyWatchers.(delete tag): %v", err)
|
|
|
}
|
|
|
@@ -615,7 +615,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
|
|
return fmt.Errorf("PrepareWebhooks.(new tag): %v", err)
|
|
|
}
|
|
|
|
|
|
- action.OpType = ACTION_PUSH_TAG
|
|
|
+ action.OpType = ActionPushTag
|
|
|
if err = NotifyWatchers(action); err != nil {
|
|
|
return fmt.Errorf("NotifyWatchers.(new tag): %v", err)
|
|
|
}
|
|
|
@@ -628,7 +628,7 @@ func transferRepoAction(e Engine, doer, oldOwner *User, repo *Repository) (err e
|
|
|
if err = notifyWatchers(e, &Action{
|
|
|
ActUserID: doer.ID,
|
|
|
ActUserName: doer.Name,
|
|
|
- OpType: ACTION_TRANSFER_REPO,
|
|
|
+ OpType: ActionTransferRepo,
|
|
|
RepoID: repo.ID,
|
|
|
RepoUserName: repo.Owner.Name,
|
|
|
RepoName: repo.Name,
|
|
|
@@ -658,7 +658,7 @@ func mergePullRequestAction(e Engine, doer *User, repo *Repository, issue *Issue
|
|
|
return notifyWatchers(e, &Action{
|
|
|
ActUserID: doer.ID,
|
|
|
ActUserName: doer.Name,
|
|
|
- OpType: ACTION_MERGE_PULL_REQUEST,
|
|
|
+ OpType: ActionMergePullRequest,
|
|
|
Content: fmt.Sprintf("%d|%s", issue.Index, issue.Title),
|
|
|
RepoID: repo.ID,
|
|
|
RepoUserName: repo.Owner.Name,
|
|
|
@@ -724,17 +724,17 @@ func MirrorSyncPushAction(repo *Repository, opts MirrorSyncPushActionOptions) er
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- return mirrorSyncAction(ACTION_MIRROR_SYNC_PUSH, repo, opts.RefName, data)
|
|
|
+ return mirrorSyncAction(ActionMirrorSyncPush, repo, opts.RefName, data)
|
|
|
}
|
|
|
|
|
|
// MirrorSyncCreateAction adds new action for mirror synchronization of new reference.
|
|
|
func MirrorSyncCreateAction(repo *Repository, refName string) error {
|
|
|
- return mirrorSyncAction(ACTION_MIRROR_SYNC_CREATE, repo, refName, nil)
|
|
|
+ return mirrorSyncAction(ActionMirrorSyncCreate, repo, refName, nil)
|
|
|
}
|
|
|
|
|
|
// MirrorSyncCreateAction adds new action for mirror synchronization of delete reference.
|
|
|
func MirrorSyncDeleteAction(repo *Repository, refName string) error {
|
|
|
- return mirrorSyncAction(ACTION_MIRROR_SYNC_DELETE, repo, refName, nil)
|
|
|
+ return mirrorSyncAction(ActionMirrorSyncDelete, repo, refName, nil)
|
|
|
}
|
|
|
|
|
|
// GetFeeds returns action list of given user in given context.
|