Yoginth 7 лет назад
Родитель
Сommit
b0a81794b0

+ 17 - 17
cmd/hook.go

@@ -72,7 +72,7 @@ func runHookPreReceive(c *cli.Context) error {
 	}
 	setup(c, "hooks/pre-receive.log", true)
 
-	isWiki := strings.Contains(os.Getenv(models.ENV_REPO_CUSTOM_HOOKS_PATH), ".wiki.git/")
+	isWiki := strings.Contains(os.Getenv(models.EnvRepoCustomHookPath), ".wiki.git/")
 
 	buf := bytes.NewBuffer(nil)
 	scanner := bufio.NewScanner(os.Stdin)
@@ -93,7 +93,7 @@ func runHookPreReceive(c *cli.Context) error {
 		branchName := strings.TrimPrefix(string(fields[2]), git.BRANCH_PREFIX)
 
 		// Branch protection
-		repoID := com.StrTo(os.Getenv(models.ENV_REPO_ID)).MustInt64()
+		repoID := com.StrTo(os.Getenv(models.EnvRepoID)).MustInt64()
 		protectBranch, err := models.GetProtectBranchOfRepoByName(repoID, branchName)
 		if err != nil {
 			if errors.IsErrBranchNotExist(err) {
@@ -109,7 +109,7 @@ func runHookPreReceive(c *cli.Context) error {
 		bypassRequirePullRequest := false
 
 		// Check if user is in whitelist when enabled
-		userID := com.StrTo(os.Getenv(models.ENV_AUTH_USER_ID)).MustInt64()
+		userID := com.StrTo(os.Getenv(models.EnvAuthUserID)).MustInt64()
 		if protectBranch.EnableWhitelist {
 			if !models.IsUserInProtectBranchWhitelist(repoID, userID, branchName) {
 				fail(fmt.Sprintf("Branch '%s' is protected and you are not in the push whitelist", branchName), "")
@@ -130,7 +130,7 @@ func runHookPreReceive(c *cli.Context) error {
 
 		// Check force push
 		output, err := git.NewCommand("rev-list", "--max-count=1", oldCommitID, "^"+newCommitID).
-			RunInDir(models.RepoPath(os.Getenv(models.ENV_REPO_OWNER_NAME), os.Getenv(models.ENV_REPO_NAME)))
+			RunInDir(models.RepoPath(os.Getenv(models.EnvRepoOwnerName), os.Getenv(models.EnvRepoName)))
 		if err != nil {
 			fail("Internal error", "Fail to detect force push: %v", err)
 		} else if len(output) > 0 {
@@ -138,7 +138,7 @@ func runHookPreReceive(c *cli.Context) error {
 		}
 	}
 
-	customHooksPath := filepath.Join(os.Getenv(models.ENV_REPO_CUSTOM_HOOKS_PATH), "pre-receive")
+	customHooksPath := filepath.Join(os.Getenv(models.EnvRepoCustomHookPath), "pre-receive")
 	if !com.IsFile(customHooksPath) {
 		return nil
 	}
@@ -149,7 +149,7 @@ func runHookPreReceive(c *cli.Context) error {
 	} else {
 		hookCmd = exec.Command(customHooksPath)
 	}
-	hookCmd.Dir = models.RepoPath(os.Getenv(models.ENV_REPO_OWNER_NAME), os.Getenv(models.ENV_REPO_NAME))
+	hookCmd.Dir = models.RepoPath(os.Getenv(models.EnvRepoOwnerName), os.Getenv(models.EnvRepoName))
 	hookCmd.Stdout = os.Stdout
 	hookCmd.Stdin = buf
 	hookCmd.Stderr = os.Stderr
@@ -172,7 +172,7 @@ func runHookUpdate(c *cli.Context) error {
 		fail("First argument 'refName' is empty", "First argument 'refName' is empty")
 	}
 
-	customHooksPath := filepath.Join(os.Getenv(models.ENV_REPO_CUSTOM_HOOKS_PATH), "update")
+	customHooksPath := filepath.Join(os.Getenv(models.EnvRepoCustomHookPath), "update")
 	if !com.IsFile(customHooksPath) {
 		return nil
 	}
@@ -183,7 +183,7 @@ func runHookUpdate(c *cli.Context) error {
 	} else {
 		hookCmd = exec.Command(customHooksPath, args...)
 	}
-	hookCmd.Dir = models.RepoPath(os.Getenv(models.ENV_REPO_OWNER_NAME), os.Getenv(models.ENV_REPO_NAME))
+	hookCmd.Dir = models.RepoPath(os.Getenv(models.EnvRepoOwnerName), os.Getenv(models.EnvRepoName))
 	hookCmd.Stdout = os.Stdout
 	hookCmd.Stdin = os.Stdin
 	hookCmd.Stderr = os.Stderr
@@ -206,7 +206,7 @@ func runHookPostReceive(c *cli.Context) error {
 	mailer.InitMailRender(path.Join(setting.StaticRootPath, "templates/mail"),
 		path.Join(setting.CustomPath, "templates/mail"), template.NewFuncMap())
 
-	isWiki := strings.Contains(os.Getenv(models.ENV_REPO_CUSTOM_HOOKS_PATH), ".wiki.git/")
+	isWiki := strings.Contains(os.Getenv(models.EnvRepoCustomHookPath), ".wiki.git/")
 
 	buf := bytes.NewBuffer(nil)
 	scanner := bufio.NewScanner(os.Stdin)
@@ -228,10 +228,10 @@ func runHookPostReceive(c *cli.Context) error {
 			OldCommitID:  string(fields[0]),
 			NewCommitID:  string(fields[1]),
 			RefFullName:  string(fields[2]),
-			PusherID:     com.StrTo(os.Getenv(models.ENV_AUTH_USER_ID)).MustInt64(),
-			PusherName:   os.Getenv(models.ENV_AUTH_USER_NAME),
-			RepoUserName: os.Getenv(models.ENV_REPO_OWNER_NAME),
-			RepoName:     os.Getenv(models.ENV_REPO_NAME),
+			PusherID:     com.StrTo(os.Getenv(models.EnvAuthUserID)).MustInt64(),
+			PusherName:   os.Getenv(models.EnvAuthUsername),
+			RepoUserName: os.Getenv(models.EnvRepoOwnerName),
+			RepoName:     os.Getenv(models.EnvRepoName),
 		}
 		if err := models.PushUpdate(options); err != nil {
 			raven.CaptureErrorAndWait(err, nil)
@@ -241,8 +241,8 @@ func runHookPostReceive(c *cli.Context) error {
 		// Ask for running deliver hook and test pull request tasks
 		reqURL := setting.LocalURL + options.RepoUserName + "/" + options.RepoName + "/tasks/trigger?branch=" +
 			template.EscapePound(strings.TrimPrefix(options.RefFullName, git.BRANCH_PREFIX)) +
-			"&secret=" + os.Getenv(models.ENV_REPO_OWNER_SALT_MD5) +
-			"&pusher=" + os.Getenv(models.ENV_AUTH_USER_ID)
+			"&secret=" + os.Getenv(models.EnvRepoOwnerSlatMD5) +
+			"&pusher=" + os.Getenv(models.EnvAuthUserID)
 		log.Trace("Trigger task: %s", reqURL)
 
 		resp, err := httplib.Head(reqURL).SetTLSClientConfig(&tls.Config{
@@ -259,7 +259,7 @@ func runHookPostReceive(c *cli.Context) error {
 		}
 	}
 
-	customHooksPath := filepath.Join(os.Getenv(models.ENV_REPO_CUSTOM_HOOKS_PATH), "post-receive")
+	customHooksPath := filepath.Join(os.Getenv(models.EnvRepoCustomHookPath), "post-receive")
 	if !com.IsFile(customHooksPath) {
 		return nil
 	}
@@ -270,7 +270,7 @@ func runHookPostReceive(c *cli.Context) error {
 	} else {
 		hookCmd = exec.Command(customHooksPath)
 	}
-	hookCmd.Dir = models.RepoPath(os.Getenv(models.ENV_REPO_OWNER_NAME), os.Getenv(models.ENV_REPO_NAME))
+	hookCmd.Dir = models.RepoPath(os.Getenv(models.EnvRepoOwnerName), os.Getenv(models.EnvRepoName))
 	hookCmd.Stdout = os.Stdout
 	hookCmd.Stdin = buf
 	hookCmd.Stderr = os.Stderr

+ 3 - 3
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

+ 25 - 25
models/comment.go

@@ -25,27 +25,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
-
-	// References.
-	COMMENT_TYPE_ISSUE_REF
-	// Reference from a commit (not part of a pull request)
-	COMMENT_TYPE_COMMIT_REF
-	// Reference from a comment
-	COMMENT_TYPE_COMMENT_REF
-	// Reference from a pull request
-	COMMENT_TYPE_PULL_REF
+	CommentTypeComment CommentType = iota
+	CommentTypeReopen
+	CommentTypeClose
+
+	// CommentTypeIssueRef References.
+	CommentTypeIssueRef
+	// CommentTypeCommitRef Reference from a commit (not part of a pull request)
+	CommentTypeCommitRef
+	// CommentTypeCommentRef Reference from a comment
+	CommentTypeCommentRef
+	// CommentTypePullRef Reference from a pull request
+	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.
@@ -217,7 +217,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
 
 	// Check comment type.
 	switch opts.Type {
-	case COMMENT_TYPE_COMMENT:
+	case CommentTypeComment:
 		act.OpType = ActionCommentIssue
 
 		if _, err = e.Exec("UPDATE `issue` SET num_comments=num_comments+1 WHERE id=?", opts.Issue.ID); err != nil {
@@ -246,7 +246,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
 			}
 		}
 
-	case COMMENT_TYPE_REOPEN:
+	case CommentTypeReopen:
 		act.OpType = ActionReopenIssue
 		if opts.Issue.IsPull {
 			act.OpType = ActionReopenPullRequest
@@ -261,7 +261,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
 			return nil, err
 		}
 
-	case COMMENT_TYPE_CLOSE:
+	case CommentTypeClose:
 		act.OpType = ActionCloseIssue
 		if opts.Issue.IsPull {
 			act.OpType = ActionClosePullRequest
@@ -297,9 +297,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,
@@ -341,7 +341,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) {
 	comment, err := CreateComment(&CreateCommentOptions{
-		Type:        COMMENT_TYPE_COMMENT,
+		Type:        CommentTypeComment,
 		Doer:        doer,
 		Repo:        repo,
 		Issue:       issue,
@@ -375,7 +375,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,
 	})
@@ -386,7 +386,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,
@@ -511,7 +511,7 @@ func DeleteCommentByID(doer *User, 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
 		}

+ 14 - 14
models/issue.go

@@ -1129,9 +1129,9 @@ func GetIssueUserPairsByMode(userID, repoID int64, filterMode FilterMode, isClos
 	}
 
 	switch filterMode {
-	case FILTER_MODE_ASSIGN:
+	case FilterModeAssign:
 		sess.And("is_assigned=?", true)
-	case FILTER_MODE_CREATE:
+	case FilterModeCreate:
 		sess.And("is_poster=?", true)
 	default:
 		return ius, nil
@@ -1195,10 +1195,10 @@ type IssueStats struct {
 type FilterMode string
 
 const (
-	FILTER_MODE_YOUR_REPOS FilterMode = "your_repositories"
-	FILTER_MODE_ASSIGN     FilterMode = "assigned"
-	FILTER_MODE_CREATE     FilterMode = "created_by"
-	FILTER_MODE_MENTION    FilterMode = "mentioned"
+	FilterModeYourRepos FilterMode = "your_repositories"
+	FilterModeAssign    FilterMode = "assigned"
+	FilterModeCreate    FilterMode = "created_by"
+	FilterModeMention   FilterMode = "mentioned"
 )
 
 func parseCountResult(results []map[string][]byte) int64 {
@@ -1252,7 +1252,7 @@ func GetIssueStats(opts *IssueStatsOptions) *IssueStats {
 	}
 
 	switch opts.FilterMode {
-	case FILTER_MODE_YOUR_REPOS, FILTER_MODE_ASSIGN:
+	case FilterModeYourRepos, FilterModeAssign:
 		stats.OpenCount, _ = countSession(opts).
 			And("is_closed = ?", false).
 			Count(new(Issue))
@@ -1260,7 +1260,7 @@ func GetIssueStats(opts *IssueStatsOptions) *IssueStats {
 		stats.ClosedCount, _ = countSession(opts).
 			And("is_closed = ?", true).
 			Count(new(Issue))
-	case FILTER_MODE_CREATE:
+	case FilterModeCreate:
 		stats.OpenCount, _ = countSession(opts).
 			And("poster_id = ?", opts.UserID).
 			And("is_closed = ?", false).
@@ -1270,7 +1270,7 @@ func GetIssueStats(opts *IssueStatsOptions) *IssueStats {
 			And("poster_id = ?", opts.UserID).
 			And("is_closed = ?", true).
 			Count(new(Issue))
-	case FILTER_MODE_MENTION:
+	case FilterModeMention:
 		stats.OpenCount, _ = countSession(opts).
 			Join("INNER", "issue_user", "issue.id = issue_user.issue_id").
 			And("issue_user.uid = ?", opts.UserID).
@@ -1318,7 +1318,7 @@ func GetUserIssueStats(repoID, userID int64, repoIDs []int64, filterMode FilterM
 	}
 
 	switch filterMode {
-	case FILTER_MODE_YOUR_REPOS:
+	case FilterModeYourRepos:
 		if !hasAnyRepo {
 			break
 		}
@@ -1327,14 +1327,14 @@ func GetUserIssueStats(repoID, userID int64, repoIDs []int64, filterMode FilterM
 			Count(new(Issue))
 		stats.ClosedCount, _ = countSession(true, isPull, repoID, repoIDs).
 			Count(new(Issue))
-	case FILTER_MODE_ASSIGN:
+	case FilterModeAssign:
 		stats.OpenCount, _ = countSession(false, isPull, repoID, nil).
 			And("assignee_id = ?", userID).
 			Count(new(Issue))
 		stats.ClosedCount, _ = countSession(true, isPull, repoID, nil).
 			And("assignee_id = ?", userID).
 			Count(new(Issue))
-	case FILTER_MODE_CREATE:
+	case FilterModeCreate:
 		stats.OpenCount, _ = countSession(false, isPull, repoID, nil).
 			And("poster_id = ?", userID).
 			Count(new(Issue))
@@ -1360,10 +1360,10 @@ func GetRepoIssueStats(repoID, userID int64, filterMode FilterMode, isPull bool)
 	closedCountSession := countSession(true, isPull, repoID)
 
 	switch filterMode {
-	case FILTER_MODE_ASSIGN:
+	case FilterModeAssign:
 		openCountSession.And("assignee_id = ?", userID)
 		closedCountSession.And("assignee_id = ?", userID)
-	case FILTER_MODE_CREATE:
+	case FilterModeCreate:
 		openCountSession.And("poster_id = ?", userID)
 		closedCountSession.And("poster_id = ?", userID)
 	}

+ 45 - 45
models/login_source.go

@@ -37,21 +37,21 @@ 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
-	LOGIN_GITHUB           // 6
+	LoginNotype LoginType = iota
+	LoginPlain            // 1
+	LoginLDAP             // 2
+	LoginSMTP             // 3
+	LoginPAM              // 4
+	LoginDLDAP            // 5
+	LoginGitHub           // 6
 )
 
 var LoginNames = map[LoginType]string{
-	LOGIN_LDAP:   "LDAP (via BindDN)",
-	LOGIN_DLDAP:  "LDAP (simple auth)", // Via direct bind
-	LOGIN_SMTP:   "SMTP",
-	LOGIN_PAM:    "PAM",
-	LOGIN_GITHUB: "GitHub",
+	LoginLDAP:   "LDAP (via BindDN)",
+	LoginDLDAP:  "LDAP (simple auth)", // Via direct bind
+	LoginSMTP:   "SMTP",
+	LoginPAM:    "PAM",
+	LoginGitHub: "GitHub",
 }
 
 var SecurityProtocolNames = map[ldap.SecurityProtocol]string{
@@ -187,13 +187,13 @@ func (s *LoginSource) BeforeSet(colName string, val xorm.Cell) {
 	switch colName {
 	case "type":
 		switch LoginType(Cell2Int64(val)) {
-		case LOGIN_LDAP, LOGIN_DLDAP:
+		case LoginLDAP, LoginDLDAP:
 			s.Cfg = new(LDAPConfig)
-		case LOGIN_SMTP:
+		case LoginSMTP:
 			s.Cfg = new(SMTPConfig)
-		case LOGIN_PAM:
+		case LoginPAM:
 			s.Cfg = new(PAMConfig)
-		case LOGIN_GITHUB:
+		case LoginGitHub:
 			s.Cfg = new(GitHubConfig)
 		default:
 			panic("unrecognized login source type: " + com.ToStr(*val))
@@ -215,23 +215,23 @@ func (s *LoginSource) TypeName() string {
 }
 
 func (s *LoginSource) IsLDAP() bool {
-	return s.Type == LOGIN_LDAP
+	return s.Type == LoginLDAP
 }
 
 func (s *LoginSource) IsDLDAP() bool {
-	return s.Type == LOGIN_DLDAP
+	return s.Type == LoginDLDAP
 }
 
 func (s *LoginSource) IsSMTP() bool {
-	return s.Type == LOGIN_SMTP
+	return s.Type == LoginSMTP
 }
 
 func (s *LoginSource) IsPAM() bool {
-	return s.Type == LOGIN_PAM
+	return s.Type == LoginPAM
 }
 
 func (s *LoginSource) IsGitHub() bool {
-	return s.Type == LOGIN_GITHUB
+	return s.Type == LoginGitHub
 }
 
 func (s *LoginSource) HasTLS() bool {
@@ -242,9 +242,9 @@ func (s *LoginSource) HasTLS() bool {
 
 func (s *LoginSource) UseTLS() bool {
 	switch s.Type {
-	case LOGIN_LDAP, LOGIN_DLDAP:
+	case LoginLDAP, LoginDLDAP:
 		return s.LDAP().SecurityProtocol != ldap.SECURITY_PROTOCOL_UNENCRYPTED
-	case LOGIN_SMTP:
+	case LoginSMTP:
 		return s.SMTP().TLS
 	}
 
@@ -253,9 +253,9 @@ func (s *LoginSource) UseTLS() bool {
 
 func (s *LoginSource) SkipVerify() bool {
 	switch s.Type {
-	case LOGIN_LDAP, LOGIN_DLDAP:
+	case LoginLDAP, LoginDLDAP:
 		return s.LDAP().SkipVerify
-	case LOGIN_SMTP:
+	case LoginSMTP:
 		return s.SMTP().SkipVerify
 	}
 
@@ -509,19 +509,19 @@ func LoadAuthSources() {
 		authType := s.Key("type").String()
 		switch authType {
 		case "ldap_bind_dn":
-			loginSource.Type = LOGIN_LDAP
+			loginSource.Type = LoginLDAP
 			loginSource.Cfg = &LDAPConfig{}
 		case "ldap_simple_auth":
-			loginSource.Type = LOGIN_DLDAP
+			loginSource.Type = LoginDLDAP
 			loginSource.Cfg = &LDAPConfig{}
 		case "smtp":
-			loginSource.Type = LOGIN_SMTP
+			loginSource.Type = LoginSMTP
 			loginSource.Cfg = &SMTPConfig{}
 		case "pam":
-			loginSource.Type = LOGIN_PAM
+			loginSource.Type = LoginPAM
 			loginSource.Cfg = &PAMConfig{}
 		case "github":
-			loginSource.Type = LOGIN_GITHUB
+			loginSource.Type = LoginGitHub
 			loginSource.Cfg = &GitHubConfig{}
 		default:
 			raven.CaptureErrorAndWait(err, nil)
@@ -553,7 +553,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, password string, source *LoginSource, autoRegister bool) (*User, error) {
-	username, fn, sn, mail, isAdmin, succeed := source.Cfg.(*LDAPConfig).SearchEntry(login, password, source.Type == LOGIN_DLDAP)
+	username, fn, sn, mail, isAdmin, succeed := source.Cfg.(*LDAPConfig).SearchEntry(login, password, source.Type == LoginDLDAP)
 	if !succeed {
 		// User not in LDAP, do nothing
 		return nil, errors.UserNotExist{0, login}
@@ -621,11 +621,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))
@@ -674,9 +674,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 authentication type")
@@ -708,7 +708,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,
@@ -735,7 +735,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,
@@ -762,7 +762,7 @@ func LoginViaGitHub(user *User, login, password string, sourceID int64, cfg *Git
 		Email:       email,
 		Website:     url,
 		Passwd:      password,
-		LoginType:   LOGIN_GITHUB,
+		LoginType:   LoginGitHub,
 		LoginSource: sourceID,
 		LoginName:   login,
 		IsActive:    true,
@@ -777,13 +777,13 @@ func remoteUserLogin(user *User, login, password string, source *LoginSource, au
 	}
 
 	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)
-	case LOGIN_GITHUB:
+	case LoginGitHub:
 		return LoginViaGitHub(user, login, password, source.ID, source.Cfg.(*GitHubConfig), autoRegister)
 	}
 
@@ -813,8 +813,8 @@ func UserLogin(username, password string, loginSourceID int64) (*User, error) {
 		}
 
 		// Validate password hash fetched from database for local accounts
-		if user.LoginType == LOGIN_NOTYPE ||
-			user.LoginType == LOGIN_PLAIN {
+		if user.LoginType == LoginNotype ||
+			user.LoginType == LoginPlain {
 			if user.ValidatePassword(password) {
 				return user, nil
 			}

+ 4 - 4
models/models.go

@@ -337,13 +337,13 @@ func ImportDatabase(dirPath string, verbose bool) (err error) {
 
 				tp := LoginType(com.StrTo(com.ToStr(meta["Type"])).MustInt64())
 				switch tp {
-				case LOGIN_LDAP, LOGIN_DLDAP:
+				case LoginLDAP, LoginDLDAP:
 					bean.Cfg = new(LDAPConfig)
-				case LOGIN_SMTP:
+				case LoginSMTP:
 					bean.Cfg = new(SMTPConfig)
-				case LOGIN_PAM:
+				case LoginPAM:
 					bean.Cfg = new(PAMConfig)
-				case LOGIN_GITHUB:
+				case LoginGitHub:
 					bean.Cfg = new(GitHubConfig)
 				default:
 					return fmt.Errorf("unrecognized login source type:: %v", tp)

+ 23 - 24
models/pull.go

@@ -30,16 +30,15 @@ var PullRequestQueue = sync.NewUniqueQueue(setting.Repository.PullRequestQueueLe
 type PullRequestType int
 
 const (
-	PULL_REQUEST_GITOTE PullRequestType = iota
-	PLLL_ERQUEST_GIT
+	PullRequestGitote PullRequestType = iota
 )
 
 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.
@@ -161,8 +160,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 {
@@ -176,20 +175,20 @@ func (pr *PullRequest) APIFormat() *api.PullRequest {
 
 // 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
 }
 
 // MergeStyle represents the approach to merge commits into base branch.
 type MergeStyle string
 
 const (
-	MERGE_STYLE_REGULAR MergeStyle = "create_merge_commit"
-	MERGE_STYLE_REBASE  MergeStyle = "rebase_before_merging"
+	MergeStyleRegular MergeStyle = "create_merge_commit"
+	MergeStyleRebase  MergeStyle = "rebase_before_merging"
 )
 
 // Merge merges pull request to base repository.
@@ -248,12 +247,12 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
 	remoteHeadBranch := "head_repo/" + pr.HeadBranch
 
 	// Check if merge style is allowed, reset to default style if not
-	if mergeStyle == MERGE_STYLE_REBASE && !pr.BaseRepo.PullsAllowRebase {
-		mergeStyle = MERGE_STYLE_REGULAR
+	if mergeStyle == MergeStyleRebase && !pr.BaseRepo.PullsAllowRebase {
+		mergeStyle = MergeStyleRegular
 	}
 
 	switch mergeStyle {
-	case MERGE_STYLE_REGULAR: // Create merge commit
+	case MergeStyleRegular: // Create merge commit
 
 		// Merge changes from head branch.
 		if _, stderr, err = process.ExecDir(-1, tmpBasePath,
@@ -272,7 +271,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
 			return fmt.Errorf("git commit [%s]: %v - %s", tmpBasePath, err, stderr)
 		}
 
-	case MERGE_STYLE_REBASE: // Rebase before merging
+	case MergeStyleRebase: // Rebase before merging
 
 		// Rebase head branch based on base branch, this creates a non-branch commit state.
 		if _, stderr, err = process.ExecDir(-1, tmpBasePath,
@@ -369,7 +368,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
 		log.Error(2, "GetBranchCommit: %v", err)
 		return nil
 	}
-	if mergeStyle == MERGE_STYLE_REGULAR {
+	if mergeStyle == MergeStyleRegular {
 		l.PushFront(mergeCommit)
 	}
 
@@ -434,13 +433,13 @@ func (pr *PullRequest) testPatch() (err error) {
 	}
 	args = append(args, patchPath)
 
-	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", args...)
 	if err != nil {
 		log.Trace("PullRequest[%d].testPatch (apply): has conflict\n%s", pr.ID, stderr)
-		pr.Status = PULL_REQUEST_STATUS_CONFLICT
+		pr.Status = PullRequestStatusConflict
 		return nil
 	}
 	return nil
@@ -474,8 +473,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
@@ -675,7 +674,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 {
 			raven.CaptureErrorAndWait(err, nil)
 			log.Error(3, "AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err)
@@ -807,8 +806,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.
@@ -825,7 +824,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)

+ 16 - 16
models/repo_editor.go

@@ -28,14 +28,14 @@ import (
 )
 
 const (
-	ENV_AUTH_USER_ID           = "GITOTE_AUTH_USER_ID"
-	ENV_AUTH_USER_NAME         = "GITOTE_AUTH_USER_NAME"
-	ENV_AUTH_USER_EMAIL        = "GITOTE_AUTH_USER_EMAIL"
-	ENV_REPO_OWNER_NAME        = "GITOTE_REPO_OWNER_NAME"
-	ENV_REPO_OWNER_SALT_MD5    = "GITOTE_REPO_OWNER_SALT_MD5"
-	ENV_REPO_ID                = "GITOTE_REPO_ID"
-	ENV_REPO_NAME              = "GITOTE_REPO_NAME"
-	ENV_REPO_CUSTOM_HOOKS_PATH = "GITOTE_REPO_CUSTOM_HOOKS_PATH"
+	EnvAuthUserID         = "GITOTE_AUTH_USER_ID"
+	EnvAuthUsername       = "GITOTE_AUTH_USER_NAME"
+	EnvAuthUserEmail      = "GITOTE_AUTH_USER_EMAIL"
+	EnvRepoOwnerName      = "GITOTE_REPO_OWNER_NAME"
+	EnvRepoOwnerSlatMD5   = "GITOTE_REPO_OWNER_SALT_MD5"
+	EnvRepoID             = "GITOTE_REPO_ID"
+	EnvRepoName           = "GITOTE_REPO_NAME"
+	EnvRepoCustomHookPath = "GITOTE_REPO_CUSTOM_HOOKS_PATH"
 )
 
 type ComposeHookEnvsOptions struct {
@@ -50,14 +50,14 @@ type ComposeHookEnvsOptions struct {
 func ComposeHookEnvs(opts ComposeHookEnvsOptions) []string {
 	envs := []string{
 		"SSH_ORIGINAL_COMMAND=1",
-		ENV_AUTH_USER_ID + "=" + com.ToStr(opts.AuthUser.ID),
-		ENV_AUTH_USER_NAME + "=" + opts.AuthUser.Name,
-		ENV_AUTH_USER_EMAIL + "=" + opts.AuthUser.Email,
-		ENV_REPO_OWNER_NAME + "=" + opts.OwnerName,
-		ENV_REPO_OWNER_SALT_MD5 + "=" + tool.MD5(opts.OwnerSalt),
-		ENV_REPO_ID + "=" + com.ToStr(opts.RepoID),
-		ENV_REPO_NAME + "=" + opts.RepoName,
-		ENV_REPO_CUSTOM_HOOKS_PATH + "=" + path.Join(opts.RepoPath, "custom_hooks"),
+		EnvAuthUserID + "=" + com.ToStr(opts.AuthUser.ID),
+		EnvAuthUsername + "=" + opts.AuthUser.Name,
+		EnvAuthUserEmail + "=" + opts.AuthUser.Email,
+		EnvRepoOwnerName + "=" + opts.OwnerName,
+		EnvRepoOwnerSlatMD5 + "=" + tool.MD5(opts.OwnerSalt),
+		EnvRepoID + "=" + com.ToStr(opts.RepoID),
+		EnvRepoName + "=" + opts.RepoName,
+		EnvRepoCustomHookPath + "=" + path.Join(opts.RepoPath, "custom_hooks"),
 	}
 	return envs
 }

+ 2 - 2
models/user.go

@@ -185,9 +185,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.

+ 15 - 15
routes/admin/auths.go

@@ -56,11 +56,11 @@ type dropdownItem struct {
 
 var (
 	authSources = []dropdownItem{
-		{models.LoginNames[models.LOGIN_LDAP], models.LOGIN_LDAP},
-		{models.LoginNames[models.LOGIN_DLDAP], models.LOGIN_DLDAP},
-		{models.LoginNames[models.LOGIN_SMTP], models.LOGIN_SMTP},
-		{models.LoginNames[models.LOGIN_PAM], models.LOGIN_PAM},
-		{models.LoginNames[models.LOGIN_GITHUB], models.LOGIN_GITHUB},
+		{models.LoginNames[models.LoginLDAP], models.LoginLDAP},
+		{models.LoginNames[models.LoginDLDAP], models.LoginDLDAP},
+		{models.LoginNames[models.LoginSMTP], models.LoginSMTP},
+		{models.LoginNames[models.LoginPAM], models.LoginPAM},
+		{models.LoginNames[models.LoginGitHub], models.LoginGitHub},
 	}
 	securityProtocols = []dropdownItem{
 		{models.SecurityProtocolNames[ldap.SECURITY_PROTOCOL_UNENCRYPTED], ldap.SECURITY_PROTOCOL_UNENCRYPTED},
@@ -75,8 +75,8 @@ func NewAuthSource(c *context.Context) {
 	c.PageIs("Admin")
 	c.PageIs("AdminAuthentications")
 
-	c.Data["type"] = models.LOGIN_LDAP
-	c.Data["CurrentTypeName"] = models.LoginNames[models.LOGIN_LDAP]
+	c.Data["type"] = models.LoginLDAP
+	c.Data["CurrentTypeName"] = models.LoginNames[models.LoginLDAP]
 	c.Data["CurrentSecurityProtocol"] = models.SecurityProtocolNames[ldap.SECURITY_PROTOCOL_UNENCRYPTED]
 	c.Data["smtp_auth"] = "PLAIN"
 	c.Data["is_active"] = true
@@ -140,17 +140,17 @@ func NewAuthSourcePost(c *context.Context, f form.Authentication) {
 	hasTLS := false
 	var config core.Conversion
 	switch models.LoginType(f.Type) {
-	case models.LOGIN_LDAP, models.LOGIN_DLDAP:
+	case models.LoginLDAP, models.LoginDLDAP:
 		config = parseLDAPConfig(f)
 		hasTLS = ldap.SecurityProtocol(f.SecurityProtocol) > ldap.SECURITY_PROTOCOL_UNENCRYPTED
-	case models.LOGIN_SMTP:
+	case models.LoginSMTP:
 		config = parseSMTPConfig(f)
 		hasTLS = true
-	case models.LOGIN_PAM:
+	case models.LoginPAM:
 		config = &models.PAMConfig{
 			ServiceName: f.PAMServiceName,
 		}
-	case models.LOGIN_GITHUB:
+	case models.LoginGitHub:
 		config = &models.GitHubConfig{
 			APIEndpoint: strings.TrimSuffix(f.GitHubAPIEndpoint, "/") + "/",
 		}
@@ -230,15 +230,15 @@ func EditAuthSourcePost(c *context.Context, f form.Authentication) {
 
 	var config core.Conversion
 	switch models.LoginType(f.Type) {
-	case models.LOGIN_LDAP, models.LOGIN_DLDAP:
+	case models.LoginLDAP, models.LoginDLDAP:
 		config = parseLDAPConfig(f)
-	case models.LOGIN_SMTP:
+	case models.LoginSMTP:
 		config = parseSMTPConfig(f)
-	case models.LOGIN_PAM:
+	case models.LoginPAM:
 		config = &models.PAMConfig{
 			ServiceName: f.PAMServiceName,
 		}
-	case models.LOGIN_GITHUB:
+	case models.LoginGitHub:
 		config = &models.GitHubConfig{
 			APIEndpoint: strings.TrimSuffix(f.GitHubAPIEndpoint, "/") + "/",
 		}

+ 1 - 1
routes/admin/users.go

@@ -92,7 +92,7 @@ func NewUserPost(c *context.Context, f form.AdminCrateUser) {
 		ThemeColor: "#161616",
 		IsActive:   true,
 		ShowAds:    true,
-		LoginType:  models.LOGIN_PLAIN,
+		LoginType:  models.LoginPlain,
 	}
 
 	if len(f.LoginType) > 0 {

+ 1 - 1
routes/api/v1/admin/user.go

@@ -45,7 +45,7 @@ func CreateUser(c *context.APIContext, form api.CreateUserOption) {
 		Email:     form.Email,
 		Passwd:    form.Password,
 		IsActive:  true,
-		LoginType: models.LOGIN_PLAIN,
+		LoginType: models.LoginPlain,
 	}
 
 	parseLoginSource(c, u, form.SourceID, form.LoginName)

+ 2 - 2
routes/api/v1/repo/issue_comment.go

@@ -99,7 +99,7 @@ func EditIssueComment(c *context.APIContext, form api.EditIssueCommentOption) {
 	if c.User.ID != comment.PosterID && !c.Repo.IsAdmin() {
 		c.Status(403)
 		return
-	} else if comment.Type != models.COMMENT_TYPE_COMMENT {
+	} else if comment.Type != models.CommentTypeComment {
 		c.Status(204)
 		return
 	}
@@ -127,7 +127,7 @@ func DeleteIssueComment(c *context.APIContext) {
 	if c.User.ID != comment.PosterID && !c.Repo.IsAdmin() {
 		c.Status(403)
 		return
-	} else if comment.Type != models.COMMENT_TYPE_COMMENT {
+	} else if comment.Type != models.CommentTypeComment {
 		c.Status(204)
 		return
 	}

+ 11 - 11
routes/repo/issue.go

@@ -141,16 +141,16 @@ func issues(c *context.Context, isPullList bool) {
 		assigneeID = c.QueryInt64("assignee")
 		posterID   int64
 	)
-	filterMode := models.FILTER_MODE_YOUR_REPOS
+	filterMode := models.FilterModeYourRepos
 	switch viewType {
 	case "assigned":
-		filterMode = models.FILTER_MODE_ASSIGN
+		filterMode = models.FilterModeAssign
 		assigneeID = c.User.ID
 	case "created_by":
-		filterMode = models.FILTER_MODE_CREATE
+		filterMode = models.FilterModeCreate
 		posterID = c.User.ID
 	case "mentioned":
-		filterMode = models.FILTER_MODE_MENTION
+		filterMode = models.FilterModeMention
 	}
 
 	var uid int64 = -1
@@ -195,7 +195,7 @@ func issues(c *context.Context, isPullList bool) {
 		MilestoneID: milestoneID,
 		Page:        pager.Current(),
 		IsClosed:    isShowClosed,
-		IsMention:   filterMode == models.FILTER_MODE_MENTION,
+		IsMention:   filterMode == models.FilterModeMention,
 		IsPull:      isPullList,
 		Labels:      selectLabels,
 		SortType:    sortType,
@@ -627,7 +627,7 @@ func viewIssue(c *context.Context, isPullList bool) {
 	// Render comments and and fetch participants.
 	participants[0] = issue.Poster
 	for _, comment = range issue.Comments {
-		if comment.Type == models.COMMENT_TYPE_COMMENT {
+		if comment.Type == models.CommentTypeComment {
 			comment.RenderedContent = string(markup.Markdown(comment.Content, c.Repo.RepoLink, c.Repo.Repository.ComposeMetas()))
 
 			// Check tag.
@@ -639,11 +639,11 @@ func viewIssue(c *context.Context, isPullList bool) {
 
 			if repo.IsOwnedBy(comment.PosterID) ||
 				(repo.Owner.IsOrganization() && repo.Owner.IsOwnedBy(comment.PosterID)) {
-				comment.ShowTag = models.COMMENT_TAG_OWNER
+				comment.ShowTag = models.CommentTagOwner
 			} else if comment.Poster.IsWriterOfRepo(repo) {
-				comment.ShowTag = models.COMMENT_TAG_WRITER
+				comment.ShowTag = models.CommentTagWriter
 			} else if comment.PosterID == issue.PosterID {
-				comment.ShowTag = models.COMMENT_TAG_POSTER
+				comment.ShowTag = models.CommentTagPoster
 			}
 
 			marked[comment.PosterID] = comment.ShowTag
@@ -953,7 +953,7 @@ func UpdateCommentContent(c *context.Context) {
 	if c.UserID() != comment.PosterID && !c.Repo.IsAdmin() {
 		c.Error(404)
 		return
-	} else if comment.Type != models.COMMENT_TYPE_COMMENT {
+	} else if comment.Type != models.CommentTypeComment {
 		c.Error(204)
 		return
 	}
@@ -986,7 +986,7 @@ func DeleteComment(c *context.Context) {
 	if c.UserID() != comment.PosterID && !c.Repo.IsAdmin() {
 		c.Error(404)
 		return
-	} else if comment.Type != models.COMMENT_TYPE_COMMENT {
+	} else if comment.Type != models.CommentTypeComment {
 		c.Error(204)
 		return
 	}

+ 1 - 1
routes/repo/pull.go

@@ -716,7 +716,7 @@ func CompareAndPullRequestPost(c *context.Context, f form.NewIssue) {
 		HeadRepo:     headRepo,
 		BaseRepo:     repo,
 		MergeBase:    prInfo.MergeBase,
-		Type:         models.PULL_REQUEST_GITOTE,
+		Type:         models.PullRequestGitote,
 	}
 	// FIXME: check error in the case two people send pull request at almost same time, give nice error prompt
 	// instead of 500.

+ 9 - 9
routes/user/home.go

@@ -194,19 +194,19 @@ func Issues(c *context.Context) {
 
 	var (
 		sortType   = c.Query("sort")
-		filterMode = models.FILTER_MODE_YOUR_REPOS
+		filterMode = models.FilterModeYourRepos
 	)
 
 	// Note: Organization does not have view type and filter mode.
 	if !ctxUser.IsOrganization() {
 		viewType := c.Query("type")
 		types := []string{
-			string(models.FILTER_MODE_YOUR_REPOS),
-			string(models.FILTER_MODE_ASSIGN),
-			string(models.FILTER_MODE_CREATE),
+			string(models.FilterModeYourRepos),
+			string(models.FilterModeAssign),
+			string(models.FilterModeCreate),
 		}
 		if !com.IsSliceContainsStr(types, viewType) {
-			viewType = string(models.FILTER_MODE_YOUR_REPOS)
+			viewType = string(models.FilterModeYourRepos)
 		}
 		filterMode = models.FilterMode(viewType)
 	}
@@ -244,7 +244,7 @@ func Issues(c *context.Context) {
 	for _, repo := range repos {
 		userRepoIDs = append(userRepoIDs, repo.ID)
 
-		if filterMode != models.FILTER_MODE_YOUR_REPOS {
+		if filterMode != models.FilterModeYourRepos {
 			continue
 		}
 
@@ -281,7 +281,7 @@ func Issues(c *context.Context) {
 		SortType: sortType,
 	}
 	switch filterMode {
-	case models.FILTER_MODE_YOUR_REPOS:
+	case models.FilterModeYourRepos:
 		// Get all issues from repositories from this user.
 		if userRepoIDs == nil {
 			issueOptions.RepoIDs = []int64{-1}
@@ -289,11 +289,11 @@ func Issues(c *context.Context) {
 			issueOptions.RepoIDs = userRepoIDs
 		}
 
-	case models.FILTER_MODE_ASSIGN:
+	case models.FilterModeAssign:
 		// Get all issues assigned to this user.
 		issueOptions.AssigneeID = ctxUser.ID
 
-	case models.FILTER_MODE_CREATE:
+	case models.FilterModeCreate:
 		// Get all issues created by this user.
 		issueOptions.PosterID = ctxUser.ID
 	}