github icon indicating copy to clipboard operation
github copied to clipboard

Recursively go through PRs when adding "included in release" message.

Open juliangieseke opened this issue 6 years ago • 10 comments

when working with feature branches, only the branch/PR itself gets a comment - it would be awesome if all PRs merged previously into feature branch also could get a comment. 🎉

juliangieseke avatar Sep 03 '18 09:09 juliangieseke

To add comments the plugin does the following:

  • Get all the commits in the current release (that's all the commit on the master branch since the last release)
  • Search for all PRs/Issues references in the commit messages and add a comment for each one
  • Search all the PRs that contains a commit that is part of the release and add a comment for each one
  • Search the body of each PR found previously and look for a closing keyword (like Fix #xyz) and add a comment for each issue found

Can you clarify in which exact scenario a comment is missing? Do you have a link to a repo where this problem happens? Please mention every step you followed, and provide links to related PRs/commits/issues.

pvdlg avatar Sep 03 '18 18:09 pvdlg

This PR merges feature branch into master - has comment: https://github.com/dcos/dcos-ui/pull/3154 This PR was merged into feature branch before, no comment: https://github.com/dcos/dcos-ui/pull/3151

We use rebase and merge and there was another issue with finding the first PR at all before 🤔

juliangieseke avatar Sep 03 '18 19:09 juliangieseke

A similar problem was fixed in https://github.com/semantic-release/github/releases/tag/v5.0.2. When the problematic case was merged which version of the plugin were you using?

pvdlg avatar Sep 03 '18 19:09 pvdlg

yeah, I reported that issue 😅we're using 5.0.2

juliangieseke avatar Sep 04 '18 13:09 juliangieseke

Oh ok sorry. So if I understand correctly, the PR dcos/dcos-ui#3151 was opened against the branch jg/DCOS-39896-service-region, then jg/DCOS-39896-service-region was merged into master.

Unfortunately it doesn't seems the GitHub API offer a way to trace back commits in such case.

The functionality relies on the Issue Search API that allow to find the parent PR of a commit. So when semantic-release runs it finds the commit e82a0c7, perform a search which returns the PR #3154. That works even though that commit has the sha d61848c when it was on the branch feature/DCOS-39895-services-region-info. The sha changed due to "Rebase and Merge" but the Search API can still make the connection.

The problem is there is no way (that I'm aware of) to figure out that the commit d61848c on branch feature/DCOS-39895-services-region-info came from the commit 14d19a1 on PR #3151. If you know a way to do that I can certainly look at implementing it. Otherwise I'm afraid it's not possible.

pvdlg avatar Sep 04 '18 17:09 pvdlg

jg/DCOS-39896-service-region got merged into feature/DCOS-39895-services-region-info and then feature/DCOS-39895-services-region-info got merged into master.

if your able to find the PR of the master commit on feature/DCOS-39895-services-region-info, isnt the same thing possible from feature/DCOS-39895-services-region-info to jg/DCOS-39896-service-region? basicly go through all of the commits recusively until you cant find a PR anymore. 🤔

juliangieseke avatar Sep 05 '18 12:09 juliangieseke

if your able to find the PR of the master commit on feature/DCOS-39895-services-region-info, isnt the same thing possible from feature/DCOS-39895-services-region-info to jg/DCOS-39896-service-region? basicly go through all of the commits recusively until you cant find a PR anymore. 🤔

It doesn't seems so...

Getting the commits from #3154:

curl https://api.github.com/repos/dcos/dcos-ui/pulls/3154/commits

// => "sha": "d61848c1232724e82c100b10746ff418e69c1682"

Searching for the sha of the commit in #3154:

curl https://api.github.com/search/issues?q=d61848c1232724e82c100b10746ff418e69c1682

// => "number": 3154

The search returns only #3154 and not #3151. So it seems that whatever GitHub keeps internally to make the link between master/e82a0c7 and feature/DCOS-39895-services-region-info/d61848c is not preserved for making the link between feature/DCOS-39895-services-region-info/d61848c and jg/DCOS-39896-service-region/14d19a1.

Basically what we would need is an API call or a sequence of API call that would get me from master/e82a0c7 to PR #3151.

pvdlg avatar Sep 05 '18 15:09 pvdlg

yup, agree - also wasnt able to find the missing link 😞

juliangieseke avatar Sep 06 '18 07:09 juliangieseke

If you think it worth it and if you have a way to make a feature request to GitHub so they add a way to do that in the API, please go ahead 😃

pvdlg avatar Sep 06 '18 19:09 pvdlg

I have something similar here: https://github.com/Sonia-corporation/il-est-midi-discord/pull/272. An issue is related: https://github.com/Sonia-corporation/il-est-midi-discord/issues/265

I was expecting a comment from the Bot nevertheless it did not occured. It this something that should work or not? Based on @pvdlg response I am not sure since the issue was never mentioned in a comment, only in GitHub directly.

C0ZEN avatar Apr 29 '20 11:04 C0ZEN