summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/access.go38
-rw-r--r--models/action.go54
-rw-r--r--models/admin.go6
-rw-r--r--models/git_diff.go66
-rw-r--r--models/git_diff_test.go4
-rw-r--r--models/issue.go60
-rw-r--r--models/issue_comment.go58
-rw-r--r--models/issue_label.go2
-rw-r--r--models/login_source.go76
-rw-r--r--models/mail.go28
-rw-r--r--models/models.go2
-rw-r--r--models/org.go4
-rw-r--r--models/org_team.go2
-rw-r--r--models/pull.go52
-rw-r--r--models/repo.go28
-rw-r--r--models/repo_collaboration.go10
-rw-r--r--models/repo_mirror.go6
-rw-r--r--models/ssh_key.go20
-rw-r--r--models/user.go18
-rw-r--r--models/webhook.go40
-rw-r--r--models/webhook_slack.go26
21 files changed, 300 insertions, 300 deletions
diff --git a/models/access.go b/models/access.go
index e46819f2d4..fa3642cf53 100644
--- a/models/access.go
+++ b/models/access.go
@@ -13,22 +13,22 @@ import (
type AccessMode int
const (
- ACCESS_MODE_NONE AccessMode = iota // 0
- ACCESS_MODE_READ // 1
- ACCESS_MODE_WRITE // 2
- ACCESS_MODE_ADMIN // 3
- ACCESS_MODE_OWNER // 4
+ AccessModeNone AccessMode = iota // 0
+ AccessModeRead // 1
+ AccessModeWrite // 2
+ AccessModeAdmin // 3
+ AccessModeOwner // 4
)
func (mode AccessMode) String() string {
switch mode {
- case ACCESS_MODE_READ:
+ case AccessModeRead:
return "read"
- case ACCESS_MODE_WRITE:
+ case AccessModeWrite:
return "write"
- case ACCESS_MODE_ADMIN:
+ case AccessModeAdmin:
return "admin"
- case ACCESS_MODE_OWNER:
+ case AccessModeOwner:
return "owner"
default:
return "none"
@@ -39,11 +39,11 @@ func (mode AccessMode) String() string {
func ParseAccessMode(permission string) AccessMode {
switch permission {
case "write":
- return ACCESS_MODE_WRITE
+ return AccessModeWrite
case "admin":
- return ACCESS_MODE_ADMIN
+ return AccessModeAdmin
default:
- return ACCESS_MODE_READ
+ return AccessModeRead
}
}
@@ -58,9 +58,9 @@ type Access struct {
}
func accessLevel(e Engine, u *User, repo *Repository) (AccessMode, error) {
- mode := ACCESS_MODE_NONE
+ mode := AccessModeNone
if !repo.IsPrivate {
- mode = ACCESS_MODE_READ
+ mode = AccessModeRead
}
if u == nil {
@@ -68,7 +68,7 @@ func accessLevel(e Engine, u *User, repo *Repository) (AccessMode, error) {
}
if u.ID == repo.OwnerID {
- return ACCESS_MODE_OWNER, nil
+ return AccessModeOwner, nil
}
a := &Access{UserID: u.ID, RepoID: repo.ID}
@@ -135,7 +135,7 @@ func (user *User) GetAccessibleRepositories(limit int) (repos []*Repository, _ e
}
func maxAccessMode(modes ...AccessMode) AccessMode {
- max := ACCESS_MODE_NONE
+ max := AccessModeNone
for _, mode := range modes {
if mode > max {
max = mode
@@ -146,9 +146,9 @@ func maxAccessMode(modes ...AccessMode) AccessMode {
// FIXME: do corss-comparison so reduce deletions and additions to the minimum?
func (repo *Repository) refreshAccesses(e Engine, accessMap map[int64]AccessMode) (err error) {
- minMode := ACCESS_MODE_READ
+ minMode := AccessModeRead
if !repo.IsPrivate {
- minMode = ACCESS_MODE_WRITE
+ minMode = AccessModeWrite
}
newAccesses := make([]Access, 0, len(accessMap))
@@ -212,7 +212,7 @@ func (repo *Repository) recalculateTeamAccesses(e Engine, ignTeamID int64) (err
// Owner team gets owner access, and skip for teams that do not
// have relations with repository.
if t.IsOwnerTeam() {
- t.Authorize = ACCESS_MODE_OWNER
+ t.Authorize = AccessModeOwner
} else if !t.hasRepository(e, repo.ID) {
continue
}
diff --git a/models/action.go b/models/action.go
index 6943802f00..96dd2d7680 100644
--- a/models/action.go
+++ b/models/action.go
@@ -17,7 +17,7 @@ import (
"github.com/go-xorm/xorm"
"github.com/go-gitea/git"
- api "github.com/gogits/go-gogs-client"
+ api "github.com/go-gitea/go-sdk/gitea"
"github.com/go-gitea/gitea/modules/base"
"github.com/go-gitea/gitea/modules/log"
@@ -27,21 +27,21 @@ import (
type ActionType int
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
+ 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
)
var (
@@ -176,7 +176,7 @@ func newRepoAction(e Engine, u *User, repo *Repository) (err error) {
if err = notifyWatchers(e, &Action{
ActUserID: u.ID,
ActUserName: u.Name,
- OpType: ACTION_CREATE_REPO,
+ OpType: ActionCreateRepo,
RepoID: repo.ID,
RepoUserName: repo.Owner.Name,
RepoName: repo.Name,
@@ -198,7 +198,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,
@@ -454,10 +454,10 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
}
isNewBranch := false
- opType := ACTION_COMMIT_REPO
+ opType := ActionCommitRepo
// Check it's tag push or branch.
if strings.HasPrefix(opts.RefFullName, git.TAG_PREFIX) {
- opType = ACTION_PUSH_TAG
+ opType = ActionPushTag
opts.Commits = &PushCommits{}
} else {
// if not the first commit, set the compare URL.
@@ -503,8 +503,8 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
apiPusher := pusher.APIFormat()
apiRepo := repo.APIFormat(nil)
switch opType {
- case ACTION_COMMIT_REPO: // Push
- if err = PrepareWebhooks(repo, HOOK_EVENT_PUSH, &api.PushPayload{
+ case ActionCommitRepo: // Push
+ if err = PrepareWebhooks(repo, HookEventPush, &api.PushPayload{
Ref: opts.RefFullName,
Before: opts.OldCommitID,
After: opts.NewCommitID,
@@ -518,7 +518,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
}
if isNewBranch {
- return PrepareWebhooks(repo, HOOK_EVENT_CREATE, &api.CreatePayload{
+ return PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{
Ref: refName,
RefType: "branch",
Repo: apiRepo,
@@ -526,8 +526,8 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
})
}
- case ACTION_PUSH_TAG: // Create
- return PrepareWebhooks(repo, HOOK_EVENT_CREATE, &api.CreatePayload{
+ case ActionPushTag: // Create
+ return PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{
Ref: refName,
RefType: "tag",
Repo: apiRepo,
@@ -542,7 +542,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,
@@ -572,7 +572,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,
diff --git a/models/admin.go b/models/admin.go
index 3f17c2fdaa..dab92863a5 100644
--- a/models/admin.go
+++ b/models/admin.go
@@ -22,7 +22,7 @@ import (
type NoticeType int
const (
- NOTICE_REPOSITORY NoticeType = iota + 1
+ NoticeRepository NoticeType = iota + 1
)
// Notice represents a system notice for admin.
@@ -65,9 +65,9 @@ func CreateNotice(tp NoticeType, desc string) error {
return err
}
-// CreateRepositoryNotice creates new system notice with type NOTICE_REPOSITORY.
+// CreateRepositoryNotice creates new system notice with type NoticeRepository.
func CreateRepositoryNotice(desc string) error {
- return CreateNotice(NOTICE_REPOSITORY, desc)
+ return CreateNotice(NoticeRepository, desc)
}
// RemoveAllWithNotice removes all directories in given path and
diff --git a/models/git_diff.go b/models/git_diff.go
index 704a4a382a..8c1b47ab60 100644
--- a/models/git_diff.go
+++ b/models/git_diff.go
@@ -31,19 +31,19 @@ import (
type DiffLineType uint8
const (
- DIFF_LINE_PLAIN DiffLineType = iota + 1
- DIFF_LINE_ADD
- DIFF_LINE_DEL
- DIFF_LINE_SECTION
+ DiffLinePlain DiffLineType = iota + 1
+ DiffLineAdd
+ DiffLineDel
+ DiffLineSection
)
type DiffFileType uint8
const (
- DIFF_FILE_ADD DiffFileType = iota + 1
- DIFF_FILE_CHANGE
- DIFF_FILE_DEL
- DIFF_FILE_RENAME
+ DiffFileAdd DiffFileType = iota + 1
+ DiffFileChange
+ DiffFileDel
+ DiffFileRename
)
type DiffLine struct {
@@ -73,19 +73,19 @@ func diffToHTML(diffs []diffmatchpatch.Diff, lineType DiffLineType) template.HTM
// Reproduce signs which are cutted for inline diff before.
switch lineType {
- case DIFF_LINE_ADD:
+ case DiffLineAdd:
buf.WriteByte('+')
- case DIFF_LINE_DEL:
+ case DiffLineDel:
buf.WriteByte('-')
}
for i := range diffs {
switch {
- case diffs[i].Type == diffmatchpatch.DiffInsert && lineType == DIFF_LINE_ADD:
+ case diffs[i].Type == diffmatchpatch.DiffInsert && lineType == DiffLineAdd:
buf.Write(addedCodePrefix)
buf.WriteString(html.EscapeString(diffs[i].Text))
buf.Write(codeTagSuffix)
- case diffs[i].Type == diffmatchpatch.DiffDelete && lineType == DIFF_LINE_DEL:
+ case diffs[i].Type == diffmatchpatch.DiffDelete && lineType == DiffLineDel:
buf.Write(removedCodePrefix)
buf.WriteString(html.EscapeString(diffs[i].Text))
buf.Write(codeTagSuffix)
@@ -109,9 +109,9 @@ func (diffSection *DiffSection) GetLine(lineType DiffLineType, idx int) *DiffLin
LOOP:
for _, diffLine := range diffSection.Lines {
switch diffLine.Type {
- case DIFF_LINE_ADD:
+ case DiffLineAdd:
addCount++
- case DIFF_LINE_DEL:
+ case DiffLineDel:
delCount++
default:
if matchDiffLine != nil {
@@ -123,11 +123,11 @@ LOOP:
}
switch lineType {
- case DIFF_LINE_DEL:
+ case DiffLineDel:
if diffLine.RightIdx == 0 && diffLine.LeftIdx == idx-difference {
matchDiffLine = diffLine
}
- case DIFF_LINE_ADD:
+ case DiffLineAdd:
if diffLine.LeftIdx == 0 && diffLine.RightIdx == idx+difference {
matchDiffLine = diffLine
}
@@ -159,15 +159,15 @@ func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine) tem
// try to find equivalent diff line. ignore, otherwise
switch diffLine.Type {
- case DIFF_LINE_ADD:
- compareDiffLine = diffSection.GetLine(DIFF_LINE_DEL, diffLine.RightIdx)
+ case DiffLineAdd:
+ compareDiffLine = diffSection.GetLine(DiffLineDel, diffLine.RightIdx)
if compareDiffLine == nil {
return template.HTML(html.EscapeString(diffLine.Content))
}
diff1 = compareDiffLine.Content
diff2 = diffLine.Content
- case DIFF_LINE_DEL:
- compareDiffLine = diffSection.GetLine(DIFF_LINE_ADD, diffLine.LeftIdx)
+ case DiffLineDel:
+ compareDiffLine = diffSection.GetLine(DiffLineAdd, diffLine.LeftIdx)
if compareDiffLine == nil {
return template.HTML(html.EscapeString(diffLine.Content))
}
@@ -264,7 +264,7 @@ func ParsePatch(maxLines, maxLineCharacteres, maxFiles int, reader io.Reader) (*
switch {
case line[0] == ' ':
- diffLine := &DiffLine{Type: DIFF_LINE_PLAIN, Content: line, LeftIdx: leftLine, RightIdx: rightLine}
+ diffLine := &DiffLine{Type: DiffLinePlain, Content: line, LeftIdx: leftLine, RightIdx: rightLine}
leftLine++
rightLine++
curSection.Lines = append(curSection.Lines, diffLine)
@@ -273,7 +273,7 @@ func ParsePatch(maxLines, maxLineCharacteres, maxFiles int, reader io.Reader) (*
curSection = &DiffSection{}
curFile.Sections = append(curFile.Sections, curSection)
ss := strings.Split(line, "@@")
- diffLine := &DiffLine{Type: DIFF_LINE_SECTION, Content: line}
+ diffLine := &DiffLine{Type: DiffLineSection, Content: line}
curSection.Lines = append(curSection.Lines, diffLine)
// Parse line number.
@@ -289,14 +289,14 @@ func ParsePatch(maxLines, maxLineCharacteres, maxFiles int, reader io.Reader) (*
case line[0] == '+':
curFile.Addition++
diff.TotalAddition++
- diffLine := &DiffLine{Type: DIFF_LINE_ADD, Content: line, RightIdx: rightLine}
+ diffLine := &DiffLine{Type: DiffLineAdd, Content: line, RightIdx: rightLine}
rightLine++
curSection.Lines = append(curSection.Lines, diffLine)
continue
case line[0] == '-':
curFile.Deletion++
diff.TotalDeletion++
- diffLine := &DiffLine{Type: DIFF_LINE_DEL, Content: line, LeftIdx: leftLine}
+ diffLine := &DiffLine{Type: DiffLineDel, Content: line, LeftIdx: leftLine}
if leftLine > 0 {
leftLine++
}
@@ -330,7 +330,7 @@ func ParsePatch(maxLines, maxLineCharacteres, maxFiles int, reader io.Reader) (*
curFile = &DiffFile{
Name: a,
Index: len(diff.Files) + 1,
- Type: DIFF_FILE_CHANGE,
+ Type: DiffFileChange,
Sections: make([]*DiffSection, 0, 10),
}
diff.Files = append(diff.Files, curFile)
@@ -354,15 +354,15 @@ func ParsePatch(maxLines, maxLineCharacteres, maxFiles int, reader io.Reader) (*
switch {
case strings.HasPrefix(line, "new file"):
- curFile.Type = DIFF_FILE_ADD
+ curFile.Type = DiffFileAdd
curFile.IsCreated = true
case strings.HasPrefix(line, "deleted"):
- curFile.Type = DIFF_FILE_DEL
+ curFile.Type = DiffFileDel
curFile.IsDeleted = true
case strings.HasPrefix(line, "index"):
- curFile.Type = DIFF_FILE_CHANGE
+ curFile.Type = DiffFileChange
case strings.HasPrefix(line, "similarity index 100%"):
- curFile.Type = DIFF_FILE_RENAME
+ curFile.Type = DiffFileRename
curFile.IsRenamed = true
curFile.OldName = curFile.Name
curFile.Name = b
@@ -459,8 +459,8 @@ func GetDiffRange(repoPath, beforeCommitID, afterCommitID string, maxLines, maxL
type RawDiffType string
const (
- RAW_DIFF_NORMAL RawDiffType = "diff"
- RAW_DIFF_PATCH RawDiffType = "patch"
+ RawDiffNormal RawDiffType = "diff"
+ RawDiffPatch RawDiffType = "patch"
)
// GetRawDiff dumps diff results of repository in given commit ID to io.Writer.
@@ -478,14 +478,14 @@ func GetRawDiff(repoPath, commitID string, diffType RawDiffType, writer io.Write
var cmd *exec.Cmd
switch diffType {
- case RAW_DIFF_NORMAL:
+ case RawDiffNormal:
if commit.ParentCount() == 0 {
cmd = exec.Command("git", "show", commitID)
} else {
c, _ := commit.Parent(0)
cmd = exec.Command("git", "diff", "-M", c.ID.String(), commitID)
}
- case RAW_DIFF_PATCH:
+ case RawDiffPatch:
if commit.ParentCount() == 0 {
cmd = exec.Command("git", "format-patch", "--no-signature", "--stdout", "--root", commitID)
} else {
diff --git a/models/git_diff_test.go b/models/git_diff_test.go
index 7f390adb3f..cf98f65399 100644
--- a/models/git_diff_test.go
+++ b/models/git_diff_test.go
@@ -24,12 +24,12 @@ func TestDiffToHTML(t *testing.T) {
dmp.Diff{dmp.DiffInsert, "bar"},
dmp.Diff{dmp.DiffDelete, " baz"},
dmp.Diff{dmp.DiffEqual, " biz"},
- }, DIFF_LINE_ADD))
+ }, DiffLineAdd))
assertEqual(t, "-foo <span class=\"removed-code\">bar</span> biz", diffToHTML([]dmp.Diff{
dmp.Diff{dmp.DiffEqual, "foo "},
dmp.Diff{dmp.DiffDelete, "bar"},
dmp.Diff{dmp.DiffInsert, " baz"},
dmp.Diff{dmp.DiffEqual, " biz"},
- }, DIFF_LINE_DEL))
+ }, DiffLineDel))
}
diff --git a/models/issue.go b/models/issue.go
index be9eedcd2b..6078f53f2d 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -16,7 +16,7 @@ import (
"github.com/Unknwon/com"
"github.com/go-xorm/xorm"
- api "github.com/gogits/go-gogs-client"
+ api "github.com/go-gitea/go-sdk/gitea"
gouuid "github.com/satori/go.uuid"
"github.com/go-gitea/gitea/modules/base"
@@ -239,8 +239,8 @@ func (issue *Issue) sendLabelUpdatedWebhook(doer *User) {
log.Error(4, "LoadIssue: %v", err)
return
}
- err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
- Action: api.HOOK_ISSUE_LABEL_UPDATED,
+ err = PrepareWebhooks(issue.Repo, HookEventPullRequest, &api.PullRequestPayload{
+ Action: api.HookIssueLabelUpdated,
Index: issue.Index,
PullRequest: issue.PullRequest.APIFormat(),
Repository: issue.Repo.APIFormat(nil),
@@ -343,8 +343,8 @@ func (issue *Issue) ClearLabels(doer *User) (err error) {
log.Error(4, "LoadIssue: %v", err)
return
}
- err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
- Action: api.HOOK_ISSUE_LABEL_CLEARED,
+ err = PrepareWebhooks(issue.Repo, HookEventPullRequest, &api.PullRequestPayload{
+ Action: api.HookIssueLabelCleared,
Index: issue.Index,
PullRequest: issue.PullRequest.APIFormat(),
Repository: issue.Repo.APIFormat(nil),
@@ -471,11 +471,11 @@ func (issue *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (e
Sender: doer.APIFormat(),
}
if isClosed {
- apiPullRequest.Action = api.HOOK_ISSUE_CLOSED
+ apiPullRequest.Action = api.HookIssueClosed
} 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 {
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 {
issue.PullRequest.Issue = issue
- err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
- Action: api.HOOK_ISSUE_EDITED,
+ err = PrepareWebhooks(issue.Repo, HookEventPullRequest, &api.PullRequestPayload{
+ Action: api.HookIssueEdited,
Index: issue.Index,
Changes: &api.ChangesPayload{
Title: &api.ChangesFromPayload{
@@ -526,8 +526,8 @@ func (issue *Issue) ChangeContent(doer *User, content string) (err error) {
if issue.IsPull {
issue.PullRequest.Issue = issue
- err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
- Action: api.HOOK_ISSUE_EDITED,
+ err = PrepareWebhooks(issue.Repo, HookEventPullRequest, &api.PullRequestPayload{
+ Action: api.HookIssueEdited,
Index: issue.Index,
Changes: &api.ChangesPayload{
Body: &api.ChangesFromPayload{
@@ -571,11 +571,11 @@ func (issue *Issue) ChangeAssignee(doer *User, assigneeID int64) (err error) {
Sender: doer.APIFormat(),
}
if isRemoveAssignee {
- apiPullRequest.Action = api.HOOK_ISSUE_UNASSIGNED
+ apiPullRequest.Action = api.HookIssueUnassigned
} 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 {
log.Error(4, "PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, isRemoveAssignee, err)
@@ -624,7 +624,7 @@ func newIssue(e *xorm.Session, opts NewIssueOptions) (err error) {
// Assume assignee is invalid and drop silently.
opts.Issue.AssigneeID = 0
if assignee != nil {
- valid, err := hasAccess(e, assignee, opts.Repo, ACCESS_MODE_WRITE)
+ valid, err := hasAccess(e, assignee, opts.Repo, AccessModeWrite)
if err != nil {
return fmt.Errorf("hasAccess [user_id: %d, repo_id: %d]: %v", assignee.ID, opts.Repo.ID, err)
}
@@ -714,7 +714,7 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string)
if err = NotifyWatchers(&Action{
ActUserID: issue.Poster.ID,
ActUserName: issue.Poster.Name,
- OpType: ACTION_CREATE_ISSUE,
+ OpType: ActionCreateIssue,
Content: fmt.Sprintf("%d|%s", issue.Index, issue.Title),
RepoID: repo.ID,
RepoUserName: repo.Owner.Name,
@@ -1005,9 +1005,9 @@ func GetIssueUserPairsByMode(uid, rid int64, isClosed bool, page, filterMode int
}
switch filterMode {
- case FM_ASSIGN:
+ case FilterModeAssign:
sess.And("is_assigned=?", true)
- case FM_CREATE:
+ case FilterModeCreate:
sess.And("is_poster=?", true)
default:
return ius, nil
@@ -1070,10 +1070,10 @@ type IssueStats struct {
// Filter modes.
const (
- FM_ALL = iota
- FM_ASSIGN
- FM_CREATE
- FM_MENTION
+ FilterModeAll = iota
+ FilterModeAssign
+ FilterModeCreate
+ FilterModeMention
)
func parseCountResult(results []map[string][]byte) int64 {
@@ -1122,7 +1122,7 @@ func GetIssueStats(opts *IssueStatsOptions) *IssueStats {
}
switch opts.FilterMode {
- case FM_ALL, FM_ASSIGN:
+ case FilterModeAll, FilterModeAssign:
stats.OpenCount, _ = countSession(opts).
And("is_closed = ?", false).
Count(&Issue{})
@@ -1130,7 +1130,7 @@ func GetIssueStats(opts *IssueStatsOptions) *IssueStats {
stats.ClosedCount, _ = countSession(opts).
And("is_closed = ?", true).
Count(&Issue{})
- case FM_CREATE:
+ case FilterModeCreate:
stats.OpenCount, _ = countSession(opts).
And("poster_id = ?", opts.UserID).
And("is_closed = ?", false).
@@ -1140,7 +1140,7 @@ func GetIssueStats(opts *IssueStatsOptions) *IssueStats {
And("poster_id = ?", opts.UserID).
And("is_closed = ?", true).
Count(&Issue{})
- case FM_MENTION:
+ case FilterModeMention:
stats.OpenCount, _ = countSession(opts).
Join("INNER", "issue_user", "issue.id = issue_user.issue_id").
And("issue_user.uid = ?", opts.UserID).
@@ -1186,10 +1186,10 @@ func GetUserIssueStats(repoID, uid int64, repoIDs []int64, filterMode int, isPul
closedCountSession := countSession(true, isPull, repoID, repoIDs)
switch filterMode {
- case FM_ASSIGN:
+ case FilterModeAssign:
openCountSession.And("assignee_id = ?", uid)
closedCountSession.And("assignee_id = ?", uid)
- case FM_CREATE:
+ case FilterModeCreate:
openCountSession.And("poster_id = ?", uid)
closedCountSession.And("poster_id = ?", uid)
}
@@ -1214,10 +1214,10 @@ func GetRepoIssueStats(repoID, uid int64, filterMode int, isPull bool) (numOpen
closedCountSession := countSession(true, isPull, repoID)
switch filterMode {
- case FM_ASSIGN:
+ case FilterModeAssign:
openCountSession.And("assignee_id = ?", uid)
closedCountSession.And("assignee_id = ?", uid)
- case FM_CREATE:
+ case FilterModeCreate:
openCountSession.And("poster_id = ?", uid)
closedCountSession.And("poster_id = ?", uid)
}
diff --git a/models/issue_comment.go b/models/issue_comment.go
index 1c615ab511..47246701a0 100644
--- a/models/issue_comment.go
+++ b/models/issue_comment.go
@@ -12,7 +12,7 @@ import (
"github.com/Unknwon/com"
"github.com/go-xorm/xorm"
- api "github.com/gogits/go-gogs-client"
+ api "github.com/go-gitea/go-sdk/gitea"
"github.com/go-gitea/gitea/modules/log"
"github.com/go-gitea/gitea/modules/markdown"
@@ -23,27 +23,27 @@ type CommentType int
const (
// Plain comment, can be associated with a commit (CommitID > 0) and a line (LineNum > 0)
- COMMENT_TYPE_COMMENT CommentType = iota
- COMMENT_TYPE_REOPEN
- COMMENT_TYPE_CLOSE
+ CommentTypeComment CommentType = iota
+ CommentTypeReopen
+ CommentTypeClose
// References.
- COMMENT_TYPE_ISSUE_REF
+ CommentTypeIssueRef
// Reference from a commit (not part of a pull request)
- COMMENT_TYPE_COMMIT_REF
+ CommentTypeCommitRef
// Reference from a comment
- COMMENT_TYPE_COMMENT_REF
+ CommentTypeCommentRef
// Reference from a pull request
- COMMENT_TYPE_PULL_REF
+ CommentTypePullRef
)
type CommentTag int
const (
- COMMENT_TAG_NONE CommentTag = iota
- COMMENT_TAG_POSTER
- COMMENT_TAG_WRITER
- COMMENT_TAG_OWNER
+ CommentTagNone CommentTag = iota
+ CommentTagPoster
+ CommentTagWriter
+ CommentTagOwner
)
// Comment represents a comment in commit and issue page.
@@ -144,11 +144,11 @@ func (cmt *Comment) MailParticipants(opType ActionType, issue *Issue) (err error
}
switch opType {
- case ACTION_COMMENT_ISSUE:
+ case ActionCommentIssue:
issue.Content = cmt.Content
- case ACTION_CLOSE_ISSUE:
+ case ActionCloseIssue:
issue.Content = fmt.Sprintf("Closed #%d", issue.Index)
- case ACTION_REOPEN_ISSUE:
+ case ActionReopenIssue:
issue.Content = fmt.Sprintf("Reopened #%d", issue.Index)
}
if err = mailIssueCommentToParticipants(issue, cmt.Poster, mentions); err != nil {
@@ -187,8 +187,8 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
// Check comment type.
switch opts.Type {
- case COMMENT_TYPE_COMMENT:
- act.OpType = ACTION_COMMENT_ISSUE
+ case CommentTypeComment:
+ act.OpType = ActionCommentIssue
if _, err = e.Exec("UPDATE `issue` SET num_comments=num_comments+1 WHERE id=?", opts.Issue.ID); err != nil {
return nil, err
@@ -216,10 +216,10 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
}
}
- case COMMENT_TYPE_REOPEN:
- act.OpType = ACTION_REOPEN_ISSUE
+ case CommentTypeReopen:
+ act.OpType = ActionReopenIssue
if opts.Issue.IsPull {
- act.OpType = ACTION_REOPEN_PULL_REQUEST
+ act.OpType = ActionReopenPullRequest
}
if opts.Issue.IsPull {
@@ -231,10 +231,10 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
return nil, err
}
- case COMMENT_TYPE_CLOSE:
- act.OpType = ACTION_CLOSE_ISSUE
+ case CommentTypeClose:
+ act.OpType = ActionCloseIssue
if opts.Issue.IsPull {
- act.OpType = ACTION_CLOSE_PULL_REQUEST
+ act.OpType = ActionClosePullRequest
}
if opts.Issue.IsPull {
@@ -260,9 +260,9 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
}
func createStatusComment(e *xorm.Session, doer *User, repo *Repository, issue *Issue) (*Comment, error) {
- cmtType := COMMENT_TYPE_CLOSE
+ cmtType := CommentTypeClose
if !issue.IsClosed {
- cmtType = COMMENT_TYPE_REOPEN
+ cmtType = CommentTypeReopen
}
return createComment(e, &CreateCommentOptions{
Type: cmtType,
@@ -304,7 +304,7 @@ func CreateComment(opts *CreateCommentOptions) (comment *Comment, err error) {
// CreateIssueComment creates a plain issue comment.
func CreateIssueComment(doer *User, repo *Repository, issue *Issue, content string, attachments []string) (*Comment, error) {
return CreateComment(&CreateCommentOptions{
- Type: COMMENT_TYPE_COMMENT,
+ Type: CommentTypeComment,
Doer: doer,
Repo: repo,
Issue: issue,
@@ -321,7 +321,7 @@ func CreateRefComment(doer *User, repo *Repository, issue *Issue, content, commi
// Check if same reference from same commit has already existed.
has, err := x.Get(&Comment{
- Type: COMMENT_TYPE_COMMIT_REF,
+ Type: CommentTypeCommitRef,
IssueID: issue.ID,
CommitSHA: commitSHA,
})
@@ -332,7 +332,7 @@ func CreateRefComment(doer *User, repo *Repository, issue *Issue, content, commi
}
_, err = CreateComment(&CreateCommentOptions{
- Type: COMMENT_TYPE_COMMIT_REF,
+ Type: CommentTypeCommitRef,
Doer: doer,
Repo: repo,
Issue: issue,
@@ -403,7 +403,7 @@ func DeleteCommentByID(id int64) error {
return err
}
- if comment.Type == COMMENT_TYPE_COMMENT {
+ if comment.Type == CommentTypeComment {
if _, err = sess.Exec("UPDATE `issue` SET num_comments = num_comments - 1 WHERE id = ?", comment.IssueID); err != nil {
return err
}
diff --git a/models/issue_label.go b/models/issue_label.go
index 0b9644c249..24d6bcac75 100644
--- a/models/issue_label.go
+++ b/models/issue_label.go
@@ -13,7 +13,7 @@ import (
"github.com/go-xorm/xorm"
- api "github.com/gogits/go-gogs-client"
+ api "github.com/go-gitea/go-sdk/gitea"
"github.com/go-gitea/gitea/modules/base"
)
diff --git a/models/login_source.go b/models/login_source.go
index c9a0c73764..ce5f5bddbe 100644
--- a/models/login_source.go
+++ b/models/login_source.go
@@ -28,25 +28,25 @@ type LoginType int
// Note: new type must append to the end of list to maintain compatibility.
const (
- LOGIN_NOTYPE LoginType = iota
- LOGIN_PLAIN // 1
- LOGIN_LDAP // 2
- LOGIN_SMTP // 3
- LOGIN_PAM // 4
- LOGIN_DLDAP // 5
+ LoginNoType LoginType = iota
+ LoginPlain // 1
+ LoginLDAP // 2
+ LoginSMTP // 3
+ LoginPAM // 4
+ LoginDLDAP // 5
)
var LoginNames = map[LoginType]string{
- LOGIN_LDAP: "LDAP (via BindDN)",
- LOGIN_DLDAP: "LDAP (simple auth)", // Via direct bind
- LOGIN_SMTP: "SMTP",
- LOGIN_PAM: "PAM",
+ LoginLDAP: "LDAP (via BindDN)",
+ LoginDLDAP: "LDAP (simple auth)", // Via direct bind
+ LoginSMTP: "SMTP",
+ LoginPAM: "PAM",
}
var SecurityProtocolNames = map[ldap.SecurityProtocol]string{
- ldap.SECURITY_PROTOCOL_UNENCRYPTED: "Unencrypted",
- ldap.SECURITY_PROTOCOL_LDAPS: "LDAPS",
- ldap.SECURITY_PROTOCOL_START_TLS: "StartTLS",
+ ldap.SecurityProtocolUnencrypted: "Unencrypted",
+ ldap.SecurityProtocolLDAPS: "LDAPS",
+ ldap.SecurityProtocolStartTLS: "StartTLS",
}
// Ensure structs implemented interface.
@@ -139,11 +139,11 @@ func (source *LoginSource) BeforeSet(colName string, val xorm.Cell) {
switch colName {
case "type":
switch LoginType(Cell2Int64(val)) {
- case LOGIN_LDAP, LOGIN_DLDAP:
+ case LoginLDAP, LoginDLDAP:
source.Cfg = new(LDAPConfig)
- case LOGIN_SMTP:
+ case LoginSMTP:
source.Cfg = new(SMTPConfig)
- case LOGIN_PAM:
+ case LoginPAM:
source.Cfg = new(PAMConfig)
default:
panic("unrecognized login source type: " + com.ToStr(*val))
@@ -165,32 +165,32 @@ func (source *LoginSource) TypeName() string {
}
func (source *LoginSource) IsLDAP() bool {
- return source.Type == LOGIN_LDAP
+ return source.Type == LoginLDAP
}
func (source *LoginSource) IsDLDAP() bool {
- return source.Type == LOGIN_DLDAP
+ return source.Type == LoginDLDAP
}
func (source *LoginSource) IsSMTP() bool {
- return source.Type == LOGIN_SMTP
+ return source.Type == LoginSMTP
}
func (source *LoginSource) IsPAM() bool {
- return source.Type == LOGIN_PAM
+ return source.Type == LoginPAM
}
func (source *LoginSource) HasTLS() bool {
return ((source.IsLDAP() || source.IsDLDAP()) &&
- source.LDAP().SecurityProtocol > ldap.SECURITY_PROTOCOL_UNENCRYPTED) ||
+ source.LDAP().SecurityProtocol > ldap.SecurityProtocolUnencrypted) ||
source.IsSMTP()
}
func (source *LoginSource) UseTLS() bool {
switch source.Type {
- case LOGIN_LDAP, LOGIN_DLDAP:
- return source.LDAP().SecurityProtocol != ldap.SECURITY_PROTOCOL_UNENCRYPTED
- case LOGIN_SMTP:
+ case LoginLDAP, LoginDLDAP:
+ return source.LDAP().SecurityProtocol != ldap.SecurityProtocolUnencrypted
+ case LoginSMTP:
return source.SMTP().TLS
}
@@ -199,9 +199,9 @@ func (source *LoginSource) UseTLS() bool {
func (source *LoginSource) SkipVerify() bool {
switch source.Type {
- case LOGIN_LDAP, LOGIN_DLDAP:
+ case LoginLDAP, LoginDLDAP:
return source.LDAP().SkipVerify
- case LOGIN_SMTP:
+ case LoginSMTP:
return source.SMTP().SkipVerify
}
@@ -293,7 +293,7 @@ func composeFullName(firstname, surname, username string) string {
// LoginViaLDAP queries if login/password is valid against the LDAP directory pool,
// and create a local user if success when enabled.
func LoginViaLDAP(user *User, login, passowrd string, source *LoginSource, autoRegister bool) (*User, error) {
- username, fn, sn, mail, isAdmin, succeed := source.Cfg.(*LDAPConfig).SearchEntry(login, passowrd, source.Type == LOGIN_DLDAP)
+ username, fn, sn, mail, isAdmin, succeed := source.Cfg.(*LDAPConfig).SearchEntry(login, passowrd, source.Type == LoginDLDAP)
if !succeed {
// User not in LDAP, do nothing
return nil, ErrUserNotExist{0, login}
@@ -358,11 +358,11 @@ func (auth *smtpLoginAuth) Next(fromServer []byte, more bool) ([]byte, error) {
}
const (
- SMTP_PLAIN = "PLAIN"
- SMTP_LOGIN = "LOGIN"
+ SMTPPlain = "PLAIN"
+ SMTPLogin = "LOGIN"
)
-var SMTPAuths = []string{SMTP_PLAIN, SMTP_LOGIN}
+var SMTPAuths = []string{SMTPPlain, SMTPLogin}
func SMTPAuth(a smtp.Auth, cfg *SMTPConfig) error {
c, err := smtp.Dial(fmt.Sprintf("%s:%d", cfg.Host, cfg.Port))
@@ -411,9 +411,9 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC
}
var auth smtp.Auth
- if cfg.Auth == SMTP_PLAIN {
+ if cfg.Auth == SMTPPlain {
auth = smtp.PlainAuth("", login, password, cfg.Host)
- } else if cfg.Auth == SMTP_LOGIN {
+ } else if cfg.Auth == SMTPLogin {
auth = &smtpLoginAuth{login, password}
} else {
return nil, errors.New("Unsupported SMTP auth type")
@@ -445,7 +445,7 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC
Name: strings.ToLower(username),
Email: login,
Passwd: password,
- LoginType: LOGIN_SMTP,
+ LoginType: LoginSMTP,
LoginSource: sourceID,
LoginName: login,
IsActive: true,
@@ -479,7 +479,7 @@ func LoginViaPAM(user *User, login, password string, sourceID int64, cfg *PAMCon
Name: login,
Email: login,
Passwd: password,
- LoginType: LOGIN_PAM,
+ LoginType: LoginPAM,
LoginSource: sourceID,
LoginName: login,
IsActive: true,
@@ -493,11 +493,11 @@ func ExternalUserLogin(user *User, login, password string, source *LoginSource,
}
switch source.Type {
- case LOGIN_LDAP, LOGIN_DLDAP:
+ case LoginLDAP, LoginDLDAP:
return LoginViaLDAP(user, login, password, source, autoRegister)
- case LOGIN_SMTP:
+ case LoginSMTP:
return LoginViaSMTP(user, login, password, source.ID, source.Cfg.(*SMTPConfig), autoRegister)
- case LOGIN_PAM:
+ case LoginPAM:
return LoginViaPAM(user, login, password, source.ID, source.Cfg.(*PAMConfig), autoRegister)
}
@@ -520,7 +520,7 @@ func UserSignIn(username, passowrd string) (*User, error) {
if hasUser {
switch user.LoginType {
- case LOGIN_NOTYPE, LOGIN_PLAIN:
+ case LoginNoType, LoginPlain:
if user.ValidatePassword(passowrd) {
return user, nil
}
diff --git a/models/mail.go b/models/mail.go
index df5fd789bc..04e571ae53 100644
--- a/models/mail.go
+++ b/models/mail.go
@@ -20,15 +20,15 @@ import (
)
const (
- MAIL_AUTH_ACTIVATE base.TplName = "auth/activate"
- MAIL_AUTH_ACTIVATE_EMAIL base.TplName = "auth/activate_email"
- MAIL_AUTH_RESET_PASSWORD base.TplName = "auth/reset_passwd"
- MAIL_AUTH_REGISTER_NOTIFY base.TplName = "auth/register_notify"
+ MailAuthActivate base.TplName = "auth/activate"
+ MailAuthActivateEmail base.TplName = "auth/activate_email"
+ MailAuthResetPassword base.TplName = "auth/reset_passwd"
+ MailAuthRegisterNotify base.TplName = "auth/register_notify"
- MAIL_ISSUE_COMMENT base.TplName = "issue/comment"
- MAIL_ISSUE_MENTION base.TplName = "issue/mention"
+ MailIssueComment base.TplName = "issue/comment"
+ MailIssueMention base.TplName = "issue/mention"
- MAIL_NOTIFY_COLLABORATOR base.TplName = "notify/collaborator"
+ MailNotifyCollaborator base.TplName = "notify/collaborator"
)
type MailRender interface {
@@ -77,11 +77,11 @@ func SendUserMail(c *macaron.Context, u *User, tpl base.TplName, code, subject,
}
func SendActivateAccountMail(c *macaron.Context, u *User) {
- SendUserMail(c, u, MAIL_AUTH_ACTIVATE, u.GenerateActivateCode(), c.Tr("mail.activate_account"), "activate account")
+ SendUserMail(c, u, MailAuthActivate, u.GenerateActivateCode(), c.Tr("mail.activate_account"), "activate account")
}
func SendResetPasswordMail(c *macaron.Context, u *User) {
- SendUserMail(c, u, MAIL_AUTH_RESET_PASSWORD, u.GenerateActivateCode(), c.Tr("mail.reset_password"), "reset password")
+ SendUserMail(c, u, MailAuthResetPassword, u.GenerateActivateCode(), c.Tr("mail.reset_password"), "reset password")
}
// SendActivateAccountMail sends confirmation email.
@@ -92,7 +92,7 @@ func SendActivateEmailMail(c *macaron.Context, u *User, email *EmailAddress) {
"Code": u.GenerateEmailActivateCode(email.Email),
"Email": email.Email,
}
- body, err := mailRender.HTMLString(string(MAIL_AUTH_ACTIVATE_EMAIL), data)
+ body, err := mailRender.HTMLString(string(MailAuthActivateEmail), data)
if err != nil {
log.Error(3, "HTMLString: %v", err)
return
@@ -109,7 +109,7 @@ func SendRegisterNotifyMail(c *macaron.Context, u *User) {
data := map[string]interface{}{
"Username": u.DisplayName(),
}
- body, err := mailRender.HTMLString(string(MAIL_AUTH_REGISTER_NOTIFY), data)
+ body, err := mailRender.HTMLString(string(MailAuthRegisterNotify), data)
if err != nil {
log.Error(3, "HTMLString: %v", err)
return
@@ -131,7 +131,7 @@ func SendCollaboratorMail(u, doer *User, repo *Repository) {
"RepoName": repoName,
"Link": repo.HTMLURL(),
}
- body, err := mailRender.HTMLString(string(MAIL_NOTIFY_COLLABORATOR), data)
+ body, err := mailRender.HTMLString(string(MailNotifyCollaborator), data)
if err != nil {
log.Error(3, "HTMLString: %v", err)
return
@@ -171,7 +171,7 @@ func SendIssueCommentMail(issue *Issue, doer *User, tos []string) {
return
}
- mailer.SendAsync(composeIssueMessage(issue, doer, MAIL_ISSUE_COMMENT, tos, "issue comment"))
+ mailer.SendAsync(composeIssueMessage(issue, doer, MailIssueComment, tos, "issue comment"))
}
// SendIssueMentionMail composes and sends issue mention emails to target receivers.
@@ -179,5 +179,5 @@ func SendIssueMentionMail(issue *Issue, doer *User, tos []string) {
if len(tos) == 0 {
return
}
- mailer.SendAsync(composeIssueMessage(issue, doer, MAIL_ISSUE_MENTION, tos, "issue mention"))
+ mailer.SendAsync(composeIssueMessage(issue, doer, MailIssueMention, tos, "issue mention"))
}
diff --git a/models/models.go b/models/models.go
index a9da884624..d6c30e1013 100644
--- a/models/models.go
+++ b/models/models.go
@@ -95,7 +95,7 @@ func LoadConfigs() {
DbCfg.Passwd = sec.Key("PASSWD").String()
}
DbCfg.SSLMode = sec.Key("SSL_MODE").String()
- DbCfg.Path = sec.Key("PATH").MustString("data/gogs.db")
+ DbCfg.Path = sec.Key("PATH").MustString("data/gitea.db")
}
// parsePostgreSQLHostPort parses given input in various forms defined in
diff --git a/models/org.go b/models/org.go
index ec54081857..9583e20927 100644
--- a/models/org.go
+++ b/models/org.go
@@ -141,7 +141,7 @@ func CreateOrganization(org, owner *User) (err error) {
OrgID: org.ID,
LowerName: strings.ToLower(OWNER_TEAM),
Name: OWNER_TEAM,
- Authorize: ACCESS_MODE_OWNER,
+ Authorize: AccessModeOwner,
NumMembers: 1,
}
if _, err = sess.Insert(t); err != nil {
@@ -170,7 +170,7 @@ func GetOrgByName(name string) (*User, error) {
}
u := &User{
LowerName: strings.ToLower(name),
- Type: USER_TYPE_ORGANIZATION,
+ Type: UserTypeOrganization,
}
has, err := x.Get(u)
if err != nil {
diff --git a/models/org_team.go b/models/org_team.go
index 07a90e08f1..b0796248a5 100644
--- a/models/org_team.go
+++ b/models/org_team.go
@@ -155,7 +155,7 @@ func (t *Team) removeRepository(e Engine, repo *Repository, recalculate bool) (e
return fmt.Errorf("get team members: %v", err)
}
for _, u := range t.Members {
- has, err := hasAccess(e, u, repo, ACCESS_MODE_READ)
+ has, err := hasAccess(e, u, repo, AccessModeRead)
if err != nil {
return err
} else if has {
diff --git a/models/pull.go b/models/pull.go
index ae508103d0..2437c040d8 100644
--- a/models/pull.go
+++ b/models/pull.go
@@ -18,7 +18,7 @@ import (
"github.com/go-gitea/gitea/modules/sync"
"github.com/go-xorm/xorm"
"github.com/go-gitea/git"
- api "github.com/gogits/go-gogs-client"
+ api "github.com/go-gitea/go-sdk/gitea"
)
var PullRequestQueue = sync.NewUniqueQueue(setting.Repository.PullRequestQueueLength)
@@ -26,16 +26,16 @@ var PullRequestQueue = sync.NewUniqueQueue(setting.Repository.PullRequestQueueLe
type PullRequestType int
const (
- PULL_REQUEST_GOGS PullRequestType = iota
- PLLL_ERQUEST_GIT
+ PullRequestGitea PullRequestType = iota
+ PullRequestGit
)
type PullRequestStatus int
const (
- PULL_REQUEST_STATUS_CONFLICT PullRequestStatus = iota
- PULL_REQUEST_STATUS_CHECKING
- PULL_REQUEST_STATUS_MERGEABLE
+ PullRequestStatusConflict PullRequestStatus = iota
+ PullRequestStatusChecking
+ PullRequestStatusMergeable
)
// PullRequest represents relation between pull request and repositories.
@@ -129,8 +129,8 @@ func (pr *PullRequest) APIFormat() *api.PullRequest {
HasMerged: pr.HasMerged,
}
- if pr.Status != PULL_REQUEST_STATUS_CHECKING {
- mergeable := pr.Status != PULL_REQUEST_STATUS_CONFLICT
+ if pr.Status != PullRequestStatusChecking {
+ mergeable := pr.Status != PullRequestStatusConflict
apiPullRequest.Mergeable = &mergeable
}
if pr.HasMerged {
@@ -168,12 +168,12 @@ func (pr *PullRequest) GetBaseRepo() (err error) {
// IsChecking returns true if this pull request is still checking conflict.
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.
func (pr *PullRequest) CanAutoMerge() bool {
- return pr.Status == PULL_REQUEST_STATUS_MERGEABLE
+ return pr.Status == PullRequestStatusMergeable
}
// 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)
return nil
}
- if err = PrepareWebhooks(pr.Issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
- Action: api.HOOK_ISSUE_CLOSED,
+ if err = PrepareWebhooks(pr.Issue.Repo, HookEventPullRequest, &api.PullRequestPayload{
+ Action: api.HookIssueClosed,
Index: pr.Index,
PullRequest: pr.APIFormat(),
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(),
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 nil
@@ -367,7 +367,7 @@ func (pr *PullRequest) testPatch() (err error) {
return fmt.Errorf("UpdateLocalCopy: %v", err)
}
- pr.Status = PULL_REQUEST_STATUS_CHECKING
+ pr.Status = PullRequestStatusChecking
_, stderr, err := process.ExecDir(-1, pr.BaseRepo.LocalCopyPath(),
fmt.Sprintf("testPatch (git apply --check): %d", pr.BaseRepo.ID),
"git", "apply", "--check", patchPath)
@@ -376,7 +376,7 @@ func (pr *PullRequest) testPatch() (err error) {
if strings.Contains(stderr, patchConflicts[i]) {
log.Trace("PullRequest[%d].testPatch (apply): has conflit", pr.ID)
fmt.Println(stderr)
- pr.Status = PULL_REQUEST_STATUS_CONFLICT
+ pr.Status = PullRequestStatusConflict
return nil
}
}
@@ -414,8 +414,8 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
return fmt.Errorf("testPatch: %v", err)
}
// No conflict appears after test means mergeable.
- if pr.Status == PULL_REQUEST_STATUS_CHECKING {
- pr.Status = PULL_REQUEST_STATUS_MERGEABLE
+ if pr.Status == PullRequestStatusChecking {
+ pr.Status = PullRequestStatusMergeable
}
pr.IssueID = pull.ID
@@ -430,7 +430,7 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
if err = NotifyWatchers(&Action{
ActUserID: pull.Poster.ID,
ActUserName: pull.Poster.Name,
- OpType: ACTION_CREATE_PULL_REQUEST,
+ OpType: ActionCreatePullRequest,
Content: fmt.Sprintf("%d|%s", pull.Index, pull.Title),
RepoID: repo.ID,
RepoUserName: repo.Owner.Name,
@@ -444,8 +444,8 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
pr.Issue = pull
pull.PullRequest = pr
- if err = PrepareWebhooks(repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
- Action: api.HOOK_ISSUE_OPENED,
+ if err = PrepareWebhooks(repo, HookEventPullRequest, &api.PullRequestPayload{
+ Action: api.HookIssueOpened,
Index: pull.Index,
PullRequest: pr.APIFormat(),
Repository: repo.APIFormat(nil),
@@ -618,7 +618,7 @@ func (pr *PullRequest) PushToBaseRepo() (err error) {
// AddToTaskQueue adds itself to pull request test task queue.
func (pr *PullRequest) AddToTaskQueue() {
go PullRequestQueue.AddFunc(pr.ID, func() {
- pr.Status = PULL_REQUEST_STATUS_CHECKING
+ pr.Status = PullRequestStatusChecking
if err := pr.UpdateCols("status"); err != nil {
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)
continue
}
- if err = PrepareWebhooks(pr.Issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
- Action: api.HOOK_ISSUE_SYNCHRONIZED,
+ if err = PrepareWebhooks(pr.Issue.Repo, HookEventPullRequest, &api.PullRequestPayload{
+ Action: api.HookIssueSynchronized,
Index: pr.Issue.Index,
PullRequest: pr.Issue.PullRequest.APIFormat(),
Repository: pr.Issue.Repo.APIFormat(nil),
@@ -733,8 +733,8 @@ func ChangeUsernameInPullRequests(oldUserName, newUserName string) error {
// and set to be either conflict or mergeable.
func (pr *PullRequest) checkAndUpdateStatus() {
// Status is not changed to conflict means mergeable.
- if pr.Status == PULL_REQUEST_STATUS_CHECKING {
- pr.Status = PULL_REQUEST_STATUS_MERGEABLE
+ if pr.Status == PullRequestStatusChecking {
+ pr.Status = PullRequestStatusMergeable
}
// Make sure there is no waiting test to process before levaing the checking status.
@@ -750,7 +750,7 @@ func (pr *PullRequest) checkAndUpdateStatus() {
func TestPullRequests() {
prs := make([]*PullRequest, 0, 10)
x.Iterate(PullRequest{
- Status: PULL_REQUEST_STATUS_CHECKING,
+ Status: PullRequestStatusChecking,
},
func(idx int, bean interface{}) error {
pr := bean.(*PullRequest)
diff --git a/models/repo.go b/models/repo.go
index 6fa023633c..edf5de9329 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -29,13 +29,13 @@ import (
"github.com/go-gitea/gitea/modules/sync"
"github.com/go-xorm/xorm"
"github.com/go-gitea/git"
- api "github.com/gogits/go-gogs-client"
+ api "github.com/go-gitea/go-sdk/gitea"
version "github.com/mcuadros/go-version"
ini "gopkg.in/ini.v1"
)
const (
- _TPL_UPDATE_HOOK = "#!/usr/bin/env %s\n%s update $1 $2 $3 --config='%s'\n"
+ tplUpdateHook = "#!/usr/bin/env %s\n%s update $1 $2 $3 --config='%s'\n"
)
var repoWorkingPool = sync.NewExclusivePool()
@@ -334,7 +334,7 @@ func (repo *Repository) getAssignees(e Engine) (_ []*User, err error) {
}
accesses := make([]*Access, 0, 10)
- if err = e.Where("repo_id = ? AND mode >= ?", repo.ID, ACCESS_MODE_WRITE).Find(&accesses); err != nil {
+ if err = e.Where("repo_id = ? AND mode >= ?", repo.ID, AccessModeWrite).Find(&accesses); err != nil {
return nil, err
}
@@ -418,7 +418,7 @@ func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) strin
}
func (repo *Repository) HasAccess(u *User) bool {
- has, _ := HasAccess(u, repo, ACCESS_MODE_READ)
+ has, _ := HasAccess(u, repo, AccessModeRead)
return has
}
@@ -706,7 +706,7 @@ func cleanUpMigrateGitConfig(configPath string) error {
func createUpdateHook(repoPath string) error {
return git.SetUpdateHook(repoPath,
- fmt.Sprintf(_TPL_UPDATE_HOOK, setting.ScriptType, "\""+setting.AppPath+"\"", setting.CustomConf))
+ fmt.Sprintf(tplUpdateHook, setting.ScriptType, "\""+setting.AppPath+"\"", setting.CustomConf))
}
// Finish migrating repository and/or wiki with things that don't need to be done for mirrors.
@@ -1613,18 +1613,18 @@ func RewriteRepositoryUpdateHook() error {
var taskStatusTable = sync.NewStatusTable()
const (
- _MIRROR_UPDATE = "mirror_update"
- _GIT_FSCK = "git_fsck"
- _CHECK_REPOs = "check_repos"
+ mirrorUpdate = "mirror_update"
+ gitFsck = "git_fsck"
+ checkRepos = "check_repos"
)
// GitFsck calls 'git fsck' to check repository health.
func GitFsck() {
- if taskStatusTable.IsRunning(_GIT_FSCK) {
+ if taskStatusTable.IsRunning(gitFsck) {
return
}
- taskStatusTable.Start(_GIT_FSCK)
- defer taskStatusTable.Stop(_GIT_FSCK)
+ taskStatusTable.Start(gitFsck)
+ defer taskStatusTable.Stop(gitFsck)
log.Trace("Doing: GitFsck")
@@ -1686,11 +1686,11 @@ func repoStatsCheck(checker *repoChecker) {
}
func CheckRepoStats() {
- if taskStatusTable.IsRunning(_CHECK_REPOs) {
+ if taskStatusTable.IsRunning(checkRepos) {
return
}
- taskStatusTable.Start(_CHECK_REPOs)
- defer taskStatusTable.Stop(_CHECK_REPOs)
+ taskStatusTable.Start(checkRepos)
+ defer taskStatusTable.Stop(checkRepos)
log.Trace("Doing: CheckRepoStats")
diff --git a/models/repo_collaboration.go b/models/repo_collaboration.go
index f4b23f9ebe..214aa2a015 100644
--- a/models/repo_collaboration.go
+++ b/models/repo_collaboration.go
@@ -18,11 +18,11 @@ type Collaboration struct {
func (c *Collaboration) ModeI18nKey() string {
switch c.Mode {
- case ACCESS_MODE_READ:
+ case AccessModeRead:
return "repo.settings.collaboration.read"
- case ACCESS_MODE_WRITE:
+ case AccessModeWrite:
return "repo.settings.collaboration.write"
- case ACCESS_MODE_ADMIN:
+ case AccessModeAdmin:
return "repo.settings.collaboration.admin"
default:
return "repo.settings.collaboration.undefined"
@@ -42,7 +42,7 @@ func (repo *Repository) AddCollaborator(u *User) error {
} else if has {
return nil
}
- collaboration.Mode = ACCESS_MODE_WRITE
+ collaboration.Mode = AccessModeWrite
sess := x.NewSession()
defer sessionRelease(sess)
@@ -105,7 +105,7 @@ func (repo *Repository) GetCollaborators() ([]*Collaborator, error) {
// ChangeCollaborationAccessMode sets new access mode for the collaboration.
func (repo *Repository) ChangeCollaborationAccessMode(uid int64, mode AccessMode) error {
// Discard invalid input
- if mode <= ACCESS_MODE_NONE || mode > ACCESS_MODE_OWNER {
+ if mode <= AccessModeNone || mode > AccessModeOwner {
return nil
}
diff --git a/models/repo_mirror.go b/models/repo_mirror.go
index 9688f579ab..c598f82bf8 100644
--- a/models/repo_mirror.go
+++ b/models/repo_mirror.go
@@ -191,11 +191,11 @@ func DeleteMirrorByRepoID(repoID int64) error {
// MirrorUpdate checks and updates mirror repositories.
func MirrorUpdate() {
- if taskStatusTable.IsRunning(_MIRROR_UPDATE) {
+ if taskStatusTable.IsRunning(mirrorUpdate) {
return
}
- taskStatusTable.Start(_MIRROR_UPDATE)
- defer taskStatusTable.Stop(_MIRROR_UPDATE)
+ taskStatusTable.Start(mirrorUpdate)
+ defer taskStatusTable.Stop(mirrorUpdate)
log.Trace("Doing: MirrorUpdate")
diff --git a/models/ssh_key.go b/models/ssh_key.go
index 77adce9f3b..932361c00c 100644
--- a/models/ssh_key.go
+++ b/models/ssh_key.go
@@ -29,7 +29,7 @@ import (
)
const (
- _TPL_PUBLICK_KEY = `command="%s serv key-%d --config='%s'",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n"
+ tplPublicKey = `command="%s serv key-%d --config='%s'",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n"
)
var sshOpLocker sync.Mutex
@@ -37,8 +37,8 @@ var sshOpLocker sync.Mutex
type KeyType int
const (
- KEY_TYPE_USER = iota + 1
- KEY_TYPE_DEPLOY
+ KeyTypeUser = iota + 1
+ KeyTypeDeploy
)
// PublicKey represents a user or deploy SSH public key.
@@ -85,7 +85,7 @@ func (k *PublicKey) OmitEmail() string {
// AuthorizedString returns formatted public key string for authorized_keys file.
func (key *PublicKey) AuthorizedString() string {
- return fmt.Sprintf(_TPL_PUBLICK_KEY, setting.AppPath, key.ID, setting.CustomConf, key.Content)
+ return fmt.Sprintf(tplPublicKey, setting.AppPath, key.ID, setting.CustomConf, key.Content)
}
func extractTypeFromBase64Key(key string) (string, error) {
@@ -352,7 +352,7 @@ func appendAuthorizedKeysToFile(keys ...*PublicKey) error {
func checkKeyContent(content string) error {
has, err := x.Get(&PublicKey{
Content: content,
- Type: KEY_TYPE_USER,
+ Type: KeyTypeUser,
})
if err != nil {
return err
@@ -415,8 +415,8 @@ func AddPublicKey(ownerID int64, name, content string) (*PublicKey, error) {
OwnerID: ownerID,
Name: name,
Content: content,
- Mode: ACCESS_MODE_WRITE,
- Type: KEY_TYPE_USER,
+ Mode: AccessModeWrite,
+ Type: KeyTypeUser,
}
if err = addKey(sess, key); err != nil {
return nil, fmt.Errorf("addKey: %v", err)
@@ -642,8 +642,8 @@ func AddDeployKey(repoID int64, name, content string) (*DeployKey, error) {
pkey := &PublicKey{
Content: content,
- Mode: ACCESS_MODE_READ,
- Type: KEY_TYPE_DEPLOY,
+ Mode: AccessModeRead,
+ Type: KeyTypeDeploy,
}
has, err := x.Get(pkey)
if err != nil {
@@ -720,7 +720,7 @@ func DeleteDeployKey(doer *User, id int64) error {
if err != nil {
return fmt.Errorf("GetRepositoryByID: %v", err)
}
- yes, err := HasAccess(doer, repo, ACCESS_MODE_ADMIN)
+ yes, err := HasAccess(doer, repo, AccessModeAdmin)
if err != nil {
return fmt.Errorf("HasAccess: %v", err)
} else if !yes {
diff --git a/models/user.go b/models/user.go
index d2e19eb17e..3870bdeb5a 100644
--- a/models/user.go
+++ b/models/user.go
@@ -25,7 +25,7 @@ import (
"github.com/nfnt/resize"
"github.com/go-gitea/git"
- api "github.com/gogits/go-gogs-client"
+ api "github.com/go-gitea/go-sdk/gitea"
"github.com/go-gitea/gitea/modules/avatar"
"github.com/go-gitea/gitea/modules/base"
@@ -37,8 +37,8 @@ import (
type UserType int
const (
- USER_TYPE_INDIVIDUAL UserType = iota // Historic reason to make it starts at 0.
- USER_TYPE_ORGANIZATION
+ UserTypeIndividual UserType = iota // Historic reason to make it starts at 0.
+ UserTypeOrganization
)
var (
@@ -140,9 +140,9 @@ func (u *User) APIFormat() *api.User {
}
}
-// returns true if user login type is LOGIN_PLAIN.
+// returns true if user login type is LoginPlain.
func (u *User) IsLocal() bool {
- return u.LoginType <= LOGIN_PLAIN
+ return u.LoginType <= LoginPlain
}
// HasForkedRepo checks if user has already forked a repository with given ID.
@@ -375,7 +375,7 @@ func (u *User) DeleteAvatar() error {
// IsAdminOfRepo returns true if user has admin or higher access of repository.
func (u *User) IsAdminOfRepo(repo *Repository) bool {
- has, err := HasAccess(u, repo, ACCESS_MODE_ADMIN)
+ has, err := HasAccess(u, repo, AccessModeAdmin)
if err != nil {
log.Error(3, "HasAccess: %v", err)
}
@@ -384,7 +384,7 @@ func (u *User) IsAdminOfRepo(repo *Repository) bool {
// IsWriterOfRepo returns true if user has write access to given repository.
func (u *User) IsWriterOfRepo(repo *Repository) bool {
- has, err := HasAccess(u, repo, ACCESS_MODE_WRITE)
+ has, err := HasAccess(u, repo, AccessModeWrite)
if err != nil {
log.Error(3, "HasAccess: %v", err)
}
@@ -393,7 +393,7 @@ func (u *User) IsWriterOfRepo(repo *Repository) bool {
// IsOrganization returns true if user is actually a organization.
func (u *User) IsOrganization() bool {
- return u.Type == USER_TYPE_ORGANIZATION
+ return u.Type == UserTypeOrganization
}
// IsUserOrgOwner returns true if user is in the owner team of given organization.
@@ -886,7 +886,7 @@ func GetUserByID(id int64) (*User, error) {
// GetAssigneeByID returns the user with write access of repository by given ID.
func GetAssigneeByID(repo *Repository, userID int64) (*User, error) {
- has, err := HasAccess(&User{ID: userID}, repo, ACCESS_MODE_WRITE)
+ has, err := HasAccess(&User{ID: userID}, repo, AccessModeWrite)
if err != nil {
return nil, err
} else if !has {
diff --git a/models/webhook.go b/models/webhook.go
index bb65dc0965..eb37338d2c 100644
--- a/models/webhook.go
+++ b/models/webhook.go
@@ -15,7 +15,7 @@ import (
"github.com/go-xorm/xorm"
gouuid "github.com/satori/go.uuid"
- api "github.com/gogits/go-gogs-client"
+ api "github.com/go-gitea/go-sdk/gitea"
"github.com/go-gitea/gitea/modules/httplib"
"github.com/go-gitea/gitea/modules/log"
@@ -28,13 +28,13 @@ var HookQueue = sync.NewUniqueQueue(setting.Webhook.QueueLength)
type HookContentType int
const (
- JSON HookContentType = iota + 1
- FORM
+ ContentTypeJSON HookContentType = iota + 1
+ ContentTypeForm
)
var hookContentTypes = map[string]HookContentType{
- "json": JSON,
- "form": FORM,
+ "json": ContentTypeJSON,
+ "form": ContentTypeForm,
}
// ToHookContentType returns HookContentType by given name.
@@ -44,9 +44,9 @@ func ToHookContentType(name string) HookContentType {
func (t HookContentType) Name() string {
switch t {
- case JSON:
+ case ContentTypeJSON:
return "json"
- case FORM:
+ case ContentTypeForm:
return "form"
}
return ""
@@ -76,9 +76,9 @@ type HookEvent struct {
type HookStatus int
const (
- HOOK_STATUS_NONE = iota
- HOOK_STATUS_SUCCEED
- HOOK_STATUS_FAILED
+ HookStatusNone = iota
+ HookStatusSucceed
+ HookStatusFail
)
// Webhook represents a web hook object.
@@ -323,9 +323,9 @@ func IsValidHookTaskType(name string) bool {
type HookEventType string
const (
- HOOK_EVENT_CREATE HookEventType = "create"
- HOOK_EVENT_PUSH HookEventType = "push"
- HOOK_EVENT_PULL_REQUEST HookEventType = "pull_request"
+ HookEventCreate HookEventType = "create"
+ HookEventPush HookEventType = "push"
+ HookEventPullRequest HookEventType = "pull_request"
)
// HookRequest represents hook task request information.
@@ -459,15 +459,15 @@ func PrepareWebhooks(repo *Repository, event HookEventType, p api.Payloader) err
var payloader api.Payloader
for _, w := range ws {
switch event {
- case HOOK_EVENT_CREATE:
+ case HookEventCreate:
if !w.HasCreateEvent() {
continue
}
- case HOOK_EVENT_PUSH:
+ case HookEventPush:
if !w.HasPushEvent() {
continue
}
- case HOOK_EVENT_PULL_REQUEST:
+ case HookEventPullRequest:
if !w.HasPullRequestEvent() {
continue
}
@@ -511,9 +511,9 @@ func (t *HookTask) deliver() {
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify})
switch t.ContentType {
- case JSON:
+ case ContentTypeJSON:
req = req.Header("Content-Type", "application/json").Body(t.PayloadContent)
- case FORM:
+ case ContentTypeForm:
req.Param("payload", t.PayloadContent)
}
@@ -544,9 +544,9 @@ func (t *HookTask) deliver() {
return
}
if t.IsSucceed {
- w.LastStatus = HOOK_STATUS_SUCCEED
+ w.LastStatus = HookStatusSucceed
} else {
- w.LastStatus = HOOK_STATUS_FAILED
+ w.LastStatus = HookStatusFail
}
if err = UpdateWebhook(w); err != nil {
log.Error(5, "UpdateWebhook: %v", err)
diff --git a/models/webhook_slack.go b/models/webhook_slack.go
index 2ee401ee19..51b3373e8c 100644
--- a/models/webhook_slack.go
+++ b/models/webhook_slack.go
@@ -11,7 +11,7 @@ import (
"strings"
"github.com/go-gitea/git"
- api "github.com/gogits/go-gogs-client"
+ api "github.com/go-gitea/go-sdk/gitea"
"github.com/go-gitea/gitea/modules/setting"
)
@@ -139,32 +139,32 @@ func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*S
fmt.Sprintf("#%d %s", p.Index, p.PullRequest.Title))
var text, title, attachmentText string
switch p.Action {
- case api.HOOK_ISSUE_OPENED:
+ case api.HookIssueOpened:
text = fmt.Sprintf("[%s] Pull request submitted by %s", p.Repository.FullName, senderLink)
title = titleLink
attachmentText = SlackTextFormatter(p.PullRequest.Body)
- case api.HOOK_ISSUE_CLOSED:
+ case api.HookIssueClosed:
if p.PullRequest.HasMerged {
text = fmt.Sprintf("[%s] Pull request merged: %s by %s", p.Repository.FullName, titleLink, senderLink)
} else {
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)
- case api.HOOK_ISSUE_EDITED:
+ case api.HookIssueEdited:
text = fmt.Sprintf("[%s] Pull request edited: %s by %s", p.Repository.FullName, titleLink, senderLink)
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,
SlackLinkFormatter(setting.AppUrl+p.PullRequest.Assignee.UserName, p.PullRequest.Assignee.UserName),
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)
- 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)
- 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)
- case api.HOOK_ISSUE_SYNCHRONIZED:
+ case api.HookIssueSynchronized:
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 {
- case HOOK_EVENT_CREATE:
+ case HookEventCreate:
return getSlackCreatePayload(p.(*api.CreatePayload), slack)
- case HOOK_EVENT_PUSH:
+ case HookEventPush:
return getSlackPushPayload(p.(*api.PushPayload), slack)
- case HOOK_EVENT_PULL_REQUEST:
+ case HookEventPullRequest:
return getSlackPullRequestPayload(p.(*api.PullRequestPayload), slack)
}