Skip to content

Commit 6740a99

Browse files
committed
Fix wrong PR number env var
1 parent e875e4e commit 6740a99

File tree

6 files changed

+14
-12
lines changed

6 files changed

+14
-12
lines changed

lib/pmdtester.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module PmdTester
3434
VERSION = '1.1.0-SNAPSHOT'
3535
BASE = 'base'
3636
PATCH = 'patch'
37+
PR_NUM_ENV_VAR = 'PMD_CI_PULL_REQUEST_NUMBER' # see PmdBranchDetail
3738

3839
def logger
3940
PmdTester.logger

lib/pmdtester/builders/summary_report_builder.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ def write_index(target_root, base_details, patch_details, projects)
4747
}
4848
end
4949

50-
prnum = ENV['TRAVIS_PULL_REQUEST']
5150
env = {
52-
'comparison_url' => nil,
51+
'comparison_url' => nil, # todo
5352
'base' => to_liquid(base_details),
5453
'patch' => to_liquid(patch_details),
55-
'pr_number' => prnum == 'false' ? nil : prnum,
5654
'projects' => projects
5755
}
5856
logger.info 'Writing /index.html...'
@@ -70,7 +68,8 @@ def to_liquid(details)
7068
'execution_time' => details.execution_time,
7169
'jdk_info' => details.jdk_version,
7270
'locale' => details.language,
73-
'config_url' => 'todo'
71+
'config_url' => 'todo', # todo
72+
'pr_number' => details.pull_request
7473
}
7574
end
7675
end

lib/pmdtester/pmd_branch_detail.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ def initialize(branch_name)
2929
@execution_time = 0
3030
# the result of command 'java -version' is going to stderr
3131
@jdk_version = Cmd.stderr_of('java -version')
32-
@language = ENV['LANG']
33-
@pull_request = ENV['TRAVIS_PULL_REQUEST']
32+
@language = ENV['LANG'] # the locale
33+
34+
prnum = ENV[PR_NUM_ENV_VAR]
35+
@pull_request = prnum == 'false' ? nil : prnum
3436
end
3537

3638
def self.load(branch_name, logger)

resources/project_index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ <h2>Branch details</h2>
2929
<td><a href="{{base.tree_url}}">{{base.name}} {{ base.tip.sha | truncate: 8, "" }}</a>: {{ base.tip.message }}</td>
3030
<td>
3131
<a href="{{patch.tree_url}}">{{patch.name}} {{ patch.tip.sha | truncate: 8, "" }}</a>: {{ patch.tip.message }}
32-
{% if pr_number %}
33-
<span class="external-link-secondary"><a href="https://github.com/pmd/pmd/pull/{{pr_number}}">PR #{{pr_number}}</a></span>
32+
{% if patch.pr_number %}
33+
<span class="external-link-secondary"><a href="https://github.com/pmd/pmd/pull/{{patch.pr_number}}">PR #{{patch.pr_number}}</a></span>
3434
{% endif %}
3535
<span class="external-link-secondary"><a href="{{ comparison_url }}">[Compare]</a></span>
3636
</td>

test/resources/summary_report_builder/expected_index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h2>Branch details</h2>
2929
<td><a href="https://github.com/pmd/pmd/tree/test sha">test_branch test sha</a>: test message</td>
3030
<td>
3131
<a href="https://github.com/pmd/pmd/tree/test sha">test_branch test sha</a>: test message
32-
32+
<span class="external-link-secondary"><a href="https://github.com/pmd/pmd/pull/42">PR #42</a></span>
3333
<span class="external-link-secondary"><a href="">[Compare]</a></span>
3434
</td>
3535
</tr>

test/test_pmd_branch_detail.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
# Unit test class for PmdTester::PmdBranchDetail
66
class TestPmdBranchDetail < Test::Unit::TestCase
77
def setup
8-
@old_pr = ENV['TRAVIS_PULL_REQUEST']
8+
@old_pr = ENV[PmdTester::PR_NUM_ENV_VAR]
99
end
1010

1111
def cleanup
12-
ENV['TRAVIS_PULL_REQUEST'] = @old_pr
12+
ENV[PmdTester::PR_NUM_ENV_VAR] = @old_pr
1313
end
1414

1515
def test_save_and_load
16-
ENV['TRAVIS_PULL_REQUEST'] = '1234'
16+
ENV[PmdTester::PR_NUM_ENV_VAR] = '1234'
1717
details = PmdTester::PmdBranchDetail.new('test_branch')
1818
details.branch_last_message = 'test message'
1919
details.branch_last_sha = 'test sha'

0 commit comments

Comments
 (0)