Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull Requests: add button to compare force pushed commits #22857

Merged
merged 1 commit into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,7 @@ issues.error_removing_due_date = "Failed to remove the due date."
issues.push_commit_1 = "added %d commit %s"
issues.push_commits_n = "added %d commits %s"
issues.force_push_codes = `force-pushed %[1]s from <a class="ui sha" href="%[3]s"><code>%[2]s</code></a> to <a class="ui sha" href="%[5]s"><code>%[4]s</code></a> %[6]s`
issues.force_push_compare = Compare
issues.due_date_form = "yyyy-mm-dd"
issues.due_date_form_add = "Add due date"
issues.due_date_form_edit = "Edit"
Expand Down
5 changes: 5 additions & 0 deletions templates/repo/issue/view_content/comments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,11 @@
{{$.locale.TrN (len .Commits) "repo.issues.push_commit_1" "repo.issues.push_commits_n" (len .Commits) $createdStr | Safe}}
{{end}}
</span>
{{if and .IsForcePush $.Issue.PullRequest.BaseRepo.Name}}
<span class="ui float right comparebox">
<a href="{{$.Issue.PullRequest.BaseRepo.Link}}/compare/{{PathEscape .OldCommit}}..{{PathEscape .NewCommit}}" rel="nofollow" class="ui compare label">{{$.locale.Tr "repo.issues.force_push_compare"}}</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I already wondered how you would solve the problem that a force-pushed commit might have been deleted by Git GC. Your approach works of course, as it will simply display a 404 or similar…


I'm wondering: Should we perhaps open the comparison in a new tab?
You probably want to continue using this tab, if you're already taking the time to go through the individual commit history…

</span>
{{end}}
</div>
{{if not .IsForcePush}}
{{template "repo/commits_list_small" dict "comment" . "root" $}}
Expand Down
11 changes: 11 additions & 0 deletions web_src/less/_repository.less
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,17 @@
margin-top: 4px;
}

.comparebox {
line-height: 32px;
vertical-align: middle;

.compare.label {
font-size: 1rem;
margin: 0;
border: 1px solid var(--color-light-border);
}
}

.comment-form-reply .footer {
padding-bottom: 1em;
}
Expand Down