Skip to content

Commit b94e552

Browse files
committed
Add comparison url
1 parent bcfde4f commit b94e552

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/pmdtester/builders/summary_report_builder.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def write_index(target_root, base_details, patch_details, projects)
5757
end
5858

5959
env = {
60-
'comparison_url' => nil, # todo
60+
'comparison_url' => create_comparison_url(base_details, patch_details),
6161
'base' => to_liquid(base_details, BASE_CONFIG_NAME),
6262
'patch' => to_liquid(patch_details, PATCH_CONFIG_NAME),
6363
'projects' => projects
@@ -66,9 +66,15 @@ def write_index(target_root, base_details, patch_details, projects)
6666
render_and_write('project_index.html', "#{target_root}/index.html", env)
6767
end
6868

69+
def create_comparison_url(base_details, patch_details)
70+
base = CGI.escape(base_details.branch_name)
71+
patch = CGI.escape(patch_details.branch_last_sha)
72+
"https://github.com/pmd/pmd/compare/#{base}...#{patch}"
73+
end
74+
6975
def to_liquid(details, config_name)
7076
{
71-
'tree_url' => "https://github.com/pmd/pmd/tree/#{details.branch_last_sha}",
77+
'tree_url' => "https://github.com/pmd/pmd/tree/#{CGI.escape(details.branch_last_sha)}",
7278
'name' => details.branch_name,
7379
'tip' => {
7480
'sha' => details.branch_last_sha,

test/resources/summary_report_builder/expected_index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ <h2>Branch details</h2>
2828
<tbody>
2929
<tr>
3030
<td class="item">Branch info</td>
31-
<td><a href="https://github.com/pmd/pmd/tree/test sha">test_branch test sha</a>: test message</td>
31+
<td><a href="https://github.com/pmd/pmd/tree/test+sha">test_branch test sha</a>: test message</td>
3232
<td>
33-
<a href="https://github.com/pmd/pmd/tree/test sha">test_branch test sha</a>: test message
33+
<a href="https://github.com/pmd/pmd/tree/test+sha">test_branch test sha</a>: test message
3434
<span class="external-link-secondary"><a href="https://github.com/pmd/pmd/pull/42">PR #42</a></span>
35-
<span class="external-link-secondary"><a href="">[Compare]</a></span>
35+
<span class="external-link-secondary"><a href="https://github.com/pmd/pmd/compare/test_branch...test+sha">[Compare]</a></span>
3636
</td>
3737
</tr>
3838
<tr>

0 commit comments

Comments
 (0)