Hub: PR List from tag instead of branch

Created on 22 Apr 2019  Â·  1Comment  Â·  Source: github/hub

Hey!

I would like to get list of all PRs since tag.
Based on https://hub.github.com/hub-pr.1.html - it's possible to use --head or --branch, but not tag.

When I try

LAST_MAJOR_VERSION=$(git describe --abbrev=0 --tags)
echo "$(hub pr list -h $LAST_MAJOR_VERSION -s closed -L 200)"

it shows nothing even tho git describe --abbrev=0 --tags shows correctly last production tag.

This would be super useful for creating changelogs as it could give me list of all closed PRs since last release.

Any idea or extension to hub pr list coming?

Thank you! :)

Most helpful comment

Interesting idea! This is not possible with hub. We can only return the results that GitHub API provides us, and the GitHub API has no functionality to query PRs based on whether they were merged into a branch that eventually got a release based off it. The --head argument merely queries PRs based on the name of their head branch at the time that the PR was opened. The names of those branches have no connection to the git tag that eventually gets created.

You can potentially use git to answer your question:

git log --merges --grep 'Merge pull request' --pretty=format:%s v1.2.0..v1.3.0

This lists all merges happening between releases v1.2.0 – v1.3.0 and lists those that start with "Merge pull request #...". You can use that to generate a list of merged PRs for a specific release. Note that this method is not perfect, but gets close to what you want.

>All comments

Interesting idea! This is not possible with hub. We can only return the results that GitHub API provides us, and the GitHub API has no functionality to query PRs based on whether they were merged into a branch that eventually got a release based off it. The --head argument merely queries PRs based on the name of their head branch at the time that the PR was opened. The names of those branches have no connection to the git tag that eventually gets created.

You can potentially use git to answer your question:

git log --merges --grep 'Merge pull request' --pretty=format:%s v1.2.0..v1.3.0

This lists all merges happening between releases v1.2.0 – v1.3.0 and lists those that start with "Merge pull request #...". You can use that to generate a list of merged PRs for a specific release. Note that this method is not perfect, but gets close to what you want.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DennisSchiefer picture DennisSchiefer  Â·  4Comments

dsifford picture dsifford  Â·  4Comments

cbeams picture cbeams  Â·  4Comments

eromoe picture eromoe  Â·  4Comments

jfritzbarnes picture jfritzbarnes  Â·  3Comments