3434REAPPLY_RE = r'^Reapply "Updated dependency \'([^\']+)\' from version (\S+) to (\S+)"'
3535
3636
37- def fetch_git_output (args ):
37+ def fetch_git_output (path , args ):
3838 return subprocess .run (
39- args ,
39+ [ "git" , "-C" , f" { path } " ] + args ,
4040 stdout = subprocess .PIPE ,
4141 check = True ,
4242 ).stdout .splitlines (keepends = True )
@@ -49,10 +49,8 @@ def collect_version_updates(repos, git_args):
4949 dep_history : dict [str , list [tuple [str , str ]]] = {}
5050 for repo in repos :
5151 for raw in fetch_git_output (
52+ os .path .join (os .getcwd (), repo ),
5253 [
53- "git" ,
54- "-C" ,
55- f"{ os .path .join (os .getcwd (), repo )} " ,
5654 "log" ,
5755 "--no-merges" ,
5856 "--reverse" ,
@@ -104,16 +102,14 @@ def add_entry(sha, msg):
104102 subject = "" .join (
105103 line .decode ()
106104 for line in fetch_git_output (
105+ os .path .join (os .getcwd (), repo ),
107106 [
108- "git" ,
109- "-C" ,
110- f"{ os .path .join (os .getcwd (), repo )} " ,
111107 "log" ,
112108 "--format=%B" ,
113109 "-n" ,
114110 "1" ,
115111 sha ,
116- ]
112+ ],
117113 )
118114 )
119115
@@ -126,13 +122,13 @@ def add_entry(sha, msg):
126122 body = parts [1 ].strip () if len (parts ) > 1 else ""
127123
128124 TOKEN_PATTERNS = [
129- r"^ Changelog:" ,
130- r"^ Signed-off-by:" ,
131- r"^ Co-authored-by:" ,
132- r"^ Ticket:" ,
133- r"^ \(cherry picked from commit [0-9a-f]+\)" ,
134- r"^ Cancel-Changelog:\s*[0-9a-f]+" ,
135- r"^ This reverts commit [0-9a-f]+" ,
125+ r"Changelog:" ,
126+ r"Signed-off-by:" ,
127+ r"Co-authored-by:" ,
128+ r"Ticket:" ,
129+ r"\(cherry picked from commit [0-9a-f]+\)" ,
130+ r"Cancel-Changelog:\s*[0-9a-f]+" ,
131+ r"This reverts commit [0-9a-f]+" ,
136132 ]
137133 token_re = re .compile ("|" .join (TOKEN_PATTERNS ), re .IGNORECASE )
138134
@@ -146,27 +142,27 @@ def add_entry(sha, msg):
146142 if current_token :
147143 trailers [current_token ] = "\n " .join (collected_lines ).strip ()
148144
149- if re .match (r"^ Changelog:" , stripped , re .IGNORECASE ):
145+ if re .match (r"Changelog:" , stripped , re .IGNORECASE ):
150146 current_token = "Changelog"
151- first_val = re .sub (r"^ Changelog:\s*" , "" , stripped , flags = re .IGNORECASE )
147+ first_val = re .sub (r"Changelog:\s*" , "" , stripped , flags = re .IGNORECASE )
152148 collected_lines = [first_val ] if first_val else []
153149
154150 elif m := re .match (
155- r"^ \(cherry picked from commit ([0-9a-f]+)\)" , stripped , re .IGNORECASE
151+ r"\(cherry picked from commit ([0-9a-f]+)\)" , stripped , re .IGNORECASE
156152 ):
157153 trailers ["CherryPick" ] = m and m .group (1 )
158154 current_token = None
159155 collected_lines = []
160156
161157 elif m := re .match (
162- r"^ Cancel-Changelog:\s*([0-9a-f]+)" , stripped , re .IGNORECASE
158+ r"Cancel-Changelog:\s*([0-9a-f]+)" , stripped , re .IGNORECASE
163159 ):
164160 trailers ["Cancel" ] = m and m .group (1 )
165161 current_token = None
166162 collected_lines = []
167163
168164 elif m := re .match (
169- r"^ This reverts commit ([0-9a-f]+)" , stripped , re .IGNORECASE
165+ r"This reverts commit ([0-9a-f]+)" , stripped , re .IGNORECASE
170166 ):
171167 trailers ["Cancel" ] = m and m .group (1 )
172168 current_token = None
@@ -204,11 +200,11 @@ def add_entry(sha, msg):
204200
205201 if "Changelog" in trailers :
206202 changelog_val = trailers ["Changelog" ]
207- if re .match (r"^ Title[ .]*$ " , changelog_val , re .IGNORECASE ):
203+ if re .match (r"Title[ .]*" , changelog_val , re .IGNORECASE ):
208204 add_entry (sha , title )
209- elif re .match (r"^ (Commit|Body)[ .]*$ " , changelog_val , re .IGNORECASE ):
205+ elif re .match (r"(Commit|Body)[ .]*" , changelog_val , re .IGNORECASE ):
210206 add_entry (sha , clean_commit_body )
211- elif re .match (r"^ None[ .]*$ " , changelog_val , re .IGNORECASE ):
207+ elif re .match (r"None[ .]*" , changelog_val , re .IGNORECASE ):
212208 pass
213209 else :
214210 add_entry (sha , changelog_val )
@@ -224,10 +220,8 @@ def parse_git_log(repos, git_args):
224220
225221 for repo in repos :
226222 for raw_sha in fetch_git_output (
223+ os .path .join (os .getcwd (), repo ),
227224 [
228- "git" ,
229- "-C" ,
230- f"{ os .path .join (os .getcwd (), repo )} " ,
231225 "rev-list" ,
232226 "--no-merges" ,
233227 "--reverse" ,
0 commit comments