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

comment on PRs that used merge commits #315

Merged
merged 1 commit into from
Feb 4, 2025
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
4 changes: 3 additions & 1 deletion lib/kennel/github_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def initialize(token, ref: "HEAD")
@token = token
commit = Utils.capture_sh("git show #{ref}")
@sha = commit[/^Merge: \S+ (\S+)/, 1] || commit[/\Acommit (\S+)/, 1] || raise("Unable to find commit")
@pr = commit[/^\s+.*\(#(\d+)\)/, 1] # from squash
@pr =
commit[/^\s+.*\(#(\d+)\)/, 1] || # from squash
commit[/^\s+Merge pull request #(\d+)/, 1] # from merge with unmodified commit message
@repo_part = ENV["GITHUB_REPOSITORY"] || begin
origin = ENV["PROJECT_REPOSITORY"] || Utils.capture_sh("git remote -v").split("\n").first
origin[%r{github\.com[:/](\S+?)(\.git|$)}, 1] || raise("no origin found in #{origin}")
Expand Down
9 changes: 8 additions & 1 deletion test/kennel/github_reporter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,20 @@
reporter.instance_variable_get(:@repo_part).must_equal "foo/bar"
end

it "can create PR comments" do
it "can create PR comments for squash" do
show_response << "\n foo (#123)"
request = stub_request(:post, "https://api.github.com/repos/foo/bar/issues/123/comments").to_return(status: 201)
Kennel::Console.capture_stdout { reporter.report { Kennel.out.puts "HEY" } }
assert_requested request
end

it "can create PR comments for merge" do
show_response << "\n Merge pull request #123"
request = stub_request(:post, "https://api.github.com/repos/foo/bar/issues/123/comments").to_return(status: 201)
Kennel::Console.capture_stdout { reporter.report { Kennel.out.puts "HEY" } }
assert_requested request
end

it "can create merge comments" do
show_response.replace "commit: nope\nMerge: foo abcd"
request = stub_request(:post, "https://api.github.com/repos/foo/bar/commits/abcd/comments").to_return(status: 201)
Expand Down