Skip to content

Commit f83ef3b

Browse files
committed
Working sha override for merge commit.
1 parent 37d226d commit f83ef3b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

assets/lib/commands/out.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ def output
4141
version = { 'ref' => sha }
4242
else
4343
pr = PullRequest.from_github(repo: repo, id: id)
44+
if sha == pr.merge_commit_sha
45+
# If the SHA that we have here is the merge commit's SHA,
46+
# we know that the correct SHA is the one at the tip of
47+
# the PR (which might be the same as the merge SHA if
48+
# there's no need for a merge).
49+
sha = pr.sha
50+
end
4451
metadata << { 'name' => 'url', 'value' => pr.url }
4552
version = { 'pr' => id, 'ref' => sha }
4653
end
@@ -77,7 +84,7 @@ def output
7784
File.read(commit_path, encoding: Encoding::UTF_8)
7885
else
7986
''
80-
end
87+
end
8188
Octokit.merge_pull_request(input.source.repo, id, commit_msg, merge_method: params.merge.method, accept: 'application/vnd.github.polaris-preview+json')
8289
metadata << { 'name' => 'merge', 'value' => params.merge.method }
8390
metadata << { 'name' => 'merge_commit_msg', 'value' => commit_msg }

assets/lib/pull_request.rb

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def sha
4747
@pr['head']['sha']
4848
end
4949

50+
def merge_commit_sha
51+
@pr['merge_commit_sha']
52+
end
53+
5054
def url
5155
@pr['html_url']
5256
end

0 commit comments

Comments
 (0)