Bläddra i källkod

Fixing Go Report Card Issues #100

Yoginth 7 år sedan
förälder
incheckning
6382397013

+ 2 - 1
models/action.go

@@ -246,6 +246,7 @@ type PushCommits struct {
 	avatars map[string]string
 }
 
+// NewPushCommits returns new push commits
 func NewPushCommits() *PushCommits {
 	return &PushCommits{
 		avatars: make(map[string]string),
@@ -732,7 +733,7 @@ func MirrorSyncCreateAction(repo *Repository, refName string) error {
 	return mirrorSyncAction(ActionMirrorSyncCreate, repo, refName, nil)
 }
 
-// MirrorSyncCreateAction adds new action for mirror synchronization of delete reference.
+// MirrorSyncDeleteAction deletes action for mirror synchronization of delete reference.
 func MirrorSyncDeleteAction(repo *Repository, refName string) error {
 	return mirrorSyncAction(ActionMirrorSyncDelete, repo, refName, nil)
 }

+ 1 - 0
models/comment.go

@@ -150,6 +150,7 @@ func (c *Comment) APIFormat() *api.Comment {
 	}
 }
 
+// CommentHashTag returns issue comment with hash
 func CommentHashTag(id int64) string {
 	return "issuecomment-" + com.ToStr(id)
 }

+ 35 - 0
models/error.go

@@ -14,6 +14,7 @@ type ErrNameReserved struct {
 	Name string
 }
 
+// IsErrNameReserved checks if an error is a ErrNameReserved.
 func IsErrNameReserved(err error) bool {
 	_, ok := err.(ErrNameReserved)
 	return ok
@@ -27,6 +28,8 @@ type ErrNamePatternNotAllowed struct {
 	Pattern string
 }
 
+// IsErrNamePatternNotAllowed checks if an error is an
+// ErrNamePatternNotAllowed.
 func IsErrNamePatternNotAllowed(err error) bool {
 	_, ok := err.(ErrNamePatternNotAllowed)
 	return ok
@@ -40,6 +43,7 @@ type ErrUserAlreadyExist struct {
 	Name string
 }
 
+// IsErrUserAlreadyExist checks if an error is a ErrUserAlreadyExists.
 func IsErrUserAlreadyExist(err error) bool {
 	_, ok := err.(ErrUserAlreadyExist)
 	return ok
@@ -53,6 +57,7 @@ type ErrEmailAlreadyUsed struct {
 	Email string
 }
 
+// IsErrEmailAlreadyUsed checks if an error is a ErrEmailAlreadyUsed.
 func IsErrEmailAlreadyUsed(err error) bool {
 	_, ok := err.(ErrEmailAlreadyUsed)
 	return ok
@@ -66,6 +71,7 @@ type ErrUserOwnRepos struct {
 	UID int64
 }
 
+// IsErrUserOwnRepos checks if an error is a ErrUserOwnRepos.
 func IsErrUserOwnRepos(err error) bool {
 	_, ok := err.(ErrUserOwnRepos)
 	return ok
@@ -79,6 +85,7 @@ type ErrUserHasOrgs struct {
 	UID int64
 }
 
+// IsErrUserHasOrgs checks if an error is a ErrUserHasOrgs.
 func IsErrUserHasOrgs(err error) bool {
 	_, ok := err.(ErrUserHasOrgs)
 	return ok
@@ -92,6 +99,7 @@ type ErrWikiAlreadyExist struct {
 	Title string
 }
 
+// IsErrWikiAlreadyExist checks if an error is an ErrWikiAlreadyExist.
 func IsErrWikiAlreadyExist(err error) bool {
 	_, ok := err.(ErrWikiAlreadyExist)
 	return ok
@@ -105,6 +113,7 @@ type ErrKeyUnableVerify struct {
 	Result string
 }
 
+// IsErrKeyUnableVerify checks if an error is a ErrKeyUnableVerify.
 func IsErrKeyUnableVerify(err error) bool {
 	_, ok := err.(ErrKeyUnableVerify)
 	return ok
@@ -118,6 +127,7 @@ type ErrKeyNotExist struct {
 	ID int64
 }
 
+// IsErrKeyNotExist checks if an error is a ErrKeyNotExist.
 func IsErrKeyNotExist(err error) bool {
 	_, ok := err.(ErrKeyNotExist)
 	return ok
@@ -132,6 +142,7 @@ type ErrKeyAlreadyExist struct {
 	Content string
 }
 
+// IsErrKeyAlreadyExist checks if an error is a ErrKeyAlreadyExist.
 func IsErrKeyAlreadyExist(err error) bool {
 	_, ok := err.(ErrKeyAlreadyExist)
 	return ok
@@ -146,6 +157,7 @@ type ErrKeyNameAlreadyUsed struct {
 	Name    string
 }
 
+// IsErrKeyNameAlreadyUsed checks if an error is a ErrKeyNameAlreadyUsed.
 func IsErrKeyNameAlreadyUsed(err error) bool {
 	_, ok := err.(ErrKeyNameAlreadyUsed)
 	return ok
@@ -161,6 +173,7 @@ type ErrKeyAccessDenied struct {
 	Note   string
 }
 
+// IsErrKeyAccessDenied checks if an error is a ErrKeyAccessDenied.
 func IsErrKeyAccessDenied(err error) bool {
 	_, ok := err.(ErrKeyAccessDenied)
 	return ok
@@ -177,6 +190,7 @@ type ErrDeployKeyNotExist struct {
 	RepoID int64
 }
 
+// IsErrDeployKeyNotExist checks if an error is a ErrDeployKeyNotExist.
 func IsErrDeployKeyNotExist(err error) bool {
 	_, ok := err.(ErrDeployKeyNotExist)
 	return ok
@@ -191,6 +205,7 @@ type ErrDeployKeyAlreadyExist struct {
 	RepoID int64
 }
 
+// IsErrDeployKeyAlreadyExist checks if an error is a ErrDeployKeyAlreadyExist.
 func IsErrDeployKeyAlreadyExist(err error) bool {
 	_, ok := err.(ErrDeployKeyAlreadyExist)
 	return ok
@@ -205,6 +220,7 @@ type ErrDeployKeyNameAlreadyUsed struct {
 	Name   string
 }
 
+// IsErrDeployKeyNameAlreadyUsed checks if an error is a ErrDeployKeyNameAlreadyUsed.
 func IsErrDeployKeyNameAlreadyUsed(err error) bool {
 	_, ok := err.(ErrDeployKeyNameAlreadyUsed)
 	return ok
@@ -218,6 +234,7 @@ type ErrAccessTokenNotExist struct {
 	SHA string
 }
 
+// IsErrAccessTokenNotExist checks if an error is a ErrAccessTokenNotExist.
 func IsErrAccessTokenNotExist(err error) bool {
 	_, ok := err.(ErrAccessTokenNotExist)
 	return ok
@@ -230,6 +247,7 @@ func (err ErrAccessTokenNotExist) Error() string {
 type ErrAccessTokenEmpty struct {
 }
 
+// IsErrAccessTokenEmpty checks if an error is a ErrAccessTokenEmpty.
 func IsErrAccessTokenEmpty(err error) bool {
 	_, ok := err.(ErrAccessTokenEmpty)
 	return ok
@@ -243,6 +261,7 @@ type ErrLastOrgOwner struct {
 	UID int64
 }
 
+// IsErrLastOrgOwner checks if an error is a ErrLastOrgOwner.
 func IsErrLastOrgOwner(err error) bool {
 	_, ok := err.(ErrLastOrgOwner)
 	return ok
@@ -257,6 +276,7 @@ type ErrRepoAlreadyExist struct {
 	Name  string
 }
 
+// IsErrRepoAlreadyExist checks if an error is a ErrRepoAlreadyExist.
 func IsErrRepoAlreadyExist(err error) bool {
 	_, ok := err.(ErrRepoAlreadyExist)
 	return ok
@@ -272,6 +292,7 @@ type ErrInvalidCloneAddr struct {
 	IsPermissionDenied bool
 }
 
+// IsErrInvalidCloneAddr checks if an error is a ErrInvalidCloneAddr.
 func IsErrInvalidCloneAddr(err error) bool {
 	_, ok := err.(ErrInvalidCloneAddr)
 	return ok
@@ -286,6 +307,7 @@ type ErrUpdateTaskNotExist struct {
 	UUID string
 }
 
+// IsErrUpdateTaskNotExist checks if an error is a ErrUpdateTaskNotExist.
 func IsErrUpdateTaskNotExist(err error) bool {
 	_, ok := err.(ErrUpdateTaskNotExist)
 	return ok
@@ -299,6 +321,7 @@ type ErrReleaseAlreadyExist struct {
 	TagName string
 }
 
+// IsErrReleaseAlreadyExist checks if an error is a ErrReleaseAlreadyExist.
 func IsErrReleaseAlreadyExist(err error) bool {
 	_, ok := err.(ErrReleaseAlreadyExist)
 	return ok
@@ -313,6 +336,7 @@ type ErrReleaseNotExist struct {
 	TagName string
 }
 
+// IsErrReleaseNotExist checks if an error is a ErrReleaseNotExist.
 func IsErrReleaseNotExist(err error) bool {
 	_, ok := err.(ErrReleaseNotExist)
 	return ok
@@ -326,6 +350,7 @@ type ErrInvalidTagName struct {
 	TagName string
 }
 
+// IsErrInvalidTagName checks if an error is a ErrInvalidTagName.
 func IsErrInvalidTagName(err error) bool {
 	_, ok := err.(ErrInvalidTagName)
 	return ok
@@ -339,6 +364,7 @@ type ErrRepoFileAlreadyExist struct {
 	FileName string
 }
 
+// IsErrRepoFileAlreadyExist checks if an error is a ErrRepoFileAlreadyExist.
 func IsErrRepoFileAlreadyExist(err error) bool {
 	_, ok := err.(ErrRepoFileAlreadyExist)
 	return ok
@@ -357,6 +383,7 @@ type ErrPullRequestNotExist struct {
 	BaseBranch string
 }
 
+// IsErrPullRequestNotExist checks if an error is a ErrPullRequestNotExist.
 func IsErrPullRequestNotExist(err error) bool {
 	_, ok := err.(ErrPullRequestNotExist)
 	return ok
@@ -372,6 +399,7 @@ type ErrCommentNotExist struct {
 	IssueID int64
 }
 
+// IsErrCommentNotExist checks if an error is a ErrCommentNotExist.
 func IsErrCommentNotExist(err error) bool {
 	_, ok := err.(ErrCommentNotExist)
 	return ok
@@ -386,6 +414,7 @@ type ErrLabelNotExist struct {
 	RepoID  int64
 }
 
+// IsErrLabelNotExist checks if an error is a ErrLabelNotExist.
 func IsErrLabelNotExist(err error) bool {
 	_, ok := err.(ErrLabelNotExist)
 	return ok
@@ -400,6 +429,7 @@ type ErrMilestoneNotExist struct {
 	RepoID int64
 }
 
+// IsErrMilestoneNotExist checks if an error is a ErrMilestoneNotExist.
 func IsErrMilestoneNotExist(err error) bool {
 	_, ok := err.(ErrMilestoneNotExist)
 	return ok
@@ -414,6 +444,7 @@ type ErrAttachmentNotExist struct {
 	UUID string
 }
 
+// IsErrAttachmentNotExist checks if an error is a ErrAttachmentNotExist.
 func IsErrAttachmentNotExist(err error) bool {
 	_, ok := err.(ErrAttachmentNotExist)
 	return ok
@@ -427,6 +458,7 @@ type ErrLoginSourceAlreadyExist struct {
 	Name string
 }
 
+// IsErrLoginSourceAlreadyExist checks if an error is a ErrLoginSourceAlreadyExist.
 func IsErrLoginSourceAlreadyExist(err error) bool {
 	_, ok := err.(ErrLoginSourceAlreadyExist)
 	return ok
@@ -440,6 +472,7 @@ type ErrLoginSourceInUse struct {
 	ID int64
 }
 
+// IsErrLoginSourceInUse checks if an error is a ErrLoginSourceInUse.
 func IsErrLoginSourceInUse(err error) bool {
 	_, ok := err.(ErrLoginSourceInUse)
 	return ok
@@ -454,6 +487,7 @@ type ErrTeamAlreadyExist struct {
 	Name  string
 }
 
+// IsErrTeamAlreadyExist checks if an error is a ErrTeamAlreadyExist.
 func IsErrTeamAlreadyExist(err error) bool {
 	_, ok := err.(ErrTeamAlreadyExist)
 	return ok
@@ -468,6 +502,7 @@ type ErrUploadNotExist struct {
 	UUID string
 }
 
+// IsErrUploadNotExist checks if an error is a ErrUploadNotExist.
 func IsErrUploadNotExist(err error) bool {
 	_, ok := err.(ErrAttachmentNotExist)
 	return ok

+ 4 - 0
models/git_diff.go

@@ -118,6 +118,7 @@ type Diff struct {
 	Files []*DiffFile
 }
 
+// NewDiff creates new diff
 func NewDiff(gitDiff *git.Diff) *Diff {
 	diff := &Diff{
 		Diff:  gitDiff,
@@ -164,6 +165,7 @@ func NewDiff(gitDiff *git.Diff) *Diff {
 	return diff
 }
 
+// ParsePatch builds a Diff object from a io.Reader and some
 func ParsePatch(maxLines, maxLineCharacteres, maxFiles int, reader io.Reader) (*Diff, error) {
 	done := make(chan error)
 	var gitDiff *git.Diff
@@ -177,6 +179,7 @@ func ParsePatch(maxLines, maxLineCharacteres, maxFiles int, reader io.Reader) (*
 	return NewDiff(gitDiff), nil
 }
 
+// GetDiffRange builds a Diff between two commits of a repository.
 func GetDiffRange(repoPath, beforeCommitID, afterCommitID string, maxLines, maxLineCharacteres, maxFiles int) (*Diff, error) {
 	gitDiff, err := git.GetDiffRange(repoPath, beforeCommitID, afterCommitID, maxLines, maxLineCharacteres, maxFiles)
 	if err != nil {
@@ -185,6 +188,7 @@ func GetDiffRange(repoPath, beforeCommitID, afterCommitID string, maxLines, maxL
 	return NewDiff(gitDiff), nil
 }
 
+// GetDiffCommit builds a Diff representing the given commitID.
 func GetDiffCommit(repoPath, commitID string, maxLines, maxLineCharacteres, maxFiles int) (*Diff, error) {
 	gitDiff, err := git.GetDiffCommit(repoPath, commitID, maxLines, maxLineCharacteres, maxFiles)
 	if err != nil {

+ 1 - 1
models/issue.go

@@ -835,7 +835,7 @@ func GetIssueByRef(ref string) (*Issue, error) {
 	return issue, issue.LoadAttributes()
 }
 
-// GetIssueByIndex returns raw issue without loading attributes by index in a repository.
+// GetRawIssueByIndex returns raw issue without loading attributes by index in a repository.
 func GetRawIssueByIndex(repoID, index int64) (*Issue, error) {
 	issue := &Issue{
 		RepoID: repoID,

+ 3 - 0
models/issue_mail.go

@@ -46,6 +46,7 @@ func (this mailerUser) GenerateEmailActivateCode(email string) string {
 	return this.user.GenerateEmailActivateCode(email)
 }
 
+// NewMailerUser returns mailerUser
 func NewMailerUser(u *User) mailer.User {
 	return mailerUser{u}
 }
@@ -67,6 +68,7 @@ func (this mailerRepo) ComposeMetas() map[string]string {
 	return this.repo.ComposeMetas()
 }
 
+// NewMailerRepo returns mailerRepo
 func NewMailerRepo(repo *Repository) mailer.Repository {
 	return mailerRepo{repo}
 }
@@ -88,6 +90,7 @@ func (this mailerIssue) HTMLURL() string {
 	return this.issue.HTMLURL()
 }
 
+// NewMailerIssue returns mailerIssue
 func NewMailerIssue(issue *Issue) mailer.Issue {
 	return mailerIssue{issue}
 }

+ 4 - 0
models/login_source.go

@@ -278,6 +278,7 @@ func (s *LoginSource) GitHub() *GitHubConfig {
 	return s.Cfg.(*GitHubConfig)
 }
 
+// CreateLoginSource inserts a LoginSource in the DB if not already existing with the given name.
 func CreateLoginSource(source *LoginSource) error {
 	has, err := x.Get(&LoginSource{Name: source.Name})
 	if err != nil {
@@ -370,6 +371,7 @@ func UpdateLoginSource(source *LoginSource) error {
 	return ResetNonDefaultLoginSources(source)
 }
 
+// DeleteSource deletes a LoginSource record in DB.
 func DeleteSource(source *LoginSource) error {
 	count, err := x.Count(&User{LoginSource: source.ID})
 	if err != nil {
@@ -627,6 +629,7 @@ const (
 
 var SMTPAuths = []string{SMTPPlain, SMTPLogin}
 
+// SMTPAuth contains available SMTP authentication type names.
 func SMTPAuth(a smtp.Auth, cfg *SMTPConfig) error {
 	c, err := smtp.Dial(fmt.Sprintf("%s:%d", cfg.Host, cfg.Port))
 	if err != nil {
@@ -743,6 +746,7 @@ func LoginViaPAM(user *User, login, password string, sourceID int64, cfg *PAMCon
 	return user, CreateUser(user)
 }
 
+// LoginViaGitHub contains available GitHub authentication type names.
 func LoginViaGitHub(user *User, login, password string, sourceID int64, cfg *GitHubConfig, autoRegister bool) (*User, error) {
 	fullname, email, url, location, err := github.Authenticate(cfg.APIEndpoint, login, password)
 	if err != nil {

+ 1 - 1
models/milestone.go

@@ -145,7 +145,7 @@ func getMilestoneByRepoID(e Engine, repoID, id int64) (*Milestone, error) {
 	return m, nil
 }
 
-// GetWebhookByRepoID returns the milestone in a repository.
+// GetMilestoneByRepoID returns the milestone in a repository.
 func GetMilestoneByRepoID(repoID, id int64) (*Milestone, error) {
 	return getMilestoneByRepoID(x, repoID, id)
 }

+ 3 - 0
models/mirror.go

@@ -333,10 +333,12 @@ func updateMirror(e Engine, m *Mirror) error {
 	return err
 }
 
+// UpdateMirror returns updateMirror
 func UpdateMirror(m *Mirror) error {
 	return updateMirror(x, m)
 }
 
+// DeleteMirrorByRepoID delted repo by ID
 func DeleteMirrorByRepoID(repoID int64) error {
 	_, err := x.Delete(&Mirror{RepoID: repoID})
 	return err
@@ -517,6 +519,7 @@ func SyncMirrors() {
 	}
 }
 
+// InitSyncMirrors will init sync mirrors
 func InitSyncMirrors() {
 	go SyncMirrors()
 }

+ 10 - 1
models/models.go

@@ -74,6 +74,7 @@ func init() {
 	}
 }
 
+// LoadConfigs loads the database settings
 func LoadConfigs() {
 	sec := setting.Cfg.Section("database")
 	DbCfg.Type = sec.Key("DB_TYPE").String()
@@ -169,6 +170,7 @@ func getEngine() (*xorm.Engine, error) {
 	return xorm.NewEngine(DbCfg.Type, connStr)
 }
 
+// NewTestEngine sets a new test xorm.Engine
 func NewTestEngine(x *xorm.Engine) (err error) {
 	x, err = getEngine()
 	if err != nil {
@@ -179,6 +181,7 @@ func NewTestEngine(x *xorm.Engine) (err error) {
 	return x.StoreEngine("InnoDB").Sync2(tables...)
 }
 
+// SetEngine sets the xorm.Engine
 func SetEngine() (err error) {
 	x, err = getEngine()
 	if err != nil {
@@ -210,6 +213,7 @@ func SetEngine() (err error) {
 	return nil
 }
 
+// NewEngine initializes a new xorm.Engine
 func NewEngine() (err error) {
 	if err = SetEngine(); err != nil {
 		return err
@@ -233,6 +237,7 @@ type Statistic struct {
 	}
 }
 
+// GetStatistic returns the database statistics
 func GetStatistic() (stats Statistic) {
 	stats.Counter.User = CountUsers()
 	stats.Counter.Org = CountOrganizations()
@@ -258,8 +263,12 @@ func GetStatistic() (stats Statistic) {
 	return
 }
 
+// Ping tests if database is alive
 func Ping() error {
-	return x.Ping()
+	if x != nil {
+		return x.Ping()
+	}
+	return errors.New("database not configured")
 }
 
 // The version table. Should have only one row with id==1

+ 1 - 1
models/org.go

@@ -290,7 +290,7 @@ func GetOwnedOrgsByUserID(userID int64) ([]*User, error) {
 	return getOwnedOrgsByUserID(sess, userID)
 }
 
-// GetOwnedOrganizationsByUserIDDesc returns a list of organizations are owned by
+// GetOwnedOrgsByUserIDDesc returns a list of organizations are owned by
 // given user ID, ordered descending by the given condition.
 func GetOwnedOrgsByUserIDDesc(userID int64, desc string) ([]*User, error) {
 	sess := x.NewSession()

+ 2 - 0
models/pull.go

@@ -793,6 +793,7 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool
 	}
 }
 
+// ChangeUsernameInPullRequests changes the name of head_user_name
 func ChangeUsernameInPullRequests(oldUserName, newUserName string) error {
 	pr := PullRequest{
 		HeadUserName: strings.ToLower(newUserName),
@@ -868,6 +869,7 @@ func TestPullRequests() {
 	}
 }
 
+// InitTestPullRequests runs the task to test all the checking status pull requests
 func InitTestPullRequests() {
 	go TestPullRequests()
 }

+ 13 - 12
models/repo.go

@@ -52,6 +52,7 @@ var (
 	ItemsPerPage = 39
 )
 
+// LoadRepoConfig loads the repository config
 func LoadRepoConfig() {
 	// Load .gitignore and license files and readme templates.
 	types := []string{"gitignore", "license", "readme", "label"}
@@ -103,6 +104,7 @@ func LoadRepoConfig() {
 	Licenses = sortedLicenses
 }
 
+// NewRepoContext creates a new repository context
 func NewRepoContext() {
 	zip.Verbose = false
 
@@ -606,7 +608,7 @@ func (repo *Repository) LocalCopyPath() string {
 	return path.Join(setting.AppDataPath, "tmp/local-repo", com.ToStr(repo.ID))
 }
 
-// UpdateLocalCopy fetches latest changes of given branch from repoPath to localPath.
+// UpdateLocalCopyBranch fetches latest changes of given branch from repoPath to localPath.
 // It creates a new clone if local copy does not exist, but does not checks out to a
 // specific branch if the local copy belongs to a wiki.
 // For existing local copy, it checks out to target branch by default, and safe to
@@ -877,7 +879,8 @@ func createDelegateHooks(repoPath string) (err error) {
 	return nil
 }
 
-// Finish migrating repository and/or wiki with things that don't need to be done for mirrors.
+// CleanUpMigrateInfo Finish migrating repository and/or wiki with things that don't
+// need to be done for mirrors.
 func CleanUpMigrateInfo(repo *Repository) (*Repository, error) {
 	repoPath := repo.RepoPath()
 	if err := createDelegateHooks(repoPath); err != nil {
@@ -1194,6 +1197,7 @@ func CountUserRepositories(userID int64, private bool) int64 {
 	return countRepositories(userID, private)
 }
 
+// Repositories returns repos in given page.
 func Repositories(page, pageSize int) (_ []*Repository, err error) {
 	repos := make([]*Repository, 0, pageSize)
 	return repos, x.Limit(pageSize, (page-1)*pageSize).Asc("id").Find(&repos)
@@ -1478,6 +1482,7 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e
 	return nil
 }
 
+// UpdateRepository updates a repository
 func UpdateRepository(repo *Repository, visibilityChanged bool) (err error) {
 	sess := x.NewSession()
 	defer sess.Close()
@@ -1683,7 +1688,7 @@ func GetUserRepositories(opts *UserRepoOptions) ([]*Repository, error) {
 	return repos, sess.Find(&repos)
 }
 
-// GetUserRepositories returns a list of mirror repositories of given user.
+// GetUserMirrorRepositories returns a list of mirror repositories of given user.
 func GetUserMirrorRepositories(userID int64) ([]*Repository, error) {
 	repos := make([]*Repository, 0, 10)
 	return repos, x.Where("owner_id = ?", userID).And("is_mirror = ?", true).Find(&repos)
@@ -1771,6 +1776,7 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (repos []*Repository, count
 	return repos, count, sess.Distinct("repo.*").Limit(opts.PageSize, (opts.Page-1)*opts.PageSize).Find(&repos)
 }
 
+// DeleteOldRepositoryArchives deletes old repository archives.
 func DeleteOldRepositoryArchives() {
 	if taskStatusTable.IsRunning(_CleanOldArchives) {
 		return
@@ -1963,6 +1969,7 @@ func GitFsck() {
 	}
 }
 
+// GitGcRepos calls 'git gc' to remove unnecessary files and optimize the local repository
 func GitGcRepos() error {
 	args := append([]string{"gc"}, setting.Git.GCArgs...)
 	return x.Where("id > 0").Iterate(new(Repository),
@@ -2005,6 +2012,7 @@ func repoStatsCheck(checker *repoChecker) {
 	}
 }
 
+// CheckRepoStats checks the repository stats
 func CheckRepoStats() {
 	if taskStatusTable.IsRunning(_CheckRepoStats) {
 		return
@@ -2236,7 +2244,7 @@ func watchRepo(e Engine, userID, repoID int64, watch bool) (err error) {
 	return err
 }
 
-// Watch or unwatch repository.
+// WatchRepo Watch or unwatch repository.
 func WatchRepo(userID, repoID int64, watch bool) (err error) {
 	return watchRepo(x, userID, repoID, watch)
 }
@@ -2298,20 +2306,13 @@ func NotifyWatchers(act *Action) error {
 	return notifyWatchers(x, act)
 }
 
-//   _________ __
-//  /   _____//  |______ _______
-//  \_____  \\   __\__  \\_  __ \
-//  /        \|  |  / __ \|  | \/
-// /_______  /|__| (____  /__|
-//         \/           \/
-
 type Star struct {
 	ID     int64
 	UID    int64 `xorm:"UNIQUE(s)"`
 	RepoID int64 `xorm:"UNIQUE(s)"`
 }
 
-// Star or unstar repository.
+// StarRepo Star or unstar repository.
 func StarRepo(userID, repoID int64, star bool) (err error) {
 	if star {
 		if IsStaring(userID, repoID) {

+ 1 - 0
models/repo_branch.go

@@ -24,6 +24,7 @@ type Branch struct {
 	Commit      *git.Commit
 }
 
+// GetBranchesByPath returns a branch by it's path
 func GetBranchesByPath(path string) ([]*Branch, error) {
 	gitRepo, err := git.OpenRepository(path)
 	if err != nil {

+ 6 - 0
models/repo_editor.go

@@ -47,6 +47,7 @@ type ComposeHookEnvsOptions struct {
 	RepoPath  string
 }
 
+// ComposeHookEnvs returns the envs
 func ComposeHookEnvs(opts ComposeHookEnvsOptions) []string {
 	envs := []string{
 		"SSH_ORIGINAL_COMMAND=1",
@@ -333,6 +334,7 @@ func NewUpload(name string, buf []byte, file multipart.File) (_ *Upload, err err
 	return upload, nil
 }
 
+// GetUploadByUUID returns the Upload by UUID
 func GetUploadByUUID(uuid string) (*Upload, error) {
 	upload := &Upload{UUID: uuid}
 	has, err := x.Get(upload)
@@ -344,6 +346,7 @@ func GetUploadByUUID(uuid string) (*Upload, error) {
 	return upload, nil
 }
 
+// GetUploadsByUUIDs returns multiple uploads by UUIDS
 func GetUploadsByUUIDs(uuids []string) ([]*Upload, error) {
 	if len(uuids) == 0 {
 		return []*Upload{}, nil
@@ -354,6 +357,7 @@ func GetUploadsByUUIDs(uuids []string) ([]*Upload, error) {
 	return uploads, x.In("uuid", uuids).Find(&uploads)
 }
 
+// DeleteUploads deletes multiple uploads
 func DeleteUploads(uploads ...*Upload) (err error) {
 	if len(uploads) == 0 {
 		return nil
@@ -387,10 +391,12 @@ func DeleteUploads(uploads ...*Upload) (err error) {
 	return sess.Commit()
 }
 
+// DeleteUpload delete a upload
 func DeleteUpload(u *Upload) error {
 	return DeleteUploads(u)
 }
 
+// DeleteUploadByUUID deletes a upload by UUID
 func DeleteUploadByUUID(uuid string) error {
 	upload, err := GetUploadByUUID(uuid)
 	if err != nil {

+ 1 - 0
models/update.go

@@ -28,6 +28,7 @@ func CommitToPushCommit(commit *git.Commit) *PushCommit {
 	}
 }
 
+// ListToPushCommits transforms a list.List to PushCommits type.
 func ListToPushCommits(l *list.List) *PushCommits {
 	if l == nil {
 		return &PushCommits{}

+ 5 - 0
models/user_mail.go

@@ -90,10 +90,12 @@ func addEmailAddress(e Engine, email *EmailAddress) error {
 	return err
 }
 
+// AddEmailAddress adds an email address to given user.
 func AddEmailAddress(email *EmailAddress) error {
 	return addEmailAddress(x, email)
 }
 
+// AddEmailAddresses adds an email address to given user.
 func AddEmailAddresses(emails []*EmailAddress) error {
 	if len(emails) == 0 {
 		return nil
@@ -142,6 +144,7 @@ func (email *EmailAddress) Activate() error {
 	return sess.Commit()
 }
 
+// DeleteEmailAddress deletes an email address of given user.
 func DeleteEmailAddress(email *EmailAddress) (err error) {
 	if email.ID > 0 {
 		_, err = x.Id(email.ID).Delete(new(EmailAddress))
@@ -151,6 +154,7 @@ func DeleteEmailAddress(email *EmailAddress) (err error) {
 	return err
 }
 
+// DeleteEmailAddresses deletes multiple email addresses
 func DeleteEmailAddresses(emails []*EmailAddress) (err error) {
 	for i := range emails {
 		if err = DeleteEmailAddress(emails[i]); err != nil {
@@ -161,6 +165,7 @@ func DeleteEmailAddresses(emails []*EmailAddress) (err error) {
 	return nil
 }
 
+// MakeEmailPrimary sets primary email address of given user.
 func MakeEmailPrimary(email *EmailAddress) error {
 	has, err := x.Get(email)
 	if err != nil {

+ 1 - 1
routes/explore.go

@@ -31,7 +31,7 @@ const (
 	ExploreOrganizationsTPL = "explore/organizations"
 )
 
-// ExploreHome shows explore page
+// Explore shows explore page
 func Explore(c *context.Context) {
 	c.Data["Title"] = c.Tr("explore")
 	c.Data["PageIsExplore"] = true