Browse Source

Update GRC #100 in routes

Yoginth 7 years ago
parent
commit
25ca4ed23a

+ 1 - 0
routes/api/v1/admin/org.go

@@ -14,6 +14,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// CreateOrg api for create organization
 func CreateOrg(c *context.APIContext, form api.CreateOrgOption) {
 func CreateOrg(c *context.APIContext, form api.CreateOrgOption) {
 	org.CreateOrgForUser(c, form, user.GetUserByParams(c))
 	org.CreateOrgForUser(c, form, user.GetUserByParams(c))
 }
 }

+ 3 - 0
routes/api/v1/admin/org_repo.go

@@ -12,6 +12,7 @@ import (
 	"gitote/gitote/pkg/context"
 	"gitote/gitote/pkg/context"
 )
 )
 
 
+// GetRepositoryByParams gets repository with params
 func GetRepositoryByParams(c *context.APIContext) *models.Repository {
 func GetRepositoryByParams(c *context.APIContext) *models.Repository {
 	repo, err := models.GetRepositoryByName(c.Org.Team.OrgID, c.Params(":reponame"))
 	repo, err := models.GetRepositoryByName(c.Org.Team.OrgID, c.Params(":reponame"))
 	if err != nil {
 	if err != nil {
@@ -25,6 +26,7 @@ func GetRepositoryByParams(c *context.APIContext) *models.Repository {
 	return repo
 	return repo
 }
 }
 
 
+// AddTeamRepository api for adding a repository
 func AddTeamRepository(c *context.APIContext) {
 func AddTeamRepository(c *context.APIContext) {
 	repo := GetRepositoryByParams(c)
 	repo := GetRepositoryByParams(c)
 	if c.Written() {
 	if c.Written() {
@@ -38,6 +40,7 @@ func AddTeamRepository(c *context.APIContext) {
 	c.Status(204)
 	c.Status(204)
 }
 }
 
 
+// RemoveTeamRepository api for removing a repository
 func RemoveTeamRepository(c *context.APIContext) {
 func RemoveTeamRepository(c *context.APIContext) {
 	repo := GetRepositoryByParams(c)
 	repo := GetRepositoryByParams(c)
 	if c.Written() {
 	if c.Written() {

+ 3 - 0
routes/api/v1/admin/org_team.go

@@ -15,6 +15,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// CreateTeam api for create a team
 func CreateTeam(c *context.APIContext, form api.CreateTeamOption) {
 func CreateTeam(c *context.APIContext, form api.CreateTeamOption) {
 	team := &models.Team{
 	team := &models.Team{
 		OrgID:       c.Org.Organization.ID,
 		OrgID:       c.Org.Organization.ID,
@@ -34,6 +35,7 @@ func CreateTeam(c *context.APIContext, form api.CreateTeamOption) {
 	c.JSON(201, convert.ToTeam(team))
 	c.JSON(201, convert.ToTeam(team))
 }
 }
 
 
+// AddTeamMember api for add a member to a team
 func AddTeamMember(c *context.APIContext) {
 func AddTeamMember(c *context.APIContext) {
 	u := user.GetUserByParams(c)
 	u := user.GetUserByParams(c)
 	if c.Written() {
 	if c.Written() {
@@ -47,6 +49,7 @@ func AddTeamMember(c *context.APIContext) {
 	c.Status(204)
 	c.Status(204)
 }
 }
 
 
+// RemoveTeamMember api for remove one member from a team
 func RemoveTeamMember(c *context.APIContext) {
 func RemoveTeamMember(c *context.APIContext) {
 	u := user.GetUserByParams(c)
 	u := user.GetUserByParams(c)
 	if c.Written() {
 	if c.Written() {

+ 1 - 0
routes/api/v1/admin/repo.go

@@ -14,6 +14,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// CreateRepo api for creating a repository
 func CreateRepo(c *context.APIContext, form api.CreateRepoOption) {
 func CreateRepo(c *context.APIContext, form api.CreateRepoOption) {
 	owner := user.GetUserByParams(c)
 	owner := user.GetUserByParams(c)
 	if c.Written() {
 	if c.Written() {

+ 4 - 0
routes/api/v1/admin/user.go

@@ -38,6 +38,7 @@ func parseLoginSource(c *context.APIContext, u *models.User, sourceID int64, log
 	u.LoginName = loginName
 	u.LoginName = loginName
 }
 }
 
 
+// CreateUser create a user
 func CreateUser(c *context.APIContext, form api.CreateUserOption) {
 func CreateUser(c *context.APIContext, form api.CreateUserOption) {
 	u := &models.User{
 	u := &models.User{
 		Name:      form.Username,
 		Name:      form.Username,
@@ -74,6 +75,7 @@ func CreateUser(c *context.APIContext, form api.CreateUserOption) {
 	c.JSON(201, u.APIFormat())
 	c.JSON(201, u.APIFormat())
 }
 }
 
 
+// EditUser api for modifying a user's information
 func EditUser(c *context.APIContext, form api.EditUserOption) {
 func EditUser(c *context.APIContext, form api.EditUserOption) {
 	u := user.GetUserByParams(c)
 	u := user.GetUserByParams(c)
 	if c.Written() {
 	if c.Written() {
@@ -129,6 +131,7 @@ func EditUser(c *context.APIContext, form api.EditUserOption) {
 	c.JSON(200, u.APIFormat())
 	c.JSON(200, u.APIFormat())
 }
 }
 
 
+// DeleteUser api for deleting a user
 func DeleteUser(c *context.APIContext) {
 func DeleteUser(c *context.APIContext) {
 	u := user.GetUserByParams(c)
 	u := user.GetUserByParams(c)
 	if c.Written() {
 	if c.Written() {
@@ -149,6 +152,7 @@ func DeleteUser(c *context.APIContext) {
 	c.Status(204)
 	c.Status(204)
 }
 }
 
 
+// CreatePublicKey api for creating a public key to a user
 func CreatePublicKey(c *context.APIContext, form api.CreateKeyOption) {
 func CreatePublicKey(c *context.APIContext, form api.CreateKeyOption) {
 	u := user.GetUserByParams(c)
 	u := user.GetUserByParams(c)
 	if c.Written() {
 	if c.Written() {

+ 8 - 0
routes/api/v1/convert/convert.go

@@ -15,6 +15,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// ToEmail convert models.EmailAddress to api.Email
 func ToEmail(email *models.EmailAddress) *api.Email {
 func ToEmail(email *models.EmailAddress) *api.Email {
 	return &api.Email{
 	return &api.Email{
 		Email:    email.Email,
 		Email:    email.Email,
@@ -23,6 +24,7 @@ func ToEmail(email *models.EmailAddress) *api.Email {
 	}
 	}
 }
 }
 
 
+// ToBranch convert a commit and branch to an api.Branch
 func ToBranch(b *models.Branch, c *git.Commit) *api.Branch {
 func ToBranch(b *models.Branch, c *git.Commit) *api.Branch {
 	return &api.Branch{
 	return &api.Branch{
 		Name:   b.Name,
 		Name:   b.Name,
@@ -30,6 +32,7 @@ func ToBranch(b *models.Branch, c *git.Commit) *api.Branch {
 	}
 	}
 }
 }
 
 
+// ToCommit convert a commit to api.PayloadCommit
 func ToCommit(c *git.Commit) *api.PayloadCommit {
 func ToCommit(c *git.Commit) *api.PayloadCommit {
 	authorUsername := ""
 	authorUsername := ""
 	author, err := models.GetUserByEmail(c.Author.Email)
 	author, err := models.GetUserByEmail(c.Author.Email)
@@ -59,6 +62,7 @@ func ToCommit(c *git.Commit) *api.PayloadCommit {
 	}
 	}
 }
 }
 
 
+// ToPublicKey convert models.PublicKey to api.PublicKey
 func ToPublicKey(apiLink string, key *models.PublicKey) *api.PublicKey {
 func ToPublicKey(apiLink string, key *models.PublicKey) *api.PublicKey {
 	return &api.PublicKey{
 	return &api.PublicKey{
 		ID:      key.ID,
 		ID:      key.ID,
@@ -69,6 +73,7 @@ func ToPublicKey(apiLink string, key *models.PublicKey) *api.PublicKey {
 	}
 	}
 }
 }
 
 
+// ToHook convert models.Webhook to api.Hook
 func ToHook(repoLink string, w *models.Webhook) *api.Hook {
 func ToHook(repoLink string, w *models.Webhook) *api.Hook {
 	config := map[string]string{
 	config := map[string]string{
 		"url":          w.URL,
 		"url":          w.URL,
@@ -94,6 +99,7 @@ func ToHook(repoLink string, w *models.Webhook) *api.Hook {
 	}
 	}
 }
 }
 
 
+// ToDeployKey convert models.DeployKey to api.DeployKey
 func ToDeployKey(apiLink string, key *models.DeployKey) *api.DeployKey {
 func ToDeployKey(apiLink string, key *models.DeployKey) *api.DeployKey {
 	return &api.DeployKey{
 	return &api.DeployKey{
 		ID:       key.ID,
 		ID:       key.ID,
@@ -105,6 +111,7 @@ func ToDeployKey(apiLink string, key *models.DeployKey) *api.DeployKey {
 	}
 	}
 }
 }
 
 
+// ToOrganization convert models.User to api.Organization
 func ToOrganization(org *models.User) *api.Organization {
 func ToOrganization(org *models.User) *api.Organization {
 	return &api.Organization{
 	return &api.Organization{
 		ID:          org.ID,
 		ID:          org.ID,
@@ -117,6 +124,7 @@ func ToOrganization(org *models.User) *api.Organization {
 	}
 	}
 }
 }
 
 
+// ToTeam convert models.Team to api.Team
 func ToTeam(team *models.Team) *api.Team {
 func ToTeam(team *models.Team) *api.Team {
 	return &api.Team{
 	return &api.Team{
 		ID:          team.ID,
 		ID:          team.ID,

+ 2 - 0
routes/api/v1/misc/markdown.go

@@ -13,6 +13,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// Markdown render markdown document to HTML
 func Markdown(c *context.APIContext, form api.MarkdownOption) {
 func Markdown(c *context.APIContext, form api.MarkdownOption) {
 	if c.HasApiError() {
 	if c.HasApiError() {
 		c.Error(422, "", c.GetErrMsg())
 		c.Error(422, "", c.GetErrMsg())
@@ -32,6 +33,7 @@ func Markdown(c *context.APIContext, form api.MarkdownOption) {
 	}
 	}
 }
 }
 
 
+// MarkdownRaw render raw markdown HTML
 func MarkdownRaw(c *context.APIContext) {
 func MarkdownRaw(c *context.APIContext) {
 	body, err := c.Req.Body().Bytes()
 	body, err := c.Req.Body().Bytes()
 	if err != nil {
 	if err != nil {

+ 6 - 0
routes/api/v1/org/org.go

@@ -15,6 +15,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// CreateOrgForUser api for create organization
 func CreateOrgForUser(c *context.APIContext, apiForm api.CreateOrgOption, user *models.User) {
 func CreateOrgForUser(c *context.APIContext, apiForm api.CreateOrgOption, user *models.User) {
 	if c.Written() {
 	if c.Written() {
 		return
 		return
@@ -56,14 +57,17 @@ func listUserOrgs(c *context.APIContext, u *models.User, all bool) {
 	c.JSON(200, &apiOrgs)
 	c.JSON(200, &apiOrgs)
 }
 }
 
 
+// ListMyOrgs list all my orgs
 func ListMyOrgs(c *context.APIContext) {
 func ListMyOrgs(c *context.APIContext) {
 	listUserOrgs(c, c.User, true)
 	listUserOrgs(c, c.User, true)
 }
 }
 
 
+// CreateMyOrg list user's orgs
 func CreateMyOrg(c *context.APIContext, apiForm api.CreateOrgOption) {
 func CreateMyOrg(c *context.APIContext, apiForm api.CreateOrgOption) {
 	CreateOrgForUser(c, apiForm, c.User)
 	CreateOrgForUser(c, apiForm, c.User)
 }
 }
 
 
+// ListUserOrgs list user's orgs
 func ListUserOrgs(c *context.APIContext) {
 func ListUserOrgs(c *context.APIContext) {
 	u := user.GetUserByParams(c)
 	u := user.GetUserByParams(c)
 	if c.Written() {
 	if c.Written() {
@@ -72,10 +76,12 @@ func ListUserOrgs(c *context.APIContext) {
 	listUserOrgs(c, u, false)
 	listUserOrgs(c, u, false)
 }
 }
 
 
+// Get get an organization
 func Get(c *context.APIContext) {
 func Get(c *context.APIContext) {
 	c.JSON(200, convert.ToOrganization(c.Org.Organization))
 	c.JSON(200, convert.ToOrganization(c.Org.Organization))
 }
 }
 
 
+// Edit change an organization's information
 func Edit(c *context.APIContext, form api.EditOrgOption) {
 func Edit(c *context.APIContext, form api.EditOrgOption) {
 	org := c.Org.Organization
 	org := c.Org.Organization
 	if !org.IsOwnedBy(c.User.ID) {
 	if !org.IsOwnedBy(c.User.ID) {

+ 1 - 0
routes/api/v1/org/team.go

@@ -13,6 +13,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// ListTeams list all the teams of an organization
 func ListTeams(c *context.APIContext) {
 func ListTeams(c *context.APIContext) {
 	org := c.Org.Organization
 	org := c.Org.Organization
 	if err := org.GetTeams(); err != nil {
 	if err := org.GetTeams(); err != nil {

+ 2 - 0
routes/api/v1/repo/branch.go

@@ -14,6 +14,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// GetBranch get a branch of a repository
 func GetBranch(c *context.APIContext) {
 func GetBranch(c *context.APIContext) {
 	branch, err := c.Repo.Repository.GetBranch(c.Params("*"))
 	branch, err := c.Repo.Repository.GetBranch(c.Params("*"))
 	if err != nil {
 	if err != nil {
@@ -34,6 +35,7 @@ func GetBranch(c *context.APIContext) {
 	c.JSON(200, convert.ToBranch(branch, commit))
 	c.JSON(200, convert.ToBranch(branch, commit))
 }
 }
 
 
+// ListBranches list all the branches of a repository
 func ListBranches(c *context.APIContext) {
 func ListBranches(c *context.APIContext) {
 	branches, err := c.Repo.Repository.GetBranches()
 	branches, err := c.Repo.Repository.GetBranches()
 	if err != nil {
 	if err != nil {

+ 4 - 0
routes/api/v1/repo/collaborators.go

@@ -14,6 +14,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// ListCollaborators list a repository's collaborators
 func ListCollaborators(c *context.APIContext) {
 func ListCollaborators(c *context.APIContext) {
 	collaborators, err := c.Repo.Repository.GetCollaborators()
 	collaborators, err := c.Repo.Repository.GetCollaborators()
 	if err != nil {
 	if err != nil {
@@ -27,6 +28,7 @@ func ListCollaborators(c *context.APIContext) {
 	c.JSONSuccess(&apiCollaborators)
 	c.JSONSuccess(&apiCollaborators)
 }
 }
 
 
+// AddCollaborator add a collaborator to a repository
 func AddCollaborator(c *context.APIContext, form api.AddCollaboratorOption) {
 func AddCollaborator(c *context.APIContext, form api.AddCollaboratorOption) {
 	collaborator, err := models.GetUserByName(c.Params(":collaborator"))
 	collaborator, err := models.GetUserByName(c.Params(":collaborator"))
 	if err != nil {
 	if err != nil {
@@ -53,6 +55,7 @@ func AddCollaborator(c *context.APIContext, form api.AddCollaboratorOption) {
 	c.Status(204)
 	c.Status(204)
 }
 }
 
 
+// IsCollaborator check if a user is a collaborator of a repository
 func IsCollaborator(c *context.APIContext) {
 func IsCollaborator(c *context.APIContext) {
 	collaborator, err := models.GetUserByName(c.Params(":collaborator"))
 	collaborator, err := models.GetUserByName(c.Params(":collaborator"))
 	if err != nil {
 	if err != nil {
@@ -71,6 +74,7 @@ func IsCollaborator(c *context.APIContext) {
 	}
 	}
 }
 }
 
 
+// DeleteCollaborator delete a collaborator from a repository
 func DeleteCollaborator(c *context.APIContext) {
 func DeleteCollaborator(c *context.APIContext) {
 	collaborator, err := models.GetUserByName(c.Params(":collaborator"))
 	collaborator, err := models.GetUserByName(c.Params(":collaborator"))
 	if err != nil {
 	if err != nil {

+ 2 - 0
routes/api/v1/repo/commits.go

@@ -20,6 +20,7 @@ import (
 	"gitote/gitote/pkg/setting"
 	"gitote/gitote/pkg/setting"
 )
 )
 
 
+// GetSingleCommit returns single commits of a branch
 func GetSingleCommit(c *context.APIContext) {
 func GetSingleCommit(c *context.APIContext) {
 	if strings.Contains(c.Req.Header.Get("Accept"), api.MediaApplicationSHA) {
 	if strings.Contains(c.Req.Header.Get("Accept"), api.MediaApplicationSHA) {
 		c.SetParams("*", c.Params(":sha"))
 		c.SetParams("*", c.Params(":sha"))
@@ -100,6 +101,7 @@ func GetSingleCommit(c *context.APIContext) {
 	})
 	})
 }
 }
 
 
+// GetReferenceSHA returns reference SHA
 func GetReferenceSHA(c *context.APIContext) {
 func GetReferenceSHA(c *context.APIContext) {
 	gitRepo, err := git.OpenRepository(c.Repo.Repository.RepoPath())
 	gitRepo, err := git.OpenRepository(c.Repo.Repository.RepoPath())
 	if err != nil {
 	if err != nil {

+ 3 - 0
routes/api/v1/repo/file.go

@@ -14,6 +14,7 @@ import (
 	"gitlab.com/gitote/git-module"
 	"gitlab.com/gitote/git-module"
 )
 )
 
 
+// GetRawFile get a file by path on a repository
 func GetRawFile(c *context.APIContext) {
 func GetRawFile(c *context.APIContext) {
 	if !c.Repo.HasAccess() {
 	if !c.Repo.HasAccess() {
 		c.Status(404)
 		c.Status(404)
@@ -39,6 +40,7 @@ func GetRawFile(c *context.APIContext) {
 	}
 	}
 }
 }
 
 
+// GetArchive get archive of a repository
 func GetArchive(c *context.APIContext) {
 func GetArchive(c *context.APIContext) {
 	repoPath := models.RepoPath(c.Params(":username"), c.Params(":reponame"))
 	repoPath := models.RepoPath(c.Params(":username"), c.Params(":reponame"))
 	gitRepo, err := git.OpenRepository(repoPath)
 	gitRepo, err := git.OpenRepository(repoPath)
@@ -51,6 +53,7 @@ func GetArchive(c *context.APIContext) {
 	repo.Download(c.Context)
 	repo.Download(c.Context)
 }
 }
 
 
+// GetEditorconfig get editor config of a repository
 func GetEditorconfig(c *context.APIContext) {
 func GetEditorconfig(c *context.APIContext) {
 	ec, err := c.Repo.GetEditorconfig()
 	ec, err := c.Repo.GetEditorconfig()
 	if err != nil {
 	if err != nil {

+ 4 - 0
routes/api/v1/repo/hook.go

@@ -17,6 +17,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// ListHooks list all hooks of a repository
 func ListHooks(c *context.APIContext) {
 func ListHooks(c *context.APIContext) {
 	hooks, err := models.GetWebhooksByRepoID(c.Repo.Repository.ID)
 	hooks, err := models.GetWebhooksByRepoID(c.Repo.Repository.ID)
 	if err != nil {
 	if err != nil {
@@ -31,6 +32,7 @@ func ListHooks(c *context.APIContext) {
 	c.JSON(200, &apiHooks)
 	c.JSON(200, &apiHooks)
 }
 }
 
 
+// CreateHook create a hook for a repository
 func CreateHook(c *context.APIContext, form api.CreateHookOption) {
 func CreateHook(c *context.APIContext, form api.CreateHookOption) {
 	if !models.IsValidHookTaskType(form.Type) {
 	if !models.IsValidHookTaskType(form.Type) {
 		c.Error(422, "", "Invalid hook type")
 		c.Error(422, "", "Invalid hook type")
@@ -101,6 +103,7 @@ func CreateHook(c *context.APIContext, form api.CreateHookOption) {
 	c.JSON(201, convert.ToHook(c.Repo.RepoLink, w))
 	c.JSON(201, convert.ToHook(c.Repo.RepoLink, w))
 }
 }
 
 
+// EditHook modify a hook of a repository
 func EditHook(c *context.APIContext, form api.EditHookOption) {
 func EditHook(c *context.APIContext, form api.EditHookOption) {
 	w, err := models.GetWebhookOfRepoByID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
 	w, err := models.GetWebhookOfRepoByID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
 	if err != nil {
 	if err != nil {
@@ -173,6 +176,7 @@ func EditHook(c *context.APIContext, form api.EditHookOption) {
 	c.JSON(200, convert.ToHook(c.Repo.RepoLink, w))
 	c.JSON(200, convert.ToHook(c.Repo.RepoLink, w))
 }
 }
 
 
+// DeleteHook delete a hook of a repository
 func DeleteHook(c *context.APIContext) {
 func DeleteHook(c *context.APIContext) {
 	if err := models.DeleteWebhookOfRepoByID(c.Repo.Repository.ID, c.ParamsInt64(":id")); err != nil {
 	if err := models.DeleteWebhookOfRepoByID(c.Repo.Repository.ID, c.ParamsInt64(":id")); err != nil {
 		c.Error(500, "DeleteWebhookByRepoID", err)
 		c.Error(500, "DeleteWebhookByRepoID", err)

+ 5 - 0
routes/api/v1/repo/issue.go

@@ -44,6 +44,7 @@ func listIssues(c *context.APIContext, opts *models.IssuesOptions) {
 	c.JSON(200, &apiIssues)
 	c.JSON(200, &apiIssues)
 }
 }
 
 
+// ListUserIssues list the user issues of a repository
 func ListUserIssues(c *context.APIContext) {
 func ListUserIssues(c *context.APIContext) {
 	opts := models.IssuesOptions{
 	opts := models.IssuesOptions{
 		AssigneeID: c.User.ID,
 		AssigneeID: c.User.ID,
@@ -54,6 +55,7 @@ func ListUserIssues(c *context.APIContext) {
 	listIssues(c, &opts)
 	listIssues(c, &opts)
 }
 }
 
 
+// ListIssues list the issues of a repository
 func ListIssues(c *context.APIContext) {
 func ListIssues(c *context.APIContext) {
 	opts := models.IssuesOptions{
 	opts := models.IssuesOptions{
 		RepoID:   c.Repo.Repository.ID,
 		RepoID:   c.Repo.Repository.ID,
@@ -64,6 +66,7 @@ func ListIssues(c *context.APIContext) {
 	listIssues(c, &opts)
 	listIssues(c, &opts)
 }
 }
 
 
+// GetIssue get an issue of a repository
 func GetIssue(c *context.APIContext) {
 func GetIssue(c *context.APIContext) {
 	issue, err := models.GetIssueByIndex(c.Repo.Repository.ID, c.ParamsInt64(":index"))
 	issue, err := models.GetIssueByIndex(c.Repo.Repository.ID, c.ParamsInt64(":index"))
 	if err != nil {
 	if err != nil {
@@ -77,6 +80,7 @@ func GetIssue(c *context.APIContext) {
 	c.JSON(200, issue.APIFormat())
 	c.JSON(200, issue.APIFormat())
 }
 }
 
 
+// CreateIssue create an issue of a repository
 func CreateIssue(c *context.APIContext, form api.CreateIssueOption) {
 func CreateIssue(c *context.APIContext, form api.CreateIssueOption) {
 	issue := &models.Issue{
 	issue := &models.Issue{
 		RepoID:   c.Repo.Repository.ID,
 		RepoID:   c.Repo.Repository.ID,
@@ -126,6 +130,7 @@ func CreateIssue(c *context.APIContext, form api.CreateIssueOption) {
 	c.JSON(201, issue.APIFormat())
 	c.JSON(201, issue.APIFormat())
 }
 }
 
 
+// EditIssue modify an issue of a repository
 func EditIssue(c *context.APIContext, form api.EditIssueOption) {
 func EditIssue(c *context.APIContext, form api.EditIssueOption) {
 	issue, err := models.GetIssueByIndex(c.Repo.Repository.ID, c.ParamsInt64(":index"))
 	issue, err := models.GetIssueByIndex(c.Repo.Repository.ID, c.ParamsInt64(":index"))
 	if err != nil {
 	if err != nil {

+ 5 - 0
routes/api/v1/repo/issue_comment.go

@@ -14,6 +14,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// ListIssueComments list all the comments of an issue
 func ListIssueComments(c *context.APIContext) {
 func ListIssueComments(c *context.APIContext) {
 	var since time.Time
 	var since time.Time
 	if len(c.Query("since")) > 0 {
 	if len(c.Query("since")) > 0 {
@@ -45,6 +46,7 @@ func ListIssueComments(c *context.APIContext) {
 	c.JSON(200, &apiComments)
 	c.JSON(200, &apiComments)
 }
 }
 
 
+// ListRepoIssueComments returns all issue-comments for a repo
 func ListRepoIssueComments(c *context.APIContext) {
 func ListRepoIssueComments(c *context.APIContext) {
 	var since time.Time
 	var since time.Time
 	if len(c.Query("since")) > 0 {
 	if len(c.Query("since")) > 0 {
@@ -69,6 +71,7 @@ func ListRepoIssueComments(c *context.APIContext) {
 	c.JSON(200, &apiComments)
 	c.JSON(200, &apiComments)
 }
 }
 
 
+// CreateIssueComment create a comment for an issue
 func CreateIssueComment(c *context.APIContext, form api.CreateIssueCommentOption) {
 func CreateIssueComment(c *context.APIContext, form api.CreateIssueCommentOption) {
 	issue, err := models.GetIssueByIndex(c.Repo.Repository.ID, c.ParamsInt64(":index"))
 	issue, err := models.GetIssueByIndex(c.Repo.Repository.ID, c.ParamsInt64(":index"))
 	if err != nil {
 	if err != nil {
@@ -85,6 +88,7 @@ func CreateIssueComment(c *context.APIContext, form api.CreateIssueCommentOption
 	c.JSON(201, comment.APIFormat())
 	c.JSON(201, comment.APIFormat())
 }
 }
 
 
+// EditIssueComment modify a comment of an issue
 func EditIssueComment(c *context.APIContext, form api.EditIssueCommentOption) {
 func EditIssueComment(c *context.APIContext, form api.EditIssueCommentOption) {
 	comment, err := models.GetCommentByID(c.ParamsInt64(":id"))
 	comment, err := models.GetCommentByID(c.ParamsInt64(":id"))
 	if err != nil {
 	if err != nil {
@@ -113,6 +117,7 @@ func EditIssueComment(c *context.APIContext, form api.EditIssueCommentOption) {
 	c.JSON(200, comment.APIFormat())
 	c.JSON(200, comment.APIFormat())
 }
 }
 
 
+// DeleteIssueComment delete a comment from an issue
 func DeleteIssueComment(c *context.APIContext) {
 func DeleteIssueComment(c *context.APIContext) {
 	comment, err := models.GetCommentByID(c.ParamsInt64(":id"))
 	comment, err := models.GetCommentByID(c.ParamsInt64(":id"))
 	if err != nil {
 	if err != nil {

+ 5 - 0
routes/api/v1/repo/issue_label.go

@@ -14,6 +14,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// ListIssueLabels list all the labels of an issue
 func ListIssueLabels(c *context.APIContext) {
 func ListIssueLabels(c *context.APIContext) {
 	issue, err := models.GetIssueByIndex(c.Repo.Repository.ID, c.ParamsInt64(":index"))
 	issue, err := models.GetIssueByIndex(c.Repo.Repository.ID, c.ParamsInt64(":index"))
 	if err != nil {
 	if err != nil {
@@ -32,6 +33,7 @@ func ListIssueLabels(c *context.APIContext) {
 	c.JSON(200, &apiLabels)
 	c.JSON(200, &apiLabels)
 }
 }
 
 
+// AddIssueLabels add labels for an issue
 func AddIssueLabels(c *context.APIContext, form api.IssueLabelsOption) {
 func AddIssueLabels(c *context.APIContext, form api.IssueLabelsOption) {
 	if !c.Repo.IsWriter() {
 	if !c.Repo.IsWriter() {
 		c.Status(403)
 		c.Status(403)
@@ -72,6 +74,7 @@ func AddIssueLabels(c *context.APIContext, form api.IssueLabelsOption) {
 	c.JSON(200, &apiLabels)
 	c.JSON(200, &apiLabels)
 }
 }
 
 
+// DeleteIssueLabel delete a label for an issue
 func DeleteIssueLabel(c *context.APIContext) {
 func DeleteIssueLabel(c *context.APIContext) {
 	if !c.Repo.IsWriter() {
 	if !c.Repo.IsWriter() {
 		c.Status(403)
 		c.Status(403)
@@ -106,6 +109,7 @@ func DeleteIssueLabel(c *context.APIContext) {
 	c.Status(204)
 	c.Status(204)
 }
 }
 
 
+// ReplaceIssueLabels replace labels for an issue
 func ReplaceIssueLabels(c *context.APIContext, form api.IssueLabelsOption) {
 func ReplaceIssueLabels(c *context.APIContext, form api.IssueLabelsOption) {
 	if !c.Repo.IsWriter() {
 	if !c.Repo.IsWriter() {
 		c.Status(403)
 		c.Status(403)
@@ -146,6 +150,7 @@ func ReplaceIssueLabels(c *context.APIContext, form api.IssueLabelsOption) {
 	c.JSON(200, &apiLabels)
 	c.JSON(200, &apiLabels)
 }
 }
 
 
+// ClearIssueLabels delete all the labels for an issue
 func ClearIssueLabels(c *context.APIContext) {
 func ClearIssueLabels(c *context.APIContext) {
 	if !c.Repo.IsWriter() {
 	if !c.Repo.IsWriter() {
 		c.Status(403)
 		c.Status(403)

+ 6 - 0
routes/api/v1/repo/key.go

@@ -20,6 +20,7 @@ func composeDeployKeysAPILink(repoPath string) string {
 	return setting.AppURL + "api/v1/repos/" + repoPath + "/keys/"
 	return setting.AppURL + "api/v1/repos/" + repoPath + "/keys/"
 }
 }
 
 
+// ListDeployKeys list all the deploy keys of a repository
 func ListDeployKeys(c *context.APIContext) {
 func ListDeployKeys(c *context.APIContext) {
 	keys, err := models.ListDeployKeys(c.Repo.Repository.ID)
 	keys, err := models.ListDeployKeys(c.Repo.Repository.ID)
 	if err != nil {
 	if err != nil {
@@ -40,6 +41,7 @@ func ListDeployKeys(c *context.APIContext) {
 	c.JSON(200, &apiKeys)
 	c.JSON(200, &apiKeys)
 }
 }
 
 
+// GetDeployKey get a deploy key by id
 func GetDeployKey(c *context.APIContext) {
 func GetDeployKey(c *context.APIContext) {
 	key, err := models.GetDeployKeyByID(c.ParamsInt64(":id"))
 	key, err := models.GetDeployKeyByID(c.ParamsInt64(":id"))
 	if err != nil {
 	if err != nil {
@@ -60,6 +62,7 @@ func GetDeployKey(c *context.APIContext) {
 	c.JSON(200, convert.ToDeployKey(apiLink, key))
 	c.JSON(200, convert.ToDeployKey(apiLink, key))
 }
 }
 
 
+// HandleCheckKeyStringError handle check key error
 func HandleCheckKeyStringError(c *context.APIContext, err error) {
 func HandleCheckKeyStringError(c *context.APIContext, err error) {
 	if models.IsErrKeyUnableVerify(err) {
 	if models.IsErrKeyUnableVerify(err) {
 		c.Error(422, "", "Unable to verify key content")
 		c.Error(422, "", "Unable to verify key content")
@@ -68,6 +71,7 @@ func HandleCheckKeyStringError(c *context.APIContext, err error) {
 	}
 	}
 }
 }
 
 
+// HandleAddKeyError handle add key error
 func HandleAddKeyError(c *context.APIContext, err error) {
 func HandleAddKeyError(c *context.APIContext, err error) {
 	switch {
 	switch {
 	case models.IsErrKeyAlreadyExist(err):
 	case models.IsErrKeyAlreadyExist(err):
@@ -79,6 +83,7 @@ func HandleAddKeyError(c *context.APIContext, err error) {
 	}
 	}
 }
 }
 
 
+// CreateDeployKey create deploy key for a repository
 func CreateDeployKey(c *context.APIContext, form api.CreateKeyOption) {
 func CreateDeployKey(c *context.APIContext, form api.CreateKeyOption) {
 	content, err := models.CheckPublicKeyString(form.Key)
 	content, err := models.CheckPublicKeyString(form.Key)
 	if err != nil {
 	if err != nil {
@@ -97,6 +102,7 @@ func CreateDeployKey(c *context.APIContext, form api.CreateKeyOption) {
 	c.JSON(201, convert.ToDeployKey(apiLink, key))
 	c.JSON(201, convert.ToDeployKey(apiLink, key))
 }
 }
 
 
+// DeleteDeploykey delete deploy key for a repository
 func DeleteDeploykey(c *context.APIContext) {
 func DeleteDeploykey(c *context.APIContext) {
 	if err := models.DeleteDeployKey(c.User, c.ParamsInt64(":id")); err != nil {
 	if err := models.DeleteDeployKey(c.User, c.ParamsInt64(":id")); err != nil {
 		if models.IsErrKeyAccessDenied(err) {
 		if models.IsErrKeyAccessDenied(err) {

+ 5 - 0
routes/api/v1/repo/label.go

@@ -14,6 +14,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// ListLabels list all the labels of a repository
 func ListLabels(c *context.APIContext) {
 func ListLabels(c *context.APIContext) {
 	labels, err := models.GetLabelsByRepoID(c.Repo.Repository.ID)
 	labels, err := models.GetLabelsByRepoID(c.Repo.Repository.ID)
 	if err != nil {
 	if err != nil {
@@ -28,6 +29,7 @@ func ListLabels(c *context.APIContext) {
 	c.JSON(200, &apiLabels)
 	c.JSON(200, &apiLabels)
 }
 }
 
 
+// GetLabel get label by repository and label id
 func GetLabel(c *context.APIContext) {
 func GetLabel(c *context.APIContext) {
 	var label *models.Label
 	var label *models.Label
 	var err error
 	var err error
@@ -49,6 +51,7 @@ func GetLabel(c *context.APIContext) {
 	c.JSON(200, label.APIFormat())
 	c.JSON(200, label.APIFormat())
 }
 }
 
 
+// CreateLabel create a label for a repository
 func CreateLabel(c *context.APIContext, form api.CreateLabelOption) {
 func CreateLabel(c *context.APIContext, form api.CreateLabelOption) {
 	if !c.Repo.IsWriter() {
 	if !c.Repo.IsWriter() {
 		c.Status(403)
 		c.Status(403)
@@ -67,6 +70,7 @@ func CreateLabel(c *context.APIContext, form api.CreateLabelOption) {
 	c.JSON(201, label.APIFormat())
 	c.JSON(201, label.APIFormat())
 }
 }
 
 
+// EditLabel modify a label for a repository
 func EditLabel(c *context.APIContext, form api.EditLabelOption) {
 func EditLabel(c *context.APIContext, form api.EditLabelOption) {
 	if !c.Repo.IsWriter() {
 	if !c.Repo.IsWriter() {
 		c.Status(403)
 		c.Status(403)
@@ -96,6 +100,7 @@ func EditLabel(c *context.APIContext, form api.EditLabelOption) {
 	c.JSON(200, label.APIFormat())
 	c.JSON(200, label.APIFormat())
 }
 }
 
 
+// DeleteLabel delete a label for a repository
 func DeleteLabel(c *context.APIContext) {
 func DeleteLabel(c *context.APIContext) {
 	if !c.Repo.IsWriter() {
 	if !c.Repo.IsWriter() {
 		c.Status(403)
 		c.Status(403)

+ 5 - 0
routes/api/v1/repo/milestone.go

@@ -14,6 +14,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// ListMilestones list all the opened milestones for a repository
 func ListMilestones(c *context.APIContext) {
 func ListMilestones(c *context.APIContext) {
 	milestones, err := models.GetMilestonesByRepoID(c.Repo.Repository.ID)
 	milestones, err := models.GetMilestonesByRepoID(c.Repo.Repository.ID)
 	if err != nil {
 	if err != nil {
@@ -28,6 +29,7 @@ func ListMilestones(c *context.APIContext) {
 	c.JSON(200, &apiMilestones)
 	c.JSON(200, &apiMilestones)
 }
 }
 
 
+// GetMilestone get a milestone for a repository
 func GetMilestone(c *context.APIContext) {
 func GetMilestone(c *context.APIContext) {
 	milestone, err := models.GetMilestoneByRepoID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
 	milestone, err := models.GetMilestoneByRepoID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
 	if err != nil {
 	if err != nil {
@@ -41,6 +43,7 @@ func GetMilestone(c *context.APIContext) {
 	c.JSON(200, milestone.APIFormat())
 	c.JSON(200, milestone.APIFormat())
 }
 }
 
 
+// CreateMilestone create a milestone for a repository
 func CreateMilestone(c *context.APIContext, form api.CreateMilestoneOption) {
 func CreateMilestone(c *context.APIContext, form api.CreateMilestoneOption) {
 	if form.Deadline == nil {
 	if form.Deadline == nil {
 		defaultDeadline, _ := time.ParseInLocation("2006-01-02", "9999-12-31", time.Local)
 		defaultDeadline, _ := time.ParseInLocation("2006-01-02", "9999-12-31", time.Local)
@@ -61,6 +64,7 @@ func CreateMilestone(c *context.APIContext, form api.CreateMilestoneOption) {
 	c.JSON(201, milestone.APIFormat())
 	c.JSON(201, milestone.APIFormat())
 }
 }
 
 
+// EditMilestone modify a milestone for a repository
 func EditMilestone(c *context.APIContext, form api.EditMilestoneOption) {
 func EditMilestone(c *context.APIContext, form api.EditMilestoneOption) {
 	milestone, err := models.GetMilestoneByRepoID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
 	milestone, err := models.GetMilestoneByRepoID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
 	if err != nil {
 	if err != nil {
@@ -95,6 +99,7 @@ func EditMilestone(c *context.APIContext, form api.EditMilestoneOption) {
 	c.JSON(200, milestone.APIFormat())
 	c.JSON(200, milestone.APIFormat())
 }
 }
 
 
+// DeleteMilestone delete a milestone for a repository
 func DeleteMilestone(c *context.APIContext) {
 func DeleteMilestone(c *context.APIContext) {
 	if err := models.DeleteMilestoneOfRepoByID(c.Repo.Repository.ID, c.ParamsInt64(":id")); err != nil {
 	if err := models.DeleteMilestoneOfRepoByID(c.Repo.Repository.ID, c.ParamsInt64(":id")); err != nil {
 		c.Error(500, "DeleteMilestoneByRepoID", err)
 		c.Error(500, "DeleteMilestoneByRepoID", err)

+ 12 - 0
routes/api/v1/repo/repo.go

@@ -20,6 +20,7 @@ import (
 	log "gopkg.in/clog.v1"
 	log "gopkg.in/clog.v1"
 )
 )
 
 
+// Search repositories via options
 func Search(c *context.APIContext) {
 func Search(c *context.APIContext) {
 	opts := &models.SearchRepoOptions{
 	opts := &models.SearchRepoOptions{
 		Keyword:  path.Base(c.Query("q")),
 		Keyword:  path.Base(c.Query("q")),
@@ -142,18 +143,22 @@ func listUserRepositories(c *context.APIContext, username string) {
 	c.JSON(200, &repos)
 	c.JSON(200, &repos)
 }
 }
 
 
+// ListMyRepos list the repositories you own or have access to.
 func ListMyRepos(c *context.APIContext) {
 func ListMyRepos(c *context.APIContext) {
 	listUserRepositories(c, c.User.Name)
 	listUserRepositories(c, c.User.Name)
 }
 }
 
 
+// ListUserRepositories list the repositories of an user.
 func ListUserRepositories(c *context.APIContext) {
 func ListUserRepositories(c *context.APIContext) {
 	listUserRepositories(c, c.Params(":username"))
 	listUserRepositories(c, c.Params(":username"))
 }
 }
 
 
+// ListOrgRepositories list the repositories of an organization.
 func ListOrgRepositories(c *context.APIContext) {
 func ListOrgRepositories(c *context.APIContext) {
 	listUserRepositories(c, c.Params(":org"))
 	listUserRepositories(c, c.Params(":org"))
 }
 }
 
 
+// CreateUserRepo create a repository for a user
 func CreateUserRepo(c *context.APIContext, owner *models.User, opt api.CreateRepoOption) {
 func CreateUserRepo(c *context.APIContext, owner *models.User, opt api.CreateRepoOption) {
 	repo, err := models.CreateRepository(c.User, owner, models.CreateRepoOptions{
 	repo, err := models.CreateRepository(c.User, owner, models.CreateRepoOptions{
 		Name:        opt.Name,
 		Name:        opt.Name,
@@ -184,6 +189,7 @@ func CreateUserRepo(c *context.APIContext, owner *models.User, opt api.CreateRep
 	c.JSON(201, repo.APIFormat(&api.Permission{true, true, true}))
 	c.JSON(201, repo.APIFormat(&api.Permission{true, true, true}))
 }
 }
 
 
+// Create one repository of mine
 func Create(c *context.APIContext, opt api.CreateRepoOption) {
 func Create(c *context.APIContext, opt api.CreateRepoOption) {
 	// Shouldn't reach this condition, but just in case.
 	// Shouldn't reach this condition, but just in case.
 	if c.User.IsOrganization() {
 	if c.User.IsOrganization() {
@@ -193,6 +199,7 @@ func Create(c *context.APIContext, opt api.CreateRepoOption) {
 	CreateUserRepo(c, c.User, opt)
 	CreateUserRepo(c, c.User, opt)
 }
 }
 
 
+// CreateOrgRepo create one repository of the organization
 func CreateOrgRepo(c *context.APIContext, opt api.CreateRepoOption) {
 func CreateOrgRepo(c *context.APIContext, opt api.CreateRepoOption) {
 	org, err := models.GetOrgByName(c.Params(":org"))
 	org, err := models.GetOrgByName(c.Params(":org"))
 	if err != nil {
 	if err != nil {
@@ -211,6 +218,7 @@ func CreateOrgRepo(c *context.APIContext, opt api.CreateRepoOption) {
 	CreateUserRepo(c, org, opt)
 	CreateUserRepo(c, org, opt)
 }
 }
 
 
+// Migrate migrate remote git repository to Gitote
 func Migrate(c *context.APIContext, f form.MigrateRepo) {
 func Migrate(c *context.APIContext, f form.MigrateRepo) {
 	ctxUser := c.User
 	ctxUser := c.User
 	// Not equal means context user is an organization,
 	// Not equal means context user is an organization,
@@ -315,6 +323,7 @@ func parseOwnerAndRepo(c *context.APIContext) (*models.User, *models.Repository)
 	return owner, repo
 	return owner, repo
 }
 }
 
 
+// Get one repository
 func Get(c *context.APIContext) {
 func Get(c *context.APIContext) {
 	_, repo := parseOwnerAndRepo(c)
 	_, repo := parseOwnerAndRepo(c)
 	if c.Written() {
 	if c.Written() {
@@ -328,6 +337,7 @@ func Get(c *context.APIContext) {
 	}))
 	}))
 }
 }
 
 
+// Delete one repository
 func Delete(c *context.APIContext) {
 func Delete(c *context.APIContext) {
 	owner, repo := parseOwnerAndRepo(c)
 	owner, repo := parseOwnerAndRepo(c)
 	if c.Written() {
 	if c.Written() {
@@ -348,6 +358,7 @@ func Delete(c *context.APIContext) {
 	c.Status(204)
 	c.Status(204)
 }
 }
 
 
+// ListForks list a repository's forks
 func ListForks(c *context.APIContext) {
 func ListForks(c *context.APIContext) {
 	forks, err := c.Repo.Repository.GetForks()
 	forks, err := c.Repo.Repository.GetForks()
 	if err != nil {
 	if err != nil {
@@ -371,6 +382,7 @@ func ListForks(c *context.APIContext) {
 	c.JSON(200, &apiForks)
 	c.JSON(200, &apiForks)
 }
 }
 
 
+// MirrorSync adds a mirrored repository to the sync queue
 func MirrorSync(c *context.APIContext) {
 func MirrorSync(c *context.APIContext) {
 	_, repo := parseOwnerAndRepo(c)
 	_, repo := parseOwnerAndRepo(c)
 	if c.Written() {
 	if c.Written() {

+ 2 - 0
routes/api/v1/user/app.go

@@ -13,6 +13,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// ListAccessTokens list all the access tokens
 func ListAccessTokens(c *context.APIContext) {
 func ListAccessTokens(c *context.APIContext) {
 	tokens, err := models.ListAccessTokens(c.User.ID)
 	tokens, err := models.ListAccessTokens(c.User.ID)
 	if err != nil {
 	if err != nil {
@@ -27,6 +28,7 @@ func ListAccessTokens(c *context.APIContext) {
 	c.JSON(200, &apiTokens)
 	c.JSON(200, &apiTokens)
 }
 }
 
 
+// CreateAccessToken create access tokens
 func CreateAccessToken(c *context.APIContext, form api.CreateAccessTokenOption) {
 func CreateAccessToken(c *context.APIContext, form api.CreateAccessTokenOption) {
 	t := &models.AccessToken{
 	t := &models.AccessToken{
 		UID:  c.User.ID,
 		UID:  c.User.ID,

+ 3 - 0
routes/api/v1/user/email.go

@@ -15,6 +15,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// ListEmails list all of the authenticated user's email addresses
 func ListEmails(c *context.APIContext) {
 func ListEmails(c *context.APIContext) {
 	emails, err := models.GetEmailAddresses(c.User.ID)
 	emails, err := models.GetEmailAddresses(c.User.ID)
 	if err != nil {
 	if err != nil {
@@ -28,6 +29,7 @@ func ListEmails(c *context.APIContext) {
 	c.JSON(200, &apiEmails)
 	c.JSON(200, &apiEmails)
 }
 }
 
 
+// AddEmail add an email address
 func AddEmail(c *context.APIContext, form api.CreateEmailOption) {
 func AddEmail(c *context.APIContext, form api.CreateEmailOption) {
 	if len(form.Emails) == 0 {
 	if len(form.Emails) == 0 {
 		c.Status(422)
 		c.Status(422)
@@ -59,6 +61,7 @@ func AddEmail(c *context.APIContext, form api.CreateEmailOption) {
 	c.JSON(201, &apiEmails)
 	c.JSON(201, &apiEmails)
 }
 }
 
 
+// DeleteEmail delete email
 func DeleteEmail(c *context.APIContext, form api.CreateEmailOption) {
 func DeleteEmail(c *context.APIContext, form api.CreateEmailOption) {
 	if len(form.Emails) == 0 {
 	if len(form.Emails) == 0 {
 		c.Status(204)
 		c.Status(204)

+ 11 - 3
routes/api/v1/user/follower.go

@@ -13,7 +13,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
-func responseApiUsers(c *context.APIContext, users []*models.User) {
+func responseAPIUsers(c *context.APIContext, users []*models.User) {
 	apiUsers := make([]*api.User, len(users))
 	apiUsers := make([]*api.User, len(users))
 	for i := range users {
 	for i := range users {
 		apiUsers[i] = users[i].APIFormat()
 		apiUsers[i] = users[i].APIFormat()
@@ -27,13 +27,15 @@ func listUserFollowers(c *context.APIContext, u *models.User) {
 		c.Error(500, "GetUserFollowers", err)
 		c.Error(500, "GetUserFollowers", err)
 		return
 		return
 	}
 	}
-	responseApiUsers(c, users)
+	responseAPIUsers(c, users)
 }
 }
 
 
+// ListMyFollowers list the authenticated user's followers
 func ListMyFollowers(c *context.APIContext) {
 func ListMyFollowers(c *context.APIContext) {
 	listUserFollowers(c, c.User)
 	listUserFollowers(c, c.User)
 }
 }
 
 
+// ListFollowers list the given user's followers
 func ListFollowers(c *context.APIContext) {
 func ListFollowers(c *context.APIContext) {
 	u := GetUserByParams(c)
 	u := GetUserByParams(c)
 	if c.Written() {
 	if c.Written() {
@@ -48,13 +50,15 @@ func listUserFollowing(c *context.APIContext, u *models.User) {
 		c.Error(500, "GetFollowing", err)
 		c.Error(500, "GetFollowing", err)
 		return
 		return
 	}
 	}
-	responseApiUsers(c, users)
+	responseAPIUsers(c, users)
 }
 }
 
 
+// ListMyFollowing list the users that the authenticated user is following
 func ListMyFollowing(c *context.APIContext) {
 func ListMyFollowing(c *context.APIContext) {
 	listUserFollowing(c, c.User)
 	listUserFollowing(c, c.User)
 }
 }
 
 
+// ListFollowing list the users that the given user is following
 func ListFollowing(c *context.APIContext) {
 func ListFollowing(c *context.APIContext) {
 	u := GetUserByParams(c)
 	u := GetUserByParams(c)
 	if c.Written() {
 	if c.Written() {
@@ -71,6 +75,7 @@ func checkUserFollowing(c *context.APIContext, u *models.User, followID int64) {
 	}
 	}
 }
 }
 
 
+// CheckMyFollowing whether the given user is followed by the authenticated user
 func CheckMyFollowing(c *context.APIContext) {
 func CheckMyFollowing(c *context.APIContext) {
 	target := GetUserByParams(c)
 	target := GetUserByParams(c)
 	if c.Written() {
 	if c.Written() {
@@ -79,6 +84,7 @@ func CheckMyFollowing(c *context.APIContext) {
 	checkUserFollowing(c, c.User, target.ID)
 	checkUserFollowing(c, c.User, target.ID)
 }
 }
 
 
+// CheckFollowing check if one user is following another user
 func CheckFollowing(c *context.APIContext) {
 func CheckFollowing(c *context.APIContext) {
 	u := GetUserByParams(c)
 	u := GetUserByParams(c)
 	if c.Written() {
 	if c.Written() {
@@ -91,6 +97,7 @@ func CheckFollowing(c *context.APIContext) {
 	checkUserFollowing(c, u, target.ID)
 	checkUserFollowing(c, u, target.ID)
 }
 }
 
 
+// Follow follow a user
 func Follow(c *context.APIContext) {
 func Follow(c *context.APIContext) {
 	target := GetUserByParams(c)
 	target := GetUserByParams(c)
 	if c.Written() {
 	if c.Written() {
@@ -103,6 +110,7 @@ func Follow(c *context.APIContext) {
 	c.Status(204)
 	c.Status(204)
 }
 }
 
 
+// Unfollow unfollow a user
 func Unfollow(c *context.APIContext) {
 func Unfollow(c *context.APIContext) {
 	target := GetUserByParams(c)
 	target := GetUserByParams(c)
 	if c.Written() {
 	if c.Written() {

+ 6 - 0
routes/api/v1/user/key.go

@@ -17,6 +17,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// GetUserByParamsName get user by name
 func GetUserByParamsName(c *context.APIContext, name string) *models.User {
 func GetUserByParamsName(c *context.APIContext, name string) *models.User {
 	user, err := models.GetUserByName(c.Params(name))
 	user, err := models.GetUserByName(c.Params(name))
 	if err != nil {
 	if err != nil {
@@ -55,10 +56,12 @@ func listPublicKeys(c *context.APIContext, uid int64) {
 	c.JSON(200, &apiKeys)
 	c.JSON(200, &apiKeys)
 }
 }
 
 
+// ListMyPublicKeys list all of the authenticated user's public keys
 func ListMyPublicKeys(c *context.APIContext) {
 func ListMyPublicKeys(c *context.APIContext) {
 	listPublicKeys(c, c.User.ID)
 	listPublicKeys(c, c.User.ID)
 }
 }
 
 
+// ListPublicKeys list the given user's public keys
 func ListPublicKeys(c *context.APIContext) {
 func ListPublicKeys(c *context.APIContext) {
 	user := GetUserByParams(c)
 	user := GetUserByParams(c)
 	if c.Written() {
 	if c.Written() {
@@ -67,6 +70,7 @@ func ListPublicKeys(c *context.APIContext) {
 	listPublicKeys(c, user.ID)
 	listPublicKeys(c, user.ID)
 }
 }
 
 
+// GetPublicKey get a public key
 func GetPublicKey(c *context.APIContext) {
 func GetPublicKey(c *context.APIContext) {
 	key, err := models.GetPublicKeyByID(c.ParamsInt64(":id"))
 	key, err := models.GetPublicKeyByID(c.ParamsInt64(":id"))
 	if err != nil {
 	if err != nil {
@@ -99,10 +103,12 @@ func CreateUserPublicKey(c *context.APIContext, form api.CreateKeyOption, uid in
 	c.JSON(201, convert.ToPublicKey(apiLink, key))
 	c.JSON(201, convert.ToPublicKey(apiLink, key))
 }
 }
 
 
+// CreatePublicKey create one public key for me
 func CreatePublicKey(c *context.APIContext, form api.CreateKeyOption) {
 func CreatePublicKey(c *context.APIContext, form api.CreateKeyOption) {
 	CreateUserPublicKey(c, form, c.User.ID)
 	CreateUserPublicKey(c, form, c.User.ID)
 }
 }
 
 
+// DeletePublicKey delete one public key
 func DeletePublicKey(c *context.APIContext) {
 func DeletePublicKey(c *context.APIContext) {
 	if err := models.DeletePublicKey(c.User, c.ParamsInt64(":id")); err != nil {
 	if err := models.DeletePublicKey(c.User, c.ParamsInt64(":id")); err != nil {
 		if models.IsErrKeyAccessDenied(err) {
 		if models.IsErrKeyAccessDenied(err) {

+ 3 - 0
routes/api/v1/user/user.go

@@ -16,6 +16,7 @@ import (
 	api "gitlab.com/gitote/go-gitote-client"
 	api "gitlab.com/gitote/go-gitote-client"
 )
 )
 
 
+// Search search users
 func Search(c *context.APIContext) {
 func Search(c *context.APIContext) {
 	opts := &models.SearchUserOptions{
 	opts := &models.SearchUserOptions{
 		Keyword:  c.Query("q"),
 		Keyword:  c.Query("q"),
@@ -54,6 +55,7 @@ func Search(c *context.APIContext) {
 	})
 	})
 }
 }
 
 
+// GetInfo get user's information
 func GetInfo(c *context.APIContext) {
 func GetInfo(c *context.APIContext) {
 	u, err := models.GetUserByName(c.Params(":username"))
 	u, err := models.GetUserByName(c.Params(":username"))
 	if err != nil {
 	if err != nil {
@@ -72,6 +74,7 @@ func GetInfo(c *context.APIContext) {
 	c.JSON(200, u.APIFormat())
 	c.JSON(200, u.APIFormat())
 }
 }
 
 
+// GetAuthenticatedUser get current user's information
 func GetAuthenticatedUser(c *context.APIContext) {
 func GetAuthenticatedUser(c *context.APIContext) {
 	c.JSON(200, c.User.APIFormat())
 	c.JSON(200, c.User.APIFormat())
 }
 }

+ 1 - 1
routes/org/setting.go

@@ -175,7 +175,7 @@ func Webhooks(c *context.Context) {
 	c.HTML(200, SettingsWebhooksTPL)
 	c.HTML(200, SettingsWebhooksTPL)
 }
 }
 
 
-// DeleteWbhook deletes an organization webhook
+// DeleteWebhook deletes an organization webhook
 func DeleteWebhook(c *context.Context) {
 func DeleteWebhook(c *context.Context) {
 
 
 	// Delete the webhook
 	// Delete the webhook

+ 6 - 0
routes/repo/commit.go

@@ -25,6 +25,7 @@ const (
 	DiffTPL = "repo/diff/page"
 	DiffTPL = "repo/diff/page"
 )
 )
 
 
+// RefCommits render commits page
 func RefCommits(c *context.Context) {
 func RefCommits(c *context.Context) {
 	c.Data["PageIsViewFiles"] = true
 	c.Data["PageIsViewFiles"] = true
 	switch {
 	switch {
@@ -37,6 +38,7 @@ func RefCommits(c *context.Context) {
 	}
 	}
 }
 }
 
 
+// RenderIssueLinks render issue links
 func RenderIssueLinks(oldCommits *list.List, repoLink string) *list.List {
 func RenderIssueLinks(oldCommits *list.List, repoLink string) *list.List {
 	newCommits := list.New()
 	newCommits := list.New()
 	for e := oldCommits.Front(); e != nil; e = e.Next() {
 	for e := oldCommits.Front(); e != nil; e = e.Next() {
@@ -92,6 +94,7 @@ func renderCommits(c *context.Context, filename string) {
 	c.HTML(200, CommitsTPL)
 	c.HTML(200, CommitsTPL)
 }
 }
 
 
+// Commits render branch's commits
 func Commits(c *context.Context) {
 func Commits(c *context.Context) {
 	renderCommits(c, "")
 	renderCommits(c, "")
 }
 }
@@ -122,6 +125,7 @@ func SearchCommits(c *context.Context) {
 	c.HTML(200, CommitsTPL)
 	c.HTML(200, CommitsTPL)
 }
 }
 
 
+// FileHistory show a file's reversions
 func FileHistory(c *context.Context) {
 func FileHistory(c *context.Context) {
 	renderCommits(c, c.Repo.TreePath)
 	renderCommits(c, c.Repo.TreePath)
 }
 }
@@ -182,6 +186,7 @@ func Diff(c *context.Context) {
 	c.Success(DiffTPL)
 	c.Success(DiffTPL)
 }
 }
 
 
+// RawDiff dumps diff results of repository in given commit ID to io.Writer
 func RawDiff(c *context.Context) {
 func RawDiff(c *context.Context) {
 	if err := git.GetRawDiff(
 	if err := git.GetRawDiff(
 		models.RepoPath(c.Repo.Owner.Name, c.Repo.Repository.Name),
 		models.RepoPath(c.Repo.Owner.Name, c.Repo.Repository.Name),
@@ -194,6 +199,7 @@ func RawDiff(c *context.Context) {
 	}
 	}
 }
 }
 
 
+// CompareDiff show different from one commit to another commit
 func CompareDiff(c *context.Context) {
 func CompareDiff(c *context.Context) {
 	c.Data["IsDiffCompare"] = true
 	c.Data["IsDiffCompare"] = true
 	userName := c.Repo.Owner.Name
 	userName := c.Repo.Owner.Name

+ 3 - 0
routes/repo/download.go

@@ -16,6 +16,7 @@ import (
 	"gitlab.com/gitote/git-module"
 	"gitlab.com/gitote/git-module"
 )
 )
 
 
+// ServeData download file from io.Reader
 func ServeData(c *context.Context, name string, reader io.Reader) error {
 func ServeData(c *context.Context, name string, reader io.Reader) error {
 	buf := make([]byte, 1024)
 	buf := make([]byte, 1024)
 	n, _ := reader.Read(buf)
 	n, _ := reader.Read(buf)
@@ -36,6 +37,7 @@ func ServeData(c *context.Context, name string, reader io.Reader) error {
 	return err
 	return err
 }
 }
 
 
+// ServeBlob download a git.Blob
 func ServeBlob(c *context.Context, blob *git.Blob) error {
 func ServeBlob(c *context.Context, blob *git.Blob) error {
 	dataRc, err := blob.Data()
 	dataRc, err := blob.Data()
 	if err != nil {
 	if err != nil {
@@ -45,6 +47,7 @@ func ServeBlob(c *context.Context, blob *git.Blob) error {
 	return ServeData(c, path.Base(c.Repo.TreePath), dataRc)
 	return ServeData(c, path.Base(c.Repo.TreePath), dataRc)
 }
 }
 
 
+// SingleDownload download a file by repos path
 func SingleDownload(c *context.Context) {
 func SingleDownload(c *context.Context) {
 	blob, err := c.Repo.Commit.GetBlobByPath(c.Repo.TreePath)
 	blob, err := c.Repo.Commit.GetBlobByPath(c.Repo.TreePath)
 	if err != nil {
 	if err != nil {

+ 2 - 0
routes/repo/editor.go

@@ -531,6 +531,7 @@ func UploadFilePost(c *context.Context, f form.UploadRepoFile) {
 	}
 	}
 }
 }
 
 
+// UploadFileToServer upload file to server file dir not git
 func UploadFileToServer(c *context.Context) {
 func UploadFileToServer(c *context.Context) {
 	file, header, err := c.Req.FormFile("file")
 	file, header, err := c.Req.FormFile("file")
 	if err != nil {
 	if err != nil {
@@ -574,6 +575,7 @@ func UploadFileToServer(c *context.Context) {
 	})
 	})
 }
 }
 
 
+// RemoveUploadFileFromServer remove file from server file dir
 func RemoveUploadFileFromServer(c *context.Context, f form.RemoveUploadFile) {
 func RemoveUploadFileFromServer(c *context.Context, f form.RemoveUploadFile) {
 	if len(f.File) == 0 {
 	if len(f.File) == 0 {
 		c.Status(204)
 		c.Status(204)

+ 1 - 0
routes/repo/http.go

@@ -381,6 +381,7 @@ func getGitRepoPath(dir string) (string, error) {
 	return filename, nil
 	return filename, nil
 }
 }
 
 
+// HTTP implmentation git smart HTTP protocol
 func HTTP(c *HTTPContext) {
 func HTTP(c *HTTPContext) {
 	for _, route := range routes {
 	for _, route := range routes {
 		reqPath := strings.ToLower(c.Req.URL.Path)
 		reqPath := strings.ToLower(c.Req.URL.Path)

+ 37 - 3
routes/repo/issue.go

@@ -56,9 +56,13 @@ const (
 )
 )
 
 
 var (
 var (
+	// ErrFileTypeForbidden not allowed file type error
 	ErrFileTypeForbidden = errors.New("File type is not allowed")
 	ErrFileTypeForbidden = errors.New("File type is not allowed")
-	ErrTooManyFiles      = errors.New("Maximum number of files to upload exceeded")
 
 
+	// ErrTooManyFiles upload too many files
+	ErrTooManyFiles = errors.New("Maximum number of files to upload exceeded")
+
+	// IssueTemplateCandidates issue templates
 	IssueTemplateCandidates = []string{
 	IssueTemplateCandidates = []string{
 		"ISSUE_TEMPLATE.md",
 		"ISSUE_TEMPLATE.md",
 		".gitote/ISSUE_TEMPLATE.md",
 		".gitote/ISSUE_TEMPLATE.md",
@@ -66,6 +70,7 @@ var (
 	}
 	}
 )
 )
 
 
+// MustEnableIssues check if repository enable internal issues
 func MustEnableIssues(c *context.Context) {
 func MustEnableIssues(c *context.Context) {
 	if !c.Repo.Repository.EnableIssues {
 	if !c.Repo.Repository.EnableIssues {
 		c.Handle(404, "MustEnableIssues", nil)
 		c.Handle(404, "MustEnableIssues", nil)
@@ -78,6 +83,7 @@ func MustEnableIssues(c *context.Context) {
 	}
 	}
 }
 }
 
 
+// MustAllowPulls check if repository enable pull requests and user have right to do that
 func MustAllowPulls(c *context.Context) {
 func MustAllowPulls(c *context.Context) {
 	if !c.Repo.Repository.AllowsPulls() {
 	if !c.Repo.Repository.AllowsPulls() {
 		c.Handle(404, "MustAllowPulls", nil)
 		c.Handle(404, "MustAllowPulls", nil)
@@ -91,6 +97,7 @@ func MustAllowPulls(c *context.Context) {
 	}
 	}
 }
 }
 
 
+// RetrieveLabels find all the labels of a repository
 func RetrieveLabels(c *context.Context) {
 func RetrieveLabels(c *context.Context) {
 	labels, err := models.GetLabelsByRepoID(c.Repo.Repository.ID)
 	labels, err := models.GetLabelsByRepoID(c.Repo.Repository.ID)
 	if err != nil {
 	if err != nil {
@@ -264,10 +271,12 @@ func issues(c *context.Context, isPullList bool) {
 	c.HTML(200, IssuesTPL)
 	c.HTML(200, IssuesTPL)
 }
 }
 
 
+// Issues render issues page
 func Issues(c *context.Context) {
 func Issues(c *context.Context) {
 	issues(c, false)
 	issues(c, false)
 }
 }
 
 
+// Pulls render pull request page
 func Pulls(c *context.Context) {
 func Pulls(c *context.Context) {
 	issues(c, true)
 	issues(c, true)
 }
 }
@@ -280,6 +289,7 @@ func renderAttachmentSettings(c *context.Context) {
 	c.Data["AttachmentMaxFiles"] = setting.AttachmentMaxFiles
 	c.Data["AttachmentMaxFiles"] = setting.AttachmentMaxFiles
 }
 }
 
 
+// RetrieveRepoMilestonesAndAssignees find all the milestones and assignees of a repository
 func RetrieveRepoMilestonesAndAssignees(c *context.Context, repo *models.Repository) {
 func RetrieveRepoMilestonesAndAssignees(c *context.Context, repo *models.Repository) {
 	var err error
 	var err error
 	c.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false)
 	c.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false)
@@ -300,6 +310,7 @@ func RetrieveRepoMilestonesAndAssignees(c *context.Context, repo *models.Reposit
 	}
 	}
 }
 }
 
 
+// RetrieveRepoMetas find all the meta information of a repository
 func RetrieveRepoMetas(c *context.Context, repo *models.Repository) []*models.Label {
 func RetrieveRepoMetas(c *context.Context, repo *models.Repository) []*models.Label {
 	if !c.Repo.IsWriter() {
 	if !c.Repo.IsWriter() {
 		return nil
 		return nil
@@ -357,6 +368,7 @@ func setTemplateIfExists(c *context.Context, ctxDataKey string, possibleFiles []
 	}
 	}
 }
 }
 
 
+// NewIssue render createing issue page
 func NewIssue(c *context.Context) {
 func NewIssue(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.issues.new")
 	c.Data["Title"] = c.Tr("repo.issues.new")
 	c.Data["PageIsIssueList"] = true
 	c.Data["PageIsIssueList"] = true
@@ -375,6 +387,7 @@ func NewIssue(c *context.Context) {
 	c.HTML(200, IssuesNewTPL)
 	c.HTML(200, IssuesNewTPL)
 }
 }
 
 
+// ValidateRepoMetas check and returns repository's meta informations
 func ValidateRepoMetas(c *context.Context, f form.NewIssue) ([]int64, int64, int64) {
 func ValidateRepoMetas(c *context.Context, f form.NewIssue) ([]int64, int64, int64) {
 	var (
 	var (
 		repo = c.Repo.Repository
 		repo = c.Repo.Repository
@@ -511,6 +524,7 @@ func uploadAttachment(c *context.Context, allowedTypes []string) {
 	})
 	})
 }
 }
 
 
+// UploadIssueAttachment response for uploading issue's attachment
 func UploadIssueAttachment(c *context.Context) {
 func UploadIssueAttachment(c *context.Context) {
 	if !setting.AttachmentEnabled {
 	if !setting.AttachmentEnabled {
 		c.NotFound()
 		c.NotFound()
@@ -678,8 +692,8 @@ func viewIssue(c *context.Context, isPullList bool) {
 			c.Repo.IsWriter() && c.Repo.GitRepo.IsBranchExist(pull.HeadBranch) &&
 			c.Repo.IsWriter() && c.Repo.GitRepo.IsBranchExist(pull.HeadBranch) &&
 			!branchProtected
 			!branchProtected
 
 
-		deleteBranchUrl := template.EscapePound(c.Repo.RepoLink + "/branches/delete/" + pull.HeadBranch)
-		c.Data["DeleteBranchLink"] = fmt.Sprintf("%s?commit=%s&redirect_to=%s", deleteBranchUrl, pull.MergedCommitID, c.Data["Link"])
+		deleteBranchURL := template.EscapePound(c.Repo.RepoLink + "/branches/delete/" + pull.HeadBranch)
+		c.Data["DeleteBranchLink"] = fmt.Sprintf("%s?commit=%s&redirect_to=%s", deleteBranchURL, pull.MergedCommitID, c.Data["Link"])
 	}
 	}
 
 
 	c.Data["Participants"] = participants
 	c.Data["Participants"] = participants
@@ -690,11 +704,13 @@ func viewIssue(c *context.Context, isPullList bool) {
 	c.HTML(200, IssuesViewTPL)
 	c.HTML(200, IssuesViewTPL)
 }
 }
 
 
+// ViewIssue render issue view page
 func ViewIssue(c *context.Context) {
 func ViewIssue(c *context.Context) {
 	c.Data["PageIsIssueConversation"] = true
 	c.Data["PageIsIssueConversation"] = true
 	viewIssue(c, false)
 	viewIssue(c, false)
 }
 }
 
 
+// ViewPull render pull view page
 func ViewPull(c *context.Context) {
 func ViewPull(c *context.Context) {
 	viewIssue(c, true)
 	viewIssue(c, true)
 }
 }
@@ -715,6 +731,7 @@ func getActionIssue(c *context.Context) *models.Issue {
 	return issue
 	return issue
 }
 }
 
 
+// UpdateIssueTitle change issue's title
 func UpdateIssueTitle(c *context.Context) {
 func UpdateIssueTitle(c *context.Context) {
 	issue := getActionIssue(c)
 	issue := getActionIssue(c)
 	if c.Written() {
 	if c.Written() {
@@ -742,6 +759,7 @@ func UpdateIssueTitle(c *context.Context) {
 	})
 	})
 }
 }
 
 
+// UpdateIssueContent change issue's content
 func UpdateIssueContent(c *context.Context) {
 func UpdateIssueContent(c *context.Context) {
 	issue := getActionIssue(c)
 	issue := getActionIssue(c)
 	if c.Written() {
 	if c.Written() {
@@ -764,6 +782,7 @@ func UpdateIssueContent(c *context.Context) {
 	})
 	})
 }
 }
 
 
+// UpdateIssueLabel change issue's labels
 func UpdateIssueLabel(c *context.Context) {
 func UpdateIssueLabel(c *context.Context) {
 	issue := getActionIssue(c)
 	issue := getActionIssue(c)
 	if c.Written() {
 	if c.Written() {
@@ -805,6 +824,7 @@ func UpdateIssueLabel(c *context.Context) {
 	})
 	})
 }
 }
 
 
+// UpdateIssueMilestone change issue's milestone
 func UpdateIssueMilestone(c *context.Context) {
 func UpdateIssueMilestone(c *context.Context) {
 	issue := getActionIssue(c)
 	issue := getActionIssue(c)
 	if c.Written() {
 	if c.Written() {
@@ -832,6 +852,7 @@ func UpdateIssueMilestone(c *context.Context) {
 	})
 	})
 }
 }
 
 
+// UpdateIssueAssignee change issue's assignee
 func UpdateIssueAssignee(c *context.Context) {
 func UpdateIssueAssignee(c *context.Context) {
 	issue := getActionIssue(c)
 	issue := getActionIssue(c)
 	if c.Written() {
 	if c.Written() {
@@ -856,6 +877,7 @@ func UpdateIssueAssignee(c *context.Context) {
 	})
 	})
 }
 }
 
 
+// NewComment create a comment for issue
 func NewComment(c *context.Context, f form.CreateComment) {
 func NewComment(c *context.Context, f form.CreateComment) {
 	issue := getActionIssue(c)
 	issue := getActionIssue(c)
 	if c.Written() {
 	if c.Written() {
@@ -943,6 +965,7 @@ func NewComment(c *context.Context, f form.CreateComment) {
 	log.Trace("Comment created: %d/%d/%d", c.Repo.Repository.ID, issue.ID, comment.ID)
 	log.Trace("Comment created: %d/%d/%d", c.Repo.Repository.ID, issue.ID, comment.ID)
 }
 }
 
 
+// UpdateCommentContent change comment of issue's content
 func UpdateCommentContent(c *context.Context) {
 func UpdateCommentContent(c *context.Context) {
 	comment, err := models.GetCommentByID(c.ParamsInt64(":id"))
 	comment, err := models.GetCommentByID(c.ParamsInt64(":id"))
 	if err != nil {
 	if err != nil {
@@ -976,6 +999,7 @@ func UpdateCommentContent(c *context.Context) {
 	})
 	})
 }
 }
 
 
+// DeleteComment delete comment of issue
 func DeleteComment(c *context.Context) {
 func DeleteComment(c *context.Context) {
 	comment, err := models.GetCommentByID(c.ParamsInt64(":id"))
 	comment, err := models.GetCommentByID(c.ParamsInt64(":id"))
 	if err != nil {
 	if err != nil {
@@ -999,6 +1023,7 @@ func DeleteComment(c *context.Context) {
 	c.Status(200)
 	c.Status(200)
 }
 }
 
 
+// Labels render issue's labels page
 func Labels(c *context.Context) {
 func Labels(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.labels")
 	c.Data["Title"] = c.Tr("repo.labels")
 	c.Data["PageIsIssueList"] = true
 	c.Data["PageIsIssueList"] = true
@@ -1008,6 +1033,7 @@ func Labels(c *context.Context) {
 	c.HTML(200, LabelsTPL)
 	c.HTML(200, LabelsTPL)
 }
 }
 
 
+// InitializeLabels init labels for a repository
 func InitializeLabels(c *context.Context, f form.InitializeLabels) {
 func InitializeLabels(c *context.Context, f form.InitializeLabels) {
 	if c.HasError() {
 	if c.HasError() {
 		c.Redirect(c.Repo.RepoLink + "/labels")
 		c.Redirect(c.Repo.RepoLink + "/labels")
@@ -1035,6 +1061,7 @@ func InitializeLabels(c *context.Context, f form.InitializeLabels) {
 	c.Redirect(c.Repo.RepoLink + "/labels")
 	c.Redirect(c.Repo.RepoLink + "/labels")
 }
 }
 
 
+// NewLabel create new label for repository
 func NewLabel(c *context.Context, f form.CreateLabel) {
 func NewLabel(c *context.Context, f form.CreateLabel) {
 	c.Data["Title"] = c.Tr("repo.labels")
 	c.Data["Title"] = c.Tr("repo.labels")
 	c.Data["PageIsLabels"] = true
 	c.Data["PageIsLabels"] = true
@@ -1057,6 +1084,7 @@ func NewLabel(c *context.Context, f form.CreateLabel) {
 	c.Redirect(c.Repo.RepoLink + "/labels")
 	c.Redirect(c.Repo.RepoLink + "/labels")
 }
 }
 
 
+// UpdateLabel update a label's name and color
 func UpdateLabel(c *context.Context, f form.CreateLabel) {
 func UpdateLabel(c *context.Context, f form.CreateLabel) {
 	l, err := models.GetLabelByID(f.ID)
 	l, err := models.GetLabelByID(f.ID)
 	if err != nil {
 	if err != nil {
@@ -1078,6 +1106,7 @@ func UpdateLabel(c *context.Context, f form.CreateLabel) {
 	c.Redirect(c.Repo.RepoLink + "/labels")
 	c.Redirect(c.Repo.RepoLink + "/labels")
 }
 }
 
 
+// DeleteLabel delete a label
 func DeleteLabel(c *context.Context) {
 func DeleteLabel(c *context.Context) {
 	if err := models.DeleteLabel(c.Repo.Repository.ID, c.QueryInt64("id")); err != nil {
 	if err := models.DeleteLabel(c.Repo.Repository.ID, c.QueryInt64("id")); err != nil {
 		c.Flash.Error("DeleteLabel: " + err.Error())
 		c.Flash.Error("DeleteLabel: " + err.Error())
@@ -1091,6 +1120,7 @@ func DeleteLabel(c *context.Context) {
 	return
 	return
 }
 }
 
 
+// Milestones render milestones page
 func Milestones(c *context.Context) {
 func Milestones(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.milestones")
 	c.Data["Title"] = c.Tr("repo.milestones")
 	c.Data["PageIsIssueList"] = true
 	c.Data["PageIsIssueList"] = true
@@ -1139,6 +1169,7 @@ func Milestones(c *context.Context) {
 	c.HTML(200, MilestoneTPL)
 	c.HTML(200, MilestoneTPL)
 }
 }
 
 
+// NewMilestone render creating milestone page
 func NewMilestone(c *context.Context) {
 func NewMilestone(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.milestones.new")
 	c.Data["Title"] = c.Tr("repo.milestones.new")
 	c.Data["PageIsIssueList"] = true
 	c.Data["PageIsIssueList"] = true
@@ -1185,6 +1216,7 @@ func NewMilestonePost(c *context.Context, f form.CreateMilestone) {
 	c.Redirect(c.Repo.RepoLink + "/milestones")
 	c.Redirect(c.Repo.RepoLink + "/milestones")
 }
 }
 
 
+// EditMilestone render edting milestone page
 func EditMilestone(c *context.Context) {
 func EditMilestone(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.milestones.edit")
 	c.Data["Title"] = c.Tr("repo.milestones.edit")
 	c.Data["PageIsMilestones"] = true
 	c.Data["PageIsMilestones"] = true
@@ -1253,6 +1285,7 @@ func EditMilestonePost(c *context.Context, f form.CreateMilestone) {
 	c.Redirect(c.Repo.RepoLink + "/milestones")
 	c.Redirect(c.Repo.RepoLink + "/milestones")
 }
 }
 
 
+// ChangeMilestonStatus response for change a milestone's status
 func ChangeMilestonStatus(c *context.Context) {
 func ChangeMilestonStatus(c *context.Context) {
 	m, err := models.GetMilestoneByRepoID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
 	m, err := models.GetMilestoneByRepoID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
 	if err != nil {
 	if err != nil {
@@ -1287,6 +1320,7 @@ func ChangeMilestonStatus(c *context.Context) {
 	}
 	}
 }
 }
 
 
+// DeleteMilestone delete a milestone
 func DeleteMilestone(c *context.Context) {
 func DeleteMilestone(c *context.Context) {
 	if err := models.DeleteMilestoneOfRepoByID(c.Repo.Repository.ID, c.QueryInt64("id")); err != nil {
 	if err := models.DeleteMilestoneOfRepoByID(c.Repo.Repository.ID, c.QueryInt64("id")); err != nil {
 		c.Flash.Error("DeleteMilestoneByRepoID: " + err.Error())
 		c.Flash.Error("DeleteMilestoneByRepoID: " + err.Error())

+ 10 - 0
routes/repo/pull.go

@@ -78,6 +78,7 @@ func parseBaseRepository(c *context.Context) *models.Repository {
 	return baseRepo
 	return baseRepo
 }
 }
 
 
+// Fork render repository fork page
 func Fork(c *context.Context) {
 func Fork(c *context.Context) {
 	c.Data["Title"] = c.Tr("new_fork")
 	c.Data["Title"] = c.Tr("new_fork")
 
 
@@ -178,6 +179,7 @@ func checkPullInfo(c *context.Context) *models.Issue {
 	return issue
 	return issue
 }
 }
 
 
+// PrepareMergedViewPullInfo show meta information for a merged pull request view page
 func PrepareMergedViewPullInfo(c *context.Context, issue *models.Issue) {
 func PrepareMergedViewPullInfo(c *context.Context, issue *models.Issue) {
 	pull := issue.PullRequest
 	pull := issue.PullRequest
 	c.Data["HasMerged"] = true
 	c.Data["HasMerged"] = true
@@ -197,6 +199,7 @@ func PrepareMergedViewPullInfo(c *context.Context, issue *models.Issue) {
 	}
 	}
 }
 }
 
 
+// PrepareViewPullInfo show meta information for a pull request preview page
 func PrepareViewPullInfo(c *context.Context, issue *models.Issue) *git.PullRequestInfo {
 func PrepareViewPullInfo(c *context.Context, issue *models.Issue) *git.PullRequestInfo {
 	repo := c.Repo.Repository
 	repo := c.Repo.Repository
 	pull := issue.PullRequest
 	pull := issue.PullRequest
@@ -244,6 +247,7 @@ func PrepareViewPullInfo(c *context.Context, issue *models.Issue) *git.PullReque
 	return prInfo
 	return prInfo
 }
 }
 
 
+// ViewPullCommits show commits for a pull request
 func ViewPullCommits(c *context.Context) {
 func ViewPullCommits(c *context.Context) {
 	c.Data["PageIsPullList"] = true
 	c.Data["PageIsPullList"] = true
 	c.Data["PageIsPullCommits"] = true
 	c.Data["PageIsPullCommits"] = true
@@ -299,6 +303,7 @@ func ViewPullCommits(c *context.Context) {
 	c.Success(PullCommitsTPL)
 	c.Success(PullCommitsTPL)
 }
 }
 
 
+// ViewPullFiles render pull request changed files list page
 func ViewPullFiles(c *context.Context) {
 func ViewPullFiles(c *context.Context) {
 	c.Data["PageIsPullList"] = true
 	c.Data["PageIsPullList"] = true
 	c.Data["PageIsPullFiles"] = true
 	c.Data["PageIsPullFiles"] = true
@@ -394,6 +399,7 @@ func ViewPullFiles(c *context.Context) {
 	c.Success(PullFilesTPL)
 	c.Success(PullFilesTPL)
 }
 }
 
 
+// MergePullRequest response for merging pull request
 func MergePullRequest(c *context.Context) {
 func MergePullRequest(c *context.Context) {
 	issue := checkPullInfo(c)
 	issue := checkPullInfo(c)
 	if c.Written() {
 	if c.Written() {
@@ -426,6 +432,7 @@ func MergePullRequest(c *context.Context) {
 	c.Redirect(c.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
 	c.Redirect(c.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
 }
 }
 
 
+// ParseCompareInfo parse compare info between two commit for preparing pull request
 func ParseCompareInfo(c *context.Context) (*models.User, *models.Repository, *git.Repository, *git.PullRequestInfo, string, string) {
 func ParseCompareInfo(c *context.Context) (*models.User, *models.Repository, *git.Repository, *git.PullRequestInfo, string, string) {
 	baseRepo := c.Repo.Repository
 	baseRepo := c.Repo.Repository
 
 
@@ -543,6 +550,7 @@ func ParseCompareInfo(c *context.Context) (*models.User, *models.Repository, *gi
 	return headUser, headRepo, headGitRepo, prInfo, baseBranch, headBranch
 	return headUser, headRepo, headGitRepo, prInfo, baseBranch, headBranch
 }
 }
 
 
+// PrepareCompareDiff render pull request preview diff page
 func PrepareCompareDiff(
 func PrepareCompareDiff(
 	c *context.Context,
 	c *context.Context,
 	headUser *models.User,
 	headUser *models.User,
@@ -601,6 +609,7 @@ func PrepareCompareDiff(
 	return false
 	return false
 }
 }
 
 
+// CompareAndPullRequest render pull request preview page
 func CompareAndPullRequest(c *context.Context) {
 func CompareAndPullRequest(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.pulls.compare_changes")
 	c.Data["Title"] = c.Tr("repo.pulls.compare_changes")
 	c.Data["PageIsComparePull"] = true
 	c.Data["PageIsComparePull"] = true
@@ -748,6 +757,7 @@ func parseOwnerAndRepo(c *context.Context) (*models.User, *models.Repository) {
 	return owner, repo
 	return owner, repo
 }
 }
 
 
+// TriggerTask response for a trigger task request
 func TriggerTask(c *context.Context) {
 func TriggerTask(c *context.Context) {
 	pusherID := c.QueryInt64("pusher")
 	pusherID := c.QueryInt64("pusher")
 	branch := c.Query("branch")
 	branch := c.Query("branch")

+ 7 - 2
routes/repo/release.go

@@ -48,6 +48,7 @@ func calReleaseNumCommitsBehind(repoCtx *context.Repository, release *models.Rel
 	return nil
 	return nil
 }
 }
 
 
+// Releases render releases list page
 func Releases(c *context.Context) {
 func Releases(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.release.releases")
 	c.Data["Title"] = c.Tr("repo.release.releases")
 	c.Data["PageIsViewFiles"] = true
 	c.Data["PageIsViewFiles"] = true
@@ -161,6 +162,7 @@ func renderReleaseAttachmentSettings(c *context.Context) {
 	c.Data["AttachmentMaxFiles"] = setting.Release.Attachment.MaxFiles
 	c.Data["AttachmentMaxFiles"] = setting.Release.Attachment.MaxFiles
 }
 }
 
 
+// NewRelease render creating release page
 func NewRelease(c *context.Context) {
 func NewRelease(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.release.new_release")
 	c.Data["Title"] = c.Tr("repo.release.new_release")
 	c.Data["PageIsReleaseList"] = true
 	c.Data["PageIsReleaseList"] = true
@@ -169,7 +171,7 @@ func NewRelease(c *context.Context) {
 	c.HTML(200, ReleasesNewTPL)
 	c.HTML(200, ReleasesNewTPL)
 }
 }
 
 
-// NewReleasePost creates a new release
+// NewReleasePost response for creating a release
 func NewReleasePost(c *context.Context, f form.NewRelease) {
 func NewReleasePost(c *context.Context, f form.NewRelease) {
 	c.Data["Title"] = c.Tr("repo.release.new_release")
 	c.Data["Title"] = c.Tr("repo.release.new_release")
 	c.Data["PageIsReleaseList"] = true
 	c.Data["PageIsReleaseList"] = true
@@ -242,6 +244,7 @@ func NewReleasePost(c *context.Context, f form.NewRelease) {
 	c.Redirect(c.Repo.RepoLink + "/releases")
 	c.Redirect(c.Repo.RepoLink + "/releases")
 }
 }
 
 
+// EditRelease render release edit page
 func EditRelease(c *context.Context) {
 func EditRelease(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.release.edit_release")
 	c.Data["Title"] = c.Tr("repo.release.edit_release")
 	c.Data["PageIsReleaseList"] = true
 	c.Data["PageIsReleaseList"] = true
@@ -270,7 +273,7 @@ func EditRelease(c *context.Context) {
 	c.HTML(200, ReleasesNewTPL)
 	c.HTML(200, ReleasesNewTPL)
 }
 }
 
 
-// EditReleasePost edits a release
+// EditReleasePost response for edit release
 func EditReleasePost(c *context.Context, f form.EditRelease) {
 func EditReleasePost(c *context.Context, f form.EditRelease) {
 	c.Data["Title"] = c.Tr("repo.release.edit_release")
 	c.Data["Title"] = c.Tr("repo.release.edit_release")
 	c.Data["PageIsReleaseList"] = true
 	c.Data["PageIsReleaseList"] = true
@@ -317,6 +320,7 @@ func EditReleasePost(c *context.Context, f form.EditRelease) {
 	c.Redirect(c.Repo.RepoLink + "/releases")
 	c.Redirect(c.Repo.RepoLink + "/releases")
 }
 }
 
 
+// UploadReleaseAttachment uploads a release attachment
 func UploadReleaseAttachment(c *context.Context) {
 func UploadReleaseAttachment(c *context.Context) {
 	if !setting.Release.Attachment.Enabled {
 	if !setting.Release.Attachment.Enabled {
 		c.NotFound()
 		c.NotFound()
@@ -325,6 +329,7 @@ func UploadReleaseAttachment(c *context.Context) {
 	uploadAttachment(c, setting.Release.Attachment.AllowedTypes)
 	uploadAttachment(c, setting.Release.Attachment.AllowedTypes)
 }
 }
 
 
+// DeleteRelease delete a release
 func DeleteRelease(c *context.Context) {
 func DeleteRelease(c *context.Context) {
 	if err := models.DeleteReleaseOfRepoByID(c.Repo.Repository.ID, c.QueryInt64("id")); err != nil {
 	if err := models.DeleteReleaseOfRepoByID(c.Repo.Repository.ID, c.QueryInt64("id")); err != nil {
 		c.Flash.Error("DeleteReleaseByID: " + err.Error())
 		c.Flash.Error("DeleteReleaseByID: " + err.Error())

+ 5 - 0
routes/repo/repo.go

@@ -32,6 +32,7 @@ const (
 	MigrateTPL = "repo/migrate"
 	MigrateTPL = "repo/migrate"
 )
 )
 
 
+// MustBeNotBare render when a repo is a bare git dir
 func MustBeNotBare(c *context.Context) {
 func MustBeNotBare(c *context.Context) {
 	if c.Repo.Repository.IsBare {
 	if c.Repo.Repository.IsBare {
 		c.Handle(404, "MustBeNotBare", nil)
 		c.Handle(404, "MustBeNotBare", nil)
@@ -69,6 +70,7 @@ func checkContextUser(c *context.Context, uid int64) *models.User {
 	return org
 	return org
 }
 }
 
 
+// Create render creating repository page
 func Create(c *context.Context) {
 func Create(c *context.Context) {
 	c.Title("new_repo")
 	c.Title("new_repo")
 	c.RequireAutosize()
 	c.RequireAutosize()
@@ -152,6 +154,7 @@ func CreatePost(c *context.Context, f form.CreateRepo) {
 	handleCreateError(c, ctxUser, err, "CreatePost", CreateTPL, &f)
 	handleCreateError(c, ctxUser, err, "CreatePost", CreateTPL, &f)
 }
 }
 
 
+// Migrate render migration of repository page
 func Migrate(c *context.Context) {
 func Migrate(c *context.Context) {
 	c.Data["Title"] = c.Tr("new_migrate")
 	c.Data["Title"] = c.Tr("new_migrate")
 	c.Data["private"] = c.User.LastRepoVisibility
 	c.Data["private"] = c.User.LastRepoVisibility
@@ -237,6 +240,7 @@ func MigratePost(c *context.Context, f form.MigrateRepo) {
 	handleCreateError(c, ctxUser, err, "MigratePost", MigrateTPL, &f)
 	handleCreateError(c, ctxUser, err, "MigratePost", MigrateTPL, &f)
 }
 }
 
 
+// Action response for actions to a repository
 func Action(c *context.Context) {
 func Action(c *context.Context) {
 	var err error
 	var err error
 	switch c.Params(":action") {
 	switch c.Params(":action") {
@@ -271,6 +275,7 @@ func Action(c *context.Context) {
 	c.Redirect(redirectTo)
 	c.Redirect(redirectTo)
 }
 }
 
 
+// Download download an archive of a repository
 func Download(c *context.Context) {
 func Download(c *context.Context) {
 	var (
 	var (
 		uri         = c.Params("*")
 		uri         = c.Params("*")

+ 14 - 0
routes/repo/setting.go

@@ -51,6 +51,7 @@ const (
 	SettingsDeployKeysTPL = "repo/settings/deploy_keys"
 	SettingsDeployKeysTPL = "repo/settings/deploy_keys"
 )
 )
 
 
+// Settings show a repository's settings page
 func Settings(c *context.Context) {
 func Settings(c *context.Context) {
 	c.Title("repo.settings")
 	c.Title("repo.settings")
 	c.PageIs("SettingsOptions")
 	c.PageIs("SettingsOptions")
@@ -319,6 +320,7 @@ func SettingsPost(c *context.Context, f form.RepoSetting) {
 	}
 	}
 }
 }
 
 
+// SettingsAvatar response for change avatar on settings page
 func SettingsAvatar(c *context.Context) {
 func SettingsAvatar(c *context.Context) {
 	c.Title("settings.avatar")
 	c.Title("settings.avatar")
 	c.PageIs("SettingsAvatar")
 	c.PageIs("SettingsAvatar")
@@ -336,6 +338,7 @@ func SettingsAvatarPost(c *context.Context, f form.Avatar) {
 	c.SubURLRedirect(c.Repo.RepoLink + "/settings")
 	c.SubURLRedirect(c.Repo.RepoLink + "/settings")
 }
 }
 
 
+// SettingsDeleteAvatar response for delete avatar on setings page
 func SettingsDeleteAvatar(c *context.Context) {
 func SettingsDeleteAvatar(c *context.Context) {
 	if err := c.Repo.Repository.DeleteAvatar(); err != nil {
 	if err := c.Repo.Repository.DeleteAvatar(); err != nil {
 		c.Flash.Error(fmt.Sprintf("Failed to delete avatar: %v", err))
 		c.Flash.Error(fmt.Sprintf("Failed to delete avatar: %v", err))
@@ -343,6 +346,7 @@ func SettingsDeleteAvatar(c *context.Context) {
 	c.SubURLRedirect(c.Repo.RepoLink + "/settings")
 	c.SubURLRedirect(c.Repo.RepoLink + "/settings")
 }
 }
 
 
+// UpdateAvatarSetting update user's avatar
 // FIXME: limit upload size
 // FIXME: limit upload size
 func UpdateAvatarSetting(c *context.Context, f form.Avatar, ctxRepo *models.Repository) error {
 func UpdateAvatarSetting(c *context.Context, f form.Avatar, ctxRepo *models.Repository) error {
 	ctxRepo.UseCustomAvatar = true
 	ctxRepo.UseCustomAvatar = true
@@ -377,6 +381,7 @@ func UpdateAvatarSetting(c *context.Context, f form.Avatar, ctxRepo *models.Repo
 	return nil
 	return nil
 }
 }
 
 
+// SettingsCollaboration render a repository's collaboration page
 func SettingsCollaboration(c *context.Context) {
 func SettingsCollaboration(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.settings")
 	c.Data["Title"] = c.Tr("repo.settings")
 	c.Data["PageIsSettingsCollaboration"] = true
 	c.Data["PageIsSettingsCollaboration"] = true
@@ -430,6 +435,7 @@ func SettingsCollaborationPost(c *context.Context) {
 	c.Redirect(setting.AppSubURL + c.Req.URL.Path)
 	c.Redirect(setting.AppSubURL + c.Req.URL.Path)
 }
 }
 
 
+// ChangeCollaborationAccessMode response for changing access of a collaboration
 func ChangeCollaborationAccessMode(c *context.Context) {
 func ChangeCollaborationAccessMode(c *context.Context) {
 	if err := c.Repo.Repository.ChangeCollaborationAccessMode(
 	if err := c.Repo.Repository.ChangeCollaborationAccessMode(
 		c.QueryInt64("uid"),
 		c.QueryInt64("uid"),
@@ -442,6 +448,7 @@ func ChangeCollaborationAccessMode(c *context.Context) {
 	c.Status(204)
 	c.Status(204)
 }
 }
 
 
+// DeleteCollaboration delete a collaboration for a repository
 func DeleteCollaboration(c *context.Context) {
 func DeleteCollaboration(c *context.Context) {
 	if err := c.Repo.Repository.DeleteCollaboration(c.QueryInt64("id")); err != nil {
 	if err := c.Repo.Repository.DeleteCollaboration(c.QueryInt64("id")); err != nil {
 		c.Flash.Error("DeleteCollaboration: " + err.Error())
 		c.Flash.Error("DeleteCollaboration: " + err.Error())
@@ -454,6 +461,7 @@ func DeleteCollaboration(c *context.Context) {
 	})
 	})
 }
 }
 
 
+// SettingsBranches render a repository's branches page
 func SettingsBranches(c *context.Context) {
 func SettingsBranches(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.settings.branches")
 	c.Data["Title"] = c.Tr("repo.settings.branches")
 	c.Data["PageIsSettingsBranches"] = true
 	c.Data["PageIsSettingsBranches"] = true
@@ -482,6 +490,7 @@ func SettingsBranches(c *context.Context) {
 	c.HTML(200, SettingsBranchesTPL)
 	c.HTML(200, SettingsBranchesTPL)
 }
 }
 
 
+// UpdateDefaultBranch updates the default branch
 func UpdateDefaultBranch(c *context.Context) {
 func UpdateDefaultBranch(c *context.Context) {
 	branch := c.Query("branch")
 	branch := c.Query("branch")
 	if c.Repo.GitRepo.IsBranchExist(branch) &&
 	if c.Repo.GitRepo.IsBranchExist(branch) &&
@@ -508,6 +517,7 @@ func UpdateDefaultBranch(c *context.Context) {
 	c.Redirect(c.Repo.RepoLink + "/settings/branches")
 	c.Redirect(c.Repo.RepoLink + "/settings/branches")
 }
 }
 
 
+// SettingsProtectedBranch renders the protected branch setting page
 func SettingsProtectedBranch(c *context.Context) {
 func SettingsProtectedBranch(c *context.Context) {
 	branch := c.Params("*")
 	branch := c.Params("*")
 	if !c.Repo.GitRepo.IsBranchExist(branch) {
 	if !c.Repo.GitRepo.IsBranchExist(branch) {
@@ -592,6 +602,7 @@ func SettingsProtectedBranchPost(c *context.Context, f form.ProtectBranch) {
 	c.Redirect(fmt.Sprintf("%s/settings/branches/%s", c.Repo.RepoLink, branch))
 	c.Redirect(fmt.Sprintf("%s/settings/branches/%s", c.Repo.RepoLink, branch))
 }
 }
 
 
+// SettingsGitHooks hooks of a repository
 func SettingsGitHooks(c *context.Context) {
 func SettingsGitHooks(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.settings.githooks")
 	c.Data["Title"] = c.Tr("repo.settings.githooks")
 	c.Data["PageIsSettingsGitHooks"] = true
 	c.Data["PageIsSettingsGitHooks"] = true
@@ -606,6 +617,7 @@ func SettingsGitHooks(c *context.Context) {
 	c.HTML(200, SettingsGitHooksTPL)
 	c.HTML(200, SettingsGitHooksTPL)
 }
 }
 
 
+// SettingsGitHooksEdit render for editing a hook of repository page
 func SettingsGitHooksEdit(c *context.Context) {
 func SettingsGitHooksEdit(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.settings.githooks")
 	c.Data["Title"] = c.Tr("repo.settings.githooks")
 	c.Data["PageIsSettingsGitHooks"] = true
 	c.Data["PageIsSettingsGitHooks"] = true
@@ -645,6 +657,7 @@ func SettingsGitHooksEditPost(c *context.Context) {
 	c.Redirect(c.Data["Link"].(string))
 	c.Redirect(c.Data["Link"].(string))
 }
 }
 
 
+// SettingsDeployKeys render the deploy keys list of a repository page
 func SettingsDeployKeys(c *context.Context) {
 func SettingsDeployKeys(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.settings.deploy_keys")
 	c.Data["Title"] = c.Tr("repo.settings.deploy_keys")
 	c.Data["PageIsSettingsKeys"] = true
 	c.Data["PageIsSettingsKeys"] = true
@@ -710,6 +723,7 @@ func SettingsDeployKeysPost(c *context.Context, f form.AddSSHKey) {
 	c.Redirect(c.Repo.RepoLink + "/settings/keys")
 	c.Redirect(c.Repo.RepoLink + "/settings/keys")
 }
 }
 
 
+// DeleteDeployKey response for deleting a deploy key
 func DeleteDeployKey(c *context.Context) {
 func DeleteDeployKey(c *context.Context) {
 	if err := models.DeleteDeployKey(c.User, c.QueryInt64("id")); err != nil {
 	if err := models.DeleteDeployKey(c.User, c.QueryInt64("id")); err != nil {
 		c.Flash.Error("DeleteDeployKey: " + err.Error())
 		c.Flash.Error("DeleteDeployKey: " + err.Error())

+ 5 - 0
routes/repo/view.go

@@ -246,6 +246,7 @@ func setEditorconfigIfExists(c *context.Context) {
 	c.Data["Editorconfig"] = ec
 	c.Data["Editorconfig"] = ec
 }
 }
 
 
+// Home render repository home page
 func Home(c *context.Context) {
 func Home(c *context.Context) {
 	c.Data["PageIsViewFiles"] = true
 	c.Data["PageIsViewFiles"] = true
 
 
@@ -327,6 +328,7 @@ func Home(c *context.Context) {
 	c.HTML(200, HomeTPL)
 	c.HTML(200, HomeTPL)
 }
 }
 
 
+// RenderUserCards render a page show users according the input templaet
 func RenderUserCards(c *context.Context, total int, getter func(page int) ([]*models.User, error), tpl string) {
 func RenderUserCards(c *context.Context, total int, getter func(page int) ([]*models.User, error), tpl string) {
 	page := c.QueryInt("page")
 	page := c.QueryInt("page")
 	if page <= 0 {
 	if page <= 0 {
@@ -345,6 +347,7 @@ func RenderUserCards(c *context.Context, total int, getter func(page int) ([]*mo
 	c.HTML(200, tpl)
 	c.HTML(200, tpl)
 }
 }
 
 
+// Watchers render repository's watch users
 func Watchers(c *context.Context) {
 func Watchers(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.watchers")
 	c.Data["Title"] = c.Tr("repo.watchers")
 	c.Data["CardsTitle"] = c.Tr("repo.watchers")
 	c.Data["CardsTitle"] = c.Tr("repo.watchers")
@@ -352,6 +355,7 @@ func Watchers(c *context.Context) {
 	RenderUserCards(c, c.Repo.Repository.NumWatches, c.Repo.Repository.GetWatchers, WatchersTPL)
 	RenderUserCards(c, c.Repo.Repository.NumWatches, c.Repo.Repository.GetWatchers, WatchersTPL)
 }
 }
 
 
+// Stars render repository's starred users
 func Stars(c *context.Context) {
 func Stars(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.stargazers")
 	c.Data["Title"] = c.Tr("repo.stargazers")
 	c.Data["CardsTitle"] = c.Tr("repo.stargazers")
 	c.Data["CardsTitle"] = c.Tr("repo.stargazers")
@@ -359,6 +363,7 @@ func Stars(c *context.Context) {
 	RenderUserCards(c, c.Repo.Repository.NumStars, c.Repo.Repository.GetStargazers, WatchersTPL)
 	RenderUserCards(c, c.Repo.Repository.NumStars, c.Repo.Repository.GetStargazers, WatchersTPL)
 }
 }
 
 
+// Forks render repository's forked users
 func Forks(c *context.Context) {
 func Forks(c *context.Context) {
 	c.Data["Title"] = c.Tr("repos.forks")
 	c.Data["Title"] = c.Tr("repos.forks")
 
 

+ 7 - 0
routes/repo/webhook.go

@@ -32,6 +32,7 @@ const (
 	OrgWebhookNewTPL = "org/settings/webhook_new"
 	OrgWebhookNewTPL = "org/settings/webhook_new"
 )
 )
 
 
+// Webhooks render web hooks list page
 func Webhooks(c *context.Context) {
 func Webhooks(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.settings.hooks")
 	c.Data["Title"] = c.Tr("repo.settings.hooks")
 	c.Data["PageIsSettingsHooks"] = true
 	c.Data["PageIsSettingsHooks"] = true
@@ -89,6 +90,7 @@ func checkHookType(c *context.Context) string {
 	return hookType
 	return hookType
 }
 }
 
 
+// WebhooksNew render creating webhook page
 func WebhooksNew(c *context.Context) {
 func WebhooksNew(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.settings.add_webhook")
 	c.Data["Title"] = c.Tr("repo.settings.add_webhook")
 	c.Data["PageIsSettingsHooks"] = true
 	c.Data["PageIsSettingsHooks"] = true
@@ -110,6 +112,7 @@ func WebhooksNew(c *context.Context) {
 	c.HTML(200, orCtx.NewTemplate)
 	c.HTML(200, orCtx.NewTemplate)
 }
 }
 
 
+// ParseHookEvent convert web form content to models.HookEvent
 func ParseHookEvent(f form.Webhook) *models.HookEvent {
 func ParseHookEvent(f form.Webhook) *models.HookEvent {
 	return &models.HookEvent{
 	return &models.HookEvent{
 		PushOnly:       f.PushOnly(),
 		PushOnly:       f.PushOnly(),
@@ -315,6 +318,7 @@ func checkWebhook(c *context.Context) (*OrgRepoCtx, *models.Webhook) {
 	return orCtx, w
 	return orCtx, w
 }
 }
 
 
+// WebHooksEdit render editing web hook page
 func WebHooksEdit(c *context.Context) {
 func WebHooksEdit(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.settings.update_webhook")
 	c.Data["Title"] = c.Tr("repo.settings.update_webhook")
 	c.Data["PageIsSettingsHooks"] = true
 	c.Data["PageIsSettingsHooks"] = true
@@ -455,6 +459,7 @@ func DiscordHooksEditPost(c *context.Context, f form.NewDiscordHook) {
 	c.Redirect(fmt.Sprintf("%s/settings/hooks/%d", orCtx.Link, w.ID))
 	c.Redirect(fmt.Sprintf("%s/settings/hooks/%d", orCtx.Link, w.ID))
 }
 }
 
 
+// TestWebhook test if web hook is work fine
 func TestWebhook(c *context.Context) {
 func TestWebhook(c *context.Context) {
 	var authorUsername, committerUsername string
 	var authorUsername, committerUsername string
 
 
@@ -532,6 +537,7 @@ func TestWebhook(c *context.Context) {
 	}
 	}
 }
 }
 
 
+// RedeliveryWebhook re-deliver a webhook
 func RedeliveryWebhook(c *context.Context) {
 func RedeliveryWebhook(c *context.Context) {
 	webhook, err := models.GetWebhookOfRepoByID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
 	webhook, err := models.GetWebhookOfRepoByID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
 	if err != nil {
 	if err != nil {
@@ -555,6 +561,7 @@ func RedeliveryWebhook(c *context.Context) {
 	}
 	}
 }
 }
 
 
+// DeleteWebhook delete a webhook
 func DeleteWebhook(c *context.Context) {
 func DeleteWebhook(c *context.Context) {
 	if err := models.DeleteWebhookOfRepoByID(c.Repo.Repository.ID, c.QueryInt64("id")); err != nil {
 	if err := models.DeleteWebhookOfRepoByID(c.Repo.Repository.ID, c.QueryInt64("id")); err != nil {
 		c.Flash.Error("DeleteWebhookByRepoID: " + err.Error())
 		c.Flash.Error("DeleteWebhookByRepoID: " + err.Error())

+ 5 - 0
routes/repo/wiki.go

@@ -32,6 +32,7 @@ const (
 	WikiPagesTPL = "repo/wiki/pages"
 	WikiPagesTPL = "repo/wiki/pages"
 )
 )
 
 
+// MustEnableWiki check if wiki is enabled, if external then redirect
 func MustEnableWiki(c *context.Context) {
 func MustEnableWiki(c *context.Context) {
 	if !c.Repo.Repository.EnableWiki {
 	if !c.Repo.Repository.EnableWiki {
 		c.Handle(404, "MustEnableWiki", nil)
 		c.Handle(404, "MustEnableWiki", nil)
@@ -123,6 +124,7 @@ func renderWikiPage(c *context.Context, isViewPage bool) (*git.Repository, strin
 	return wikiRepo, pageName
 	return wikiRepo, pageName
 }
 }
 
 
+// Wiki renders single wiki page
 func Wiki(c *context.Context) {
 func Wiki(c *context.Context) {
 	c.Data["PageIsWiki"] = true
 	c.Data["PageIsWiki"] = true
 
 
@@ -149,6 +151,7 @@ func Wiki(c *context.Context) {
 	c.HTML(200, WikiViewTPL)
 	c.HTML(200, WikiViewTPL)
 }
 }
 
 
+// WikiPages render wiki pages list page
 func WikiPages(c *context.Context) {
 func WikiPages(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.wiki.pages")
 	c.Data["Title"] = c.Tr("repo.wiki.pages")
 	c.Data["PageIsWiki"] = true
 	c.Data["PageIsWiki"] = true
@@ -195,6 +198,7 @@ func WikiPages(c *context.Context) {
 	c.HTML(200, WikiPagesTPL)
 	c.HTML(200, WikiPagesTPL)
 }
 }
 
 
+// NewWiki render wiki create page
 func NewWiki(c *context.Context) {
 func NewWiki(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.wiki.new_page")
 	c.Data["Title"] = c.Tr("repo.wiki.new_page")
 	c.Data["PageIsWiki"] = true
 	c.Data["PageIsWiki"] = true
@@ -231,6 +235,7 @@ func NewWikiPost(c *context.Context, f form.NewWiki) {
 	c.Redirect(c.Repo.RepoLink + "/wiki/" + models.ToWikiPageURL(models.ToWikiPageName(f.Title)))
 	c.Redirect(c.Repo.RepoLink + "/wiki/" + models.ToWikiPageURL(models.ToWikiPageName(f.Title)))
 }
 }
 
 
+// EditWiki render wiki modify page
 func EditWiki(c *context.Context) {
 func EditWiki(c *context.Context) {
 	c.Data["PageIsWiki"] = true
 	c.Data["PageIsWiki"] = true
 	c.Data["PageIsWikiEdit"] = true
 	c.Data["PageIsWikiEdit"] = true

+ 1 - 1
routes/user/setting.go

@@ -140,7 +140,7 @@ func SettingsPost(c *context.Context, f form.UpdateProfile) {
 		c.User.LowerName = strings.ToLower(f.Name)
 		c.User.LowerName = strings.ToLower(f.Name)
 	}
 	}
 
 
-	var email string = strings.ToLower(f.Email)
+	var email = strings.ToLower(f.Email)
 	if c.User.Email != email {
 	if c.User.Email != email {
 		if used, err := models.IsEmailUsed(email); used {
 		if used, err := models.IsEmailUsed(email); used {
 			c.FormErr("Email")
 			c.FormErr("Email")