File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ import os
3+ import re
4+ from argparse import ArgumentParser
5+
6+ import github
7+
8+
9+ def extract_gitref (s ):
10+ """
11+ Extract git ref from a container registry tag or Helm chart version
12+
13+ Examples:
14+ - 2022.02.0 -> 2022.02.0
15+ - 2022.02.0-90.g0345a86 -> 0345a86
16+ - 0.2.0 -> 0.2.0
17+ - 0.2.0-n1011.hb49edf6 -> b49edf6
18+ - 0.2.0-0.dev.git.2752.h3450e52 -> 3450e52
19+ """
20+ m = re .match (r"[\d\.]+-[\w\.]+[gh]([0-9a-f]+)" , s )
21+ if m :
22+ return m .group (1 )
23+ return s
24+
25+
26+ token = os .getenv ("GITHUB_TOKEN" )
27+
28+ parser = ArgumentParser (description = "Summarise PRs from a repo" )
29+ parser .add_argument ("repo" , help = "The repository in format user/repo" )
30+ parser .add_argument ("start" , help = "commit or image/chart version from which to start" )
31+ parser .add_argument ("end" , help = "commit or image/chart version to which to end" )
32+
33+ args = parser .parse_args ()
34+
35+ gh = github .Github (token )
36+ r = gh .get_repo (args .repo )
37+
38+ start = extract_gitref (args .start )
39+ end = extract_gitref (args .end )
40+
41+ prs = set ()
42+ git_compare = r .compare (start , end )
43+ for c in git_compare .commits :
44+ s = gh .search_issues ("" , type = "pr" , repo = args .repo , sha = c .sha )
45+ prs .update (s )
46+
47+ for pr in sorted (prs ):
48+ print (f"- [#{ pr .number } ]({ pr .html_url } ) { pr .title } " )
You can’t perform that action at this time.
0 commit comments