Skip to content

Commit 987df33

Browse files
committed
Correctly determine commit sha to avoid rebuilding PMD
In case the branch name was a tag, the tag sha was used instead of the commit sha, which rebuilt PMD always.
1 parent effadde commit 987df33

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/pmdtester/builders/pmd_report_builder.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ def initialize(projects, options, branch_config, branch_name)
2525
def get_pmd_binary_file
2626
logger.info "#{@pmd_branch_name}: Start packaging PMD"
2727
Dir.chdir(@local_git_repo) do
28-
current_head_sha = Cmd.execute('git rev-parse HEAD')
29-
current_branch_sha = Cmd.execute("git rev-parse #{@pmd_branch_name}")
28+
current_head_sha = Cmd.execute('git rev-parse HEAD^{commit}')
29+
current_branch_sha = Cmd.execute("git rev-parse #{@pmd_branch_name}^{commit}")
3030

3131
@pmd_version = determine_pmd_version
3232

33+
logger.debug "pmd_version in HEAD: #{@pmd_version}, " \
34+
"head_sha=#{current_head_sha}, branch_sha=#{current_branch_sha}"
35+
3336
# in case we are already on the correct branch
3437
# and a binary zip already exists...
3538
if current_head_sha == current_branch_sha &&

test/test_pmd_report_builder.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ def record_expectations_project_build(error = false)
104104
def record_expectations(sha1_head, sha1_base, zip_file_exists)
105105
Dir.stubs(:getwd).returns('current-dir').once
106106
Dir.stubs(:chdir).with('target/repositories/pmd').yields.once
107-
PmdTester::Cmd.stubs(:execute).with('git rev-parse HEAD').returns(sha1_head).once
108-
PmdTester::Cmd.stubs(:execute).with('git rev-parse master').returns(sha1_base).once
107+
PmdTester::Cmd.stubs(:execute).with('git rev-parse HEAD^{commit}').returns(sha1_head).once
108+
PmdTester::Cmd.stubs(:execute).with('git rev-parse master^{commit}').returns(sha1_base).once
109109
PmdTester::Cmd.stubs(:execute).with('./mvnw -q -Dexec.executable="echo" ' \
110110
"-Dexec.args='${project.version}' " \
111111
'--non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec')

0 commit comments

Comments
 (0)