sorin
sorin

Reputation: 170470

How to get all merged pull requests since last tag was added using github3.py?

I am trying to identify all merged pull-requests that happened since last release was made. A release always has a tag, so the logic is to find any pull-requests that happened after that tag was created.

Apparently the pull-request API does not allow to filter by tags, not even the commits ones.

I guess that if I find a way to query all commits that happened after a particular tag, I may detect which pull-requests produced them (i do not care about direct pushes).

Details:

I want this in order to be able to produce some draft release nodes, and all the data I need is the list of PRs that were merged.

Upvotes: 1

Views: 1145

Answers (1)

sorin
sorin

Reputation: 170470

I ended up using gitpython to perform a local query that returned me the commits. Example at https://github.com/pycontribs/tender/blob/master/tender/__main__.py#L133-L145 but the main code looks like

rev = f"{tag}..HEAD"
for commit in self.git.iter_commits(rev=rev):
  result[commit.hexsha] = commit

Upvotes: 0

Related Questions