1
1
#! /usr/bin/python3
2
- import subprocess
3
2
import argparse
3
+ import subprocess
4
4
from argparse import RawTextHelpFormatter
5
5
6
+
6
7
def get_git_log (start_sha , end_sha , prefixes ):
7
8
try :
8
9
# Run the git log command with output format <commit hash> -- <Title>
@@ -13,26 +14,27 @@ def get_git_log(start_sha, end_sha, prefixes):
13
14
check = True ,
14
15
text = True
15
16
)
16
-
17
+
17
18
# Split the result into lines
18
19
log_lines = result .stdout .split ('\n ' )
19
-
20
+
20
21
# Initialize a dictionary to hold commits by prefix
21
22
commits_by_prefix = {prefix : [] for prefix in prefixes }
22
-
23
+
23
24
# Filter and group commits based on the prefixes
24
25
for line in log_lines :
25
26
for prefix in prefixes :
26
27
if prefix in line :
27
28
commits_by_prefix [prefix ].append (line )
28
29
break
29
-
30
+
30
31
return commits_by_prefix
31
-
32
+
32
33
except subprocess .CalledProcessError as e :
33
34
print (f"Error running git log: { e } " )
34
35
return {}
35
36
37
+
36
38
def main ():
37
39
parser = argparse .ArgumentParser (formatter_class = RawTextHelpFormatter , description = """
38
40
This script will parse git logs for our silabs prefixes ([SL-UP], [SL-TEMP], [SL-ONLY] or [CSA-CP]) between the commit SHAs provided in parameters
@@ -41,7 +43,7 @@ def main():
41
43
[PREFIX] commits:
42
44
<full_commit_sha> -- <Commit_Title>
43
45
""" ,
44
- epilog = """
46
+ epilog = """
45
47
Post result developer actions:
46
48
commits grouped under [SL-UP] shall be upstream the CSA master.
47
49
commits grouped under [SL-ONLY] shall be cherry-picked to matter_sdk main branch.
@@ -52,7 +54,7 @@ def main():
52
54
parser .add_argument ('end_sha' , type = str , help = 'The ending commit SHA' )
53
55
54
56
args = parser .parse_args ()
55
-
57
+
56
58
start_sha = args .start_sha
57
59
end_sha = args .end_sha
58
60
prefixes = ["[SL-UP]" , "[SL-TEMP]" , "[SL-ONLY]" , "[CSA-CP]" ]
@@ -64,5 +66,6 @@ def main():
64
66
print (commit )
65
67
print ()
66
68
69
+
67
70
if __name__ == "__main__" :
68
- main ()
71
+ main ()
0 commit comments