semantic-release / github

:octocat: semantic-release plugin to publish a GitHub release and comment on released Pull Requests/Issues
MIT License
405 stars 125 forks source link

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

Open juliangieseke opened 6 years ago

juliangieseke commented 6 years ago

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. 🎉

pvdlg commented 6 years ago

To add comments the plugin does the following:

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.

juliangieseke commented 6 years ago

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 🤔

pvdlg commented 6 years ago

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?

juliangieseke commented 6 years ago

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

pvdlg commented 6 years ago

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.

juliangieseke commented 6 years ago

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. 🤔

pvdlg commented 6 years ago

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.

juliangieseke commented 6 years ago

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

pvdlg commented 6 years ago

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 😃

C0ZEN commented 4 years ago

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.