From 7ca5f8f119593023809e6130db75154597c52426 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 15 Jul 2016 21:53:43 +0800 Subject: [PATCH] models/repo: remove redundant info for some repo methods RepoLink -> Link, RepoRelLink -> RelLink, FullRepoLink -> FullLink --- models/action.go | 2 +- models/pull.go | 2 +- models/repo.go | 8 ++++---- modules/context/repo.go | 2 +- routers/repo/pull.go | 2 +- routers/repo/setting.go | 2 +- routers/repo/webhook.go | 2 +- templates/repo/header.tmpl | 8 ++++---- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/models/action.go b/models/action.go index efb4eaaf02..d39209c447 100644 --- a/models/action.go +++ b/models/action.go @@ -517,7 +517,7 @@ func CommitRepoAction( Before: oldCommitID, After: newCommitID, CompareUrl: setting.AppUrl + commit.CompareUrl, - Commits: commit.ToApiPayloadCommits(repo.FullRepoLink()), + Commits: commit.ToApiPayloadCommits(repo.FullLink()), Repo: payloadRepo, Pusher: &api.PayloadAuthor{ Name: pusher_name, diff --git a/models/pull.go b/models/pull.go index 86ddb5d944..8ef0cc643a 100644 --- a/models/pull.go +++ b/models/pull.go @@ -236,7 +236,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error Before: pr.MergeBase, After: pr.MergedCommitID, CompareUrl: setting.AppUrl + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID), - Commits: ListToPushCommits(l).ToApiPayloadCommits(pr.BaseRepo.FullRepoLink()), + Commits: ListToPushCommits(l).ToApiPayloadCommits(pr.BaseRepo.FullLink()), Repo: pr.BaseRepo.ComposePayload(), Pusher: &api.PayloadAuthor{ Name: pr.HeadRepo.MustOwner().DisplayName(), diff --git a/models/repo.go b/models/repo.go index 78f1511c9d..f8782db71e 100644 --- a/models/repo.go +++ b/models/repo.go @@ -346,11 +346,11 @@ func (repo *Repository) GitConfigPath() string { return filepath.Join(repo.RepoPath(), "config") } -func (repo *Repository) RepoLink() string { +func (repo *Repository) Link() string { return setting.AppSubUrl + "/" + repo.MustOwner().Name + "/" + repo.Name } -func (repo *Repository) RepoRelLink() string { +func (repo *Repository) RelLink() string { return "/" + repo.MustOwner().Name + "/" + repo.Name } @@ -358,7 +358,7 @@ func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) strin return fmt.Sprintf("%s/%s/compare/%s...%s", repo.MustOwner().Name, repo.Name, oldCommitID, newCommitID) } -func (repo *Repository) FullRepoLink() string { +func (repo *Repository) FullLink() string { return setting.AppUrl + repo.MustOwner().Name + "/" + repo.Name } @@ -459,7 +459,7 @@ func (repo *Repository) ComposePayload() *api.PayloadRepo { return &api.PayloadRepo{ ID: repo.ID, Name: repo.Name, - URL: repo.FullRepoLink(), + URL: repo.FullLink(), SSHURL: cl.SSH, CloneURL: cl.HTTPS, Description: repo.Description, diff --git a/modules/context/repo.go b/modules/context/repo.go index a7ca17d3bc..f68576ff5d 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -174,7 +174,7 @@ func RepoAssignment(args ...bool) macaron.Handler { return } ctx.Repo.GitRepo = gitRepo - ctx.Repo.RepoLink = repo.RepoLink() + ctx.Repo.RepoLink = repo.Link() ctx.Data["RepoLink"] = ctx.Repo.RepoLink ctx.Data["RepoRelPath"] = ctx.Repo.Owner.Name + "/" + ctx.Repo.Repository.Name diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 922d64ef47..da1ee14996 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -531,7 +531,7 @@ func PrepareCompareDiff( ) // Get diff information. - ctx.Data["CommitRepoLink"] = headRepo.RepoLink() + ctx.Data["CommitRepoLink"] = headRepo.Link() headCommitID, err := headGitRepo.GetBranchCommitID(headBranch) if err != nil { diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 14d2963656..6fd195aa10 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -122,7 +122,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { } ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success")) - ctx.Redirect(repo.RepoLink() + "/settings") + ctx.Redirect(repo.Link() + "/settings") case "advanced": repo.EnableWiki = form.EnableWiki diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index 460a430aad..d904862359 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -349,7 +349,7 @@ func TestWebhook(ctx *context.Context) { { ID: ctx.Repo.CommitID, Message: ctx.Repo.Commit.Message(), - URL: ctx.Repo.Repository.FullRepoLink() + "/commit/" + ctx.Repo.CommitID, + URL: ctx.Repo.Repository.FullLink() + "/commit/" + ctx.Repo.CommitID, Author: &api.PayloadAuthor{ Name: ctx.Repo.Commit.Author.Name, Email: ctx.Repo.Commit.Author.Email, diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index dfb7673d33..1293fa4310 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -10,7 +10,7 @@
/
{{.Name}} {{if .IsMirror}}
{{$.i18n.Tr "repo.mirror_from"}} {{$.Mirror.Address}}
{{end}} - {{if .IsFork}}
{{$.i18n.Tr "repo.forked_from"}} {{SubStr .BaseRepo.RepoRelLink 1 -1}}
{{end}} + {{if .IsFork}}
{{$.i18n.Tr "repo.forked_from"}} {{SubStr .BaseRepo.RepoRelLink 1 -1}}
{{end}}
@@ -18,7 +18,7 @@ {{if $.IsWatchingRepo}}{{$.i18n.Tr "repo.unwatch"}}{{else}}{{$.i18n.Tr "repo.watch"}}{{end}} - + {{.NumWatches}}
@@ -26,7 +26,7 @@ {{if $.IsStaringRepo}}{{$.i18n.Tr "repo.unstar"}}{{else}}{{$.i18n.Tr "repo.star"}}{{end}} - + {{.NumStars}} @@ -35,7 +35,7 @@ {{$.i18n.Tr "repo.fork"}} - + {{.NumForks}}