summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorMario Lubenka <mario.lubenka@googlemail.com>2019-06-07 22:29:29 +0200
committertechknowlogick <hello@techknowlogick.com>2019-06-07 16:29:29 -0400
commit311ce2d1d06c26d0d5a3b745493995813e2ea6f2 (patch)
tree128b7cf4a9772373ea25bfea523de4298e5e78a2 /templates
parentbd55f6ff36d40503bfa3407225780d0ab7d37930 (diff)
downloadgitea-311ce2d1d06c26d0d5a3b745493995813e2ea6f2.tar.gz
gitea-311ce2d1d06c26d0d5a3b745493995813e2ea6f2.zip
Compare branches, commits and tags with each other (#6991)
* Supports tags when comparing commits or branches Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Hide headline when only comparing and don't load unused data Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Merges compare logics to allow comparing branches, commits and tags with eachother Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Display branch or tag instead of commit when used for comparing Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Show pull request form after click on button Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Transfers relevant pull.go changes from master to compare.go Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Fixes error when comparing forks against a commit or tag Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Removes console.log from JavaScript file Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Show icon next to commit reference when comparing branch or tag Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Updates css file Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Fixes import order * Renames template variable * Update routers/repo/compare.go Co-Authored-By: zeripath <art27@cantab.net> * Update from master Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Allow short-shas in compare * Renames prInfo to compareInfo Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Check PR permissions only if compare is pull request Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Adjusts comment Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Use compareInfo instead of prInfo
Diffstat (limited to 'templates')
-rw-r--r--templates/repo/commit_page.tmpl89
-rw-r--r--templates/repo/commits_table.tmpl8
-rw-r--r--templates/repo/diff/compare.tmpl74
-rw-r--r--templates/repo/diff/page.tmpl94
-rw-r--r--templates/repo/pulls/compare.tmpl69
5 files changed, 168 insertions, 166 deletions
diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl
new file mode 100644
index 0000000000..0cfdf5156d
--- /dev/null
+++ b/templates/repo/commit_page.tmpl
@@ -0,0 +1,89 @@
+{{template "base/head" .}}
+<div class="repository diff">
+ {{template "repo/header" .}}
+ <div class="ui container {{if .IsSplitStyle}}fluid padded{{end}}">
+ <div class="ui top attached info clearing segment {{if .Commit.Signature}} isSigned {{if .Verification.Verified }} isVerified {{end}}{{end}}">
+ <a class="ui floated right blue tiny button" href="{{EscapePound .SourcePath}}">
+ {{.i18n.Tr "repo.diff.browse_source"}}
+ </a>
+ <h3 class="has-emoji">{{RenderCommitMessage .Commit.Message $.RepoLink $.Repository.ComposeMetas}}{{template "repo/commit_status" .CommitStatus}}</h3>
+ {{if IsMultilineCommitMessage .Commit.Message}}
+ <pre class="commit-body">{{RenderCommitBody .Commit.Message $.RepoLink $.Repository.ComposeMetas}}</pre>
+ {{end}}
+ <span class="text grey"><i class="octicon octicon-git-branch"></i>{{.BranchName}}</span>
+ </div>
+ <div class="ui attached info segment {{if .Commit.Signature}} isSigned {{if .Verification.Verified }} isVerified {{end}}{{end}}">
+ <div class="ui stackable grid">
+ <div class="nine wide column">
+ {{if .Author}}
+ <img class="ui avatar image" src="{{.Author.RelAvatarLink}}" />
+ {{if .Author.FullName}}
+ <a href="{{.Author.HomeLink}}"><strong>{{.Author.FullName}}</strong></a> {{if .IsSigned}}<{{.Commit.Author.Email}}>{{end}}
+ {{else}}
+ <a href="{{.Author.HomeLink}}"><strong>{{.Commit.Author.Name}}</strong></a> {{if .IsSigned}}<{{.Commit.Author.Email}}>{{end}}
+ {{end}}
+ {{else}}
+ <img class="ui avatar image" src="{{AvatarLink .Commit.Author.Email}}" />
+ <strong>{{.Commit.Author.Name}}</strong>
+ {{end}}
+ <span class="text grey" id="authored-time">{{TimeSince .Commit.Author.When $.Lang}}</span>
+ </div>
+ <div class="seven wide right aligned column">
+ <div class="ui horizontal list">
+ {{if .Parents}}
+ <div class="item">
+ {{.i18n.Tr "repo.diff.parent"}}
+ </div>
+ <div class="item">
+ {{range .Parents}}
+ <a class="ui blue sha label" href="{{$.RepoLink}}/commit/{{.}}">{{ShortSha .}}</a>
+ {{end}}
+ </div>
+ {{end}}
+ <div class="mobile-only"></div>
+ <div class="item">{{.i18n.Tr "repo.diff.commit"}}</div>
+ <div class="item"><span class="ui blue sha label">{{ShortSha .CommitID}}</span></div>
+ </div>
+ </div><!-- end column -->
+ </div><!-- end grid -->
+ </div>
+ {{if .Commit.Signature}}
+ {{if .Verification.Verified }}
+ <div class="ui bottom attached positive message">
+ <i class="green lock icon"></i>
+ <span>{{.i18n.Tr "repo.commits.signed_by"}}:</span>
+ <a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Commit.Committer.Name}}</strong></a> <{{.Commit.Committer.Email}}>
+ <span class="pull-right"><span>{{.i18n.Tr "repo.commits.gpg_key_id"}}:</span> {{.Verification.SigningKey.KeyID}}</span>
+ </div>
+ {{else}}
+ <div class="ui bottom attached message">
+ <i class="grey unlock icon"></i>
+ {{.i18n.Tr .Verification.Reason}}
+ </div>
+ {{end}}
+ {{end}}
+ {{if .Note}}
+ <div class="ui top attached info segment message git-notes">
+ <i class="sticky note icon"></i>
+ {{.i18n.Tr "repo.diff.git-notes"}}:
+ {{if .NoteAuthor}}
+ <a href="{{.NoteAuthor.HomeLink}}">
+ {{if .NoteAuthor.FullName}}
+ <strong>{{.NoteAuthor.FullName}}</strong>
+ {{else}}
+ <strong>{{.NoteCommit.Author.Name}}</strong>
+ {{end}}
+ </a>
+ {{else}}
+ <strong>{{.NoteCommit.Author.Name}}</strong>
+ {{end}}
+ <span class="text grey" id="note-authored-time">{{TimeSince .NoteCommit.Author.When $.Lang}}</span>
+ </div>
+ <div class="ui bottom attached info segment git-notes">
+ <pre class="commit-body">{{RenderNote .Note $.RepoLink $.Repository.ComposeMetas}}</pre>
+ </div>
+ {{end}}
+ {{template "repo/diff/box" .}}
+ </div>
+</div>
+{{template "base/footer" .}}
diff --git a/templates/repo/commits_table.tmpl b/templates/repo/commits_table.tmpl
index 66bfd0d831..10f4b60483 100644
--- a/templates/repo/commits_table.tmpl
+++ b/templates/repo/commits_table.tmpl
@@ -1,13 +1,13 @@
<h4 class="ui top attached header">
<div class="ui stackable grid">
- <div class="ten wide column">
+ <div class="five wide column">
{{if or .PageIsCommits (gt .CommitCount 0)}}
{{.CommitCount}} {{.i18n.Tr "repo.commits.commits"}} {{if .Branch}}({{.Branch}}){{end}}
{{else}}
{{.i18n.Tr "repo.commits.no_commits" $.BaseBranch $.HeadBranch }} {{if .Branch}}({{.Branch}}){{end}}
{{end}}
</div>
- <div class="six wide right aligned column">
+ <div class="eleven wide right aligned column">
{{if .PageIsCommits}}
<form class="ignore-dirty" action="{{.RepoLink}}/commits/{{.BranchNameSubURL | EscapePound}}/search">
<div class="ui tiny search input">
@@ -21,7 +21,9 @@
<button class="ui black tiny button" data-panel="#add-deploy-key-panel" data-tooltip={{.i18n.Tr "repo.commits.search.tooltip"}}>{{.i18n.Tr "repo.commits.find"}}</button>
</form>
{{else if .IsDiffCompare}}
- <a href="{{$.CommitRepoLink}}/commit/{{.BeforeCommitID}}" class="ui green sha label">{{ShortSha .BeforeCommitID}}</a> ... <a href="{{$.CommitRepoLink}}/commit/{{.AfterCommitID}}" class="ui green sha label">{{ShortSha .AfterCommitID}}</a>
+ <a href="{{$.CommitRepoLink}}/commit/{{.BeforeCommitID}}" class="ui green sha label">{{if not .BaseIsCommit}}{{if .BaseIsBranch}}<i class="octicon octicon-git-branch"></i>{{else if .BaseIsTag}}<i class="octicon octicon-tag"></i>{{end}}{{.BaseBranch}}{{else}}{{ShortSha .BaseBranch}}{{end}}</a>
+ ...
+ <a href="{{$.CommitRepoLink}}/commit/{{.AfterCommitID}}" class="ui green sha label">{{if not .HeadIsCommit}}{{if .HeadIsBranch}}<i class="octicon octicon-git-branch"></i>{{else if .HeadIsTag}}<i class="octicon octicon-tag"></i>{{end}}{{.HeadBranch}}{{else}}{{ShortSha .HeadBranch}}{{end}}</a>
{{end}}
</div>
</div>
diff --git a/templates/repo/diff/compare.tmpl b/templates/repo/diff/compare.tmpl
new file mode 100644
index 0000000000..cc727422d7
--- /dev/null
+++ b/templates/repo/diff/compare.tmpl
@@ -0,0 +1,74 @@
+{{template "base/head" .}}
+<div class="repository diff {{if .PageIsComparePull}}compare pull{{end}}">
+ {{template "repo/header" .}}
+ <div class="ui container {{if .IsSplitStyle}}fluid padded{{end}}">
+
+ {{if .PageIsComparePull}}
+ <h2 class="ui header">
+ {{.i18n.Tr "repo.pulls.compare_changes"}}
+ <div class="sub header">{{.i18n.Tr "repo.pulls.compare_changes_desc"}}</div>
+ </h2>
+ <div class="ui segment choose branch">
+ <span class="octicon octicon-git-compare"></span>
+ <div class="ui floating filter dropdown" data-no-results="{{.i18n.Tr "repo.pulls.no_results"}}">
+ <div class="ui basic small button">
+ <span class="text">{{.i18n.Tr "repo.pulls.compare_base"}}: {{$.BaseName}}:{{$.BaseBranch}}</span>
+ <i class="dropdown icon"></i>
+ </div>
+ <div class="menu">
+ <div class="ui icon search input">
+ <i class="filter icon"></i>
+ <input name="search" placeholder="{{.i18n.Tr "repo.pulls.filter_branch"}}...">
+ </div>
+ <div class="scrolling menu">
+ {{range .Branches}}
+ <div class="item {{if eq $.BaseBranch .}}selected{{end}}" data-url="{{$.RepoLink}}/compare/{{EscapePound .}}...{{if not $.PullRequestCtx.SameRepo}}{{$.HeadUser.Name}}:{{end}}{{EscapePound $.HeadBranch}}">{{$.BaseName}}:{{.}}</div>
+ {{end}}
+ </div>
+ </div>
+ </div>
+ ...
+ <div class="ui floating filter dropdown">
+ <div class="ui basic small button">
+ <span class="text">{{.i18n.Tr "repo.pulls.compare_compare"}}: {{$.HeadUser.Name}}:{{$.HeadBranch}}</span>
+ <i class="dropdown icon"></i>
+ </div>
+ <div class="menu">
+ <div class="ui icon search input">
+ <i class="filter icon"></i>
+ <input name="search" placeholder="{{.i18n.Tr "repo.pulls.filter_branch"}}...">
+ </div>
+ <div class="scrolling menu">
+ {{range .HeadBranches}}
+ <div class="{{if eq $.HeadBranch .}}selected{{end}} item" data-url="{{$.RepoLink}}/compare/{{EscapePound $.BaseBranch}}...{{if not $.PullRequestCtx.SameRepo}}{{$.HeadUser.Name}}:{{end}}{{EscapePound .}}">{{$.HeadUser.Name}}:{{.}}</div>
+ {{end}}
+ </div>
+ </div>
+ </div>
+ </div>
+ {{end}}
+
+ {{if .IsNothingToCompare}}
+ <div class="ui segment">{{.i18n.Tr "repo.pulls.nothing_to_compare"}}</div>
+ {{else if .PageIsComparePull}}
+ {{if .HasPullRequest}}
+ <div class="ui segment">
+ {{.i18n.Tr "repo.pulls.has_pull_request" $.RepoLink $.RepoRelPath .PullRequest.Index | Safe}}
+ </div>
+ {{else}}
+ <div class="ui info message show-form-container">
+ <button class="ui button green show-form">{{.i18n.Tr "repo.pulls.new"}}</button>
+ </div>
+ <div class="pullrequest-form" style="display: none">
+ {{template "repo/issue/new_form" .}}
+ </div>
+ {{template "repo/commits_table" .}}
+ {{template "repo/diff/box" .}}
+ {{end}}
+ {{else}}
+ {{template "repo/commits_table" .}}
+ {{template "repo/diff/box" .}}
+ {{end}}
+ </div>
+</div>
+{{template "base/footer" .}}
diff --git a/templates/repo/diff/page.tmpl b/templates/repo/diff/page.tmpl
deleted file mode 100644
index c35e2a415b..0000000000
--- a/templates/repo/diff/page.tmpl
+++ /dev/null
@@ -1,94 +0,0 @@
-{{template "base/head" .}}
-<div class="repository diff">
- {{template "repo/header" .}}
- <div class="ui container {{if .IsSplitStyle}}fluid padded{{end}}">
- {{if .IsDiffCompare }}
- {{template "repo/commits_table" .}}
- {{else}}
- <div class="ui top attached info clearing segment {{if .Commit.Signature}} isSigned {{if .Verification.Verified }} isVerified {{end}}{{end}}">
- <a class="ui floated right blue tiny button" href="{{EscapePound .SourcePath}}">
- {{.i18n.Tr "repo.diff.browse_source"}}
- </a>
- <h3 class="has-emoji">{{RenderCommitMessage .Commit.Message $.RepoLink $.Repository.ComposeMetas}}{{template "repo/commit_status" .CommitStatus}}</h3>
- {{if IsMultilineCommitMessage .Commit.Message}}
- <pre class="commit-body">{{RenderCommitBody .Commit.Message $.RepoLink $.Repository.ComposeMetas}}</pre>
- {{end}}
- <span class="text grey"><i class="octicon octicon-git-branch"></i>{{.BranchName}}</span>
- </div>
- <div class="ui attached info segment {{if .Commit.Signature}} isSigned {{if .Verification.Verified }} isVerified {{end}}{{end}}">
- <div class="ui stackable grid">
- <div class="nine wide column">
- {{if .Author}}
- <img class="ui avatar image" src="{{.Author.RelAvatarLink}}" />
- {{if .Author.FullName}}
- <a href="{{.Author.HomeLink}}"><strong>{{.Author.FullName}}</strong></a> {{if .IsSigned}}<{{.Commit.Author.Email}}>{{end}}
- {{else}}
- <a href="{{.Author.HomeLink}}"><strong>{{.Commit.Author.Name}}</strong></a> {{if .IsSigned}}<{{.Commit.Author.Email}}>{{end}}
- {{end}}
- {{else}}
- <img class="ui avatar image" src="{{AvatarLink .Commit.Author.Email}}" />
- <strong>{{.Commit.Author.Name}}</strong>
- {{end}}
- <span class="text grey" id="authored-time">{{TimeSince .Commit.Author.When $.Lang}}</span>
- </div>
- <div class="seven wide right aligned column">
- <div class="ui horizontal list">
- {{if .Parents}}
- <div class="item">
- {{.i18n.Tr "repo.diff.parent"}}
- </div>
- <div class="item">
- {{range .Parents}}
- <a class="ui blue sha label" href="{{$.RepoLink}}/commit/{{.}}">{{ShortSha .}}</a>
- {{end}}
- </div>
- {{end}}
- <div class="mobile-only"></div>
- <div class="item">{{.i18n.Tr "repo.diff.commit"}}</div>
- <div class="item"><span class="ui blue sha label">{{ShortSha .CommitID}}</span></div>
- </div>
- </div><!-- end column -->
- </div><!-- end grid -->
- </div>
- {{if .Commit.Signature}}
- {{if .Verification.Verified }}
- <div class="ui bottom attached positive message">
- <i class="green lock icon"></i>
- <span>{{.i18n.Tr "repo.commits.signed_by"}}:</span>
- <a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Commit.Committer.Name}}</strong></a> <{{.Commit.Committer.Email}}>
- <span class="pull-right"><span>{{.i18n.Tr "repo.commits.gpg_key_id"}}:</span> {{.Verification.SigningKey.KeyID}}</span>
- </div>
- {{else}}
- <div class="ui bottom attached message">
- <i class="grey unlock icon"></i>
- {{.i18n.Tr .Verification.Reason}}
- </div>
- {{end}}
- {{end}}
- {{if .Note}}
- <div class="ui top attached info segment message git-notes">
- <i class="sticky note icon"></i>
- {{.i18n.Tr "repo.diff.git-notes"}}:
- {{if .NoteAuthor}}
- <a href="{{.NoteAuthor.HomeLink}}">
- {{if .NoteAuthor.FullName}}
- <strong>{{.NoteAuthor.FullName}}</strong>
- {{else}}
- <strong>{{.NoteCommit.Author.Name}}</strong>
- {{end}}
- </a>
- {{else}}
- <strong>{{.NoteCommit.Author.Name}}</strong>
- {{end}}
- <span class="text grey" id="note-authored-time">{{TimeSince .NoteCommit.Author.When $.Lang}}</span>
- </div>
- <div class="ui bottom attached info segment git-notes">
- <pre class="commit-body">{{RenderNote .Note $.RepoLink $.Repository.ComposeMetas}}</pre>
- </div>
- {{end}}
- {{end}}
-
- {{template "repo/diff/box" .}}
- </div>
-</div>
-{{template "base/footer" .}}
diff --git a/templates/repo/pulls/compare.tmpl b/templates/repo/pulls/compare.tmpl
deleted file mode 100644
index 2296acf1df..0000000000
--- a/templates/repo/pulls/compare.tmpl
+++ /dev/null
@@ -1,69 +0,0 @@
-{{template "base/head" .}}
-<div class="repository compare pull diff">
- {{template "repo/header" .}}
- <div class="ui container">
- <div class="sixteen wide column page grid">
- <h2 class="ui header">
- {{.i18n.Tr "repo.pulls.compare_changes"}}
- <div class="sub header">{{.i18n.Tr "repo.pulls.compare_changes_desc"}}</div>
- </h2>
- <div class="ui segment choose branch">
- <span class="octicon octicon-git-compare"></span>
- <div class="ui floating filter dropdown" data-no-results="{{.i18n.Tr "repo.pulls.no_results"}}">
- <div class="ui basic small button">
- <span class="text">{{.i18n.Tr "repo.pulls.compare_base"}}: {{$.BaseName}}:{{$.BaseBranch}}</span>
- <i class="dropdown icon"></i>
- </div>
- <div class="menu">
- <div class="ui icon search input">
- <i class="filter icon"></i>
- <input name="search" placeholder="{{.i18n.Tr "repo.pulls.filter_branch"}}...">
- </div>
- <div class="scrolling menu">
- {{range .Branches}}
- <div class="item {{if eq $.BaseBranch .}}selected{{end}}" data-url="{{$.RepoLink}}/compare/{{EscapePound .}}...{{if not $.PullRequestCtx.SameRepo}}{{$.HeadUser.Name}}:{{end}}{{EscapePound $.HeadBranch}}">{{$.BaseName}}:{{.}}</div>
- {{end}}
- </div>
- </div>
- </div>
- ...
- <div class="ui floating filter dropdown">
- <div class="ui basic small button">
- <span class="text">{{.i18n.Tr "repo.pulls.compare_compare"}}: {{$.HeadUser.Name}}:{{$.HeadBranch}}</span>
- <i class="dropdown icon"></i>
- </div>
- <div class="menu">
- <div class="ui icon search input">
- <i class="filter icon"></i>
- <input name="search" placeholder="{{.i18n.Tr "repo.pulls.filter_branch"}}...">
- </div>
- <div class="scrolling menu">
- {{range .HeadBranches}}
- <div class="{{if eq $.HeadBranch .}}selected{{end}} item" data-url="{{$.RepoLink}}/compare/{{EscapePound $.BaseBranch}}...{{if not $.PullRequestCtx.SameRepo}}{{$.HeadUser.Name}}:{{end}}{{EscapePound .}}">{{$.HeadUser.Name}}:{{.}}</div>
- {{end}}
- </div>
- </div>
- </div>
- </div>
-
- {{if .IsNothingToCompare}}
- <div class="ui segment">
- {{.i18n.Tr "repo.pulls.nothing_to_compare"}}
- </div>
- {{else if .HasPullRequest}}
- <div class="ui segment">
- {{.i18n.Tr "repo.pulls.has_pull_request" $.RepoLink $.RepoRelPath .PullRequest.Index | Safe}}
- </div>
- {{else if eq .CommitCount 0 }}
- {{template "repo/commits_table" .}}
- {{template "repo/diff/box" .}}
- {{else}}
- {{template "repo/issue/new_form" .}}
- {{template "repo/commits_table" .}}
- {{template "repo/diff/box" .}}
- {{end}}
- </div>
-
- </div>
-</div>
-{{template "base/footer" .}}