@@ -29,8 +29,15 @@ def get_branch_tag_sha_list(repo, branch):
2929 tags = []
3030 for line in results .stdout .split (b'\n ' ):
3131 if b'tag: resf_kernel' in line :
32- print (line )
3332 tags .append (line .split (b' ' )[0 ])
33+
34+ # Print summary instead of all tags
35+ if len (tags ) > 0 :
36+ print (f'[rolling release update] Found { len (tags )} RESF kernel tags' )
37+ if DEBUG :
38+ for line_tag in tags :
39+ print (f' { line_tag .decode ()} ' )
40+
3441 return tags
3542
3643def check_for_fips_protected_changes (repo , branch , common_tag ):
@@ -136,10 +143,12 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
136143 print ('[rolling release update] Rolling Product: ' , rolling_product )
137144
138145 old_rolling_branch_tags = get_branch_tag_sha_list (repo , args .old_rolling_branch )
139- print ('[rolling release update] Old Rolling Branch Tags: ' , old_rolling_branch_tags )
146+ if DEBUG :
147+ print ('[rolling release update] Old Rolling Branch Tags: ' , old_rolling_branch_tags )
140148
141149 new_base_branch_tags = get_branch_tag_sha_list (repo , args .new_base_branch )
142- print ('[rolling release update] New Base Branch Tags: ' , new_base_branch_tags )
150+ if DEBUG :
151+ print ('[rolling release update] New Base Branch Tags: ' , new_base_branch_tags )
143152
144153 latest_resf_sha = find_common_tag (old_rolling_branch_tags , new_base_branch_tags )
145154 print ('[rolling release update] Latest RESF tag sha: ' , latest_resf_sha )
@@ -179,14 +188,15 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
179188
180189 print ('[rolling release update] Last RESF tag sha: ' , latest_resf_sha )
181190
182- print ('[rolling release update] Total Commit in old branch: ' , len (rolling_commit_map ))
183- print ('{ "CIQ COMMMIT" : "UPSTREAM COMMMIT" }' )
184- if len (rolling_commit_map ) > 10 :
185- print ('Printing first 5 and last 5 commits' )
186- print (json .dumps ({k : rolling_commit_map [k ] for k in list (rolling_commit_map )[:5 ]}, indent = 2 ))
187- print (json .dumps ({k : rolling_commit_map [k ] for k in list (rolling_commit_map )[- 5 :]}, indent = 2 ))
188- else :
189- print (json .dumps (rolling_commit_map , indent = 2 ))
191+ print (f'[rolling release update] Total commits in old branch: { len (rolling_commit_map )} ' )
192+ if DEBUG :
193+ print ('{ "CIQ COMMIT" : "UPSTREAM COMMIT" }' )
194+ if len (rolling_commit_map ) > 10 :
195+ print ('Printing first 5 and last 5 commits' )
196+ print (json .dumps ({k : rolling_commit_map [k ] for k in list (rolling_commit_map )[:5 ]}, indent = 2 ))
197+ print (json .dumps ({k : rolling_commit_map [k ] for k in list (rolling_commit_map )[- 5 :]}, indent = 2 ))
198+ else :
199+ print (json .dumps (rolling_commit_map , indent = 2 ))
190200
191201 print ('[rolling release update] Checking out new base branch: ' , args .new_base_branch )
192202 repo .git .checkout (args .new_base_branch )
@@ -198,27 +208,30 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
198208 new_rolling_branch_kernel = ''
199209 for line in results .stdout .split (b'\n ' ):
200210 if b'tag: resf_kernel' in line :
201- print (line )
211+ if DEBUG :
212+ print (line )
202213 r = re .match (b'.*(?P<vendor>.*)_kernel-(?P<kernel_ver>[0-9.-]*el[0-9]{1,2}_[0-9]*)' , line )
203- print (r )
204214 if r :
205215 new_rolling_branch_kernel = r .group ('kernel_ver' )
216+ if DEBUG :
217+ print (f'[rolling release update] Matched kernel version: { new_rolling_branch_kernel .decode ()} ' )
206218 break
207219
208220 if args .demo :
209221 new_rolling_branch_kernel = f'demo_{ rolling_product } /{ new_rolling_branch_kernel .decode ()} '
210222 else :
211223 new_rolling_branch_kernel = f'{ rolling_product } /{ new_rolling_branch_kernel .decode ()} '
212- print ('[rolling release update} New Branch to create ' , new_rolling_branch_kernel )
224+ print (f '[rolling release update] New Branch to create: { new_rolling_branch_kernel } ' )
213225
214- print ('[rolling release update] Check if branch Exists: ' , new_rolling_branch_kernel )
226+ if DEBUG :
227+ print (f'[rolling release update] Check if branch exists: { new_rolling_branch_kernel } ' )
215228 results = subprocess .run (['git' , 'show-ref' , '--quiet' , f'refs/heads/{ new_rolling_branch_kernel } ' ],
216229 stderr = subprocess .PIPE , stdout = subprocess .PIPE , cwd = args .repo )
217230 if results .returncode == 0 :
218- print (f'Branch { new_rolling_branch_kernel } already exists' )
231+ print (f'[rolling release update] ERROR: Branch { new_rolling_branch_kernel } already exists' )
219232 exit (1 )
220233 else :
221- print (f'Branch { new_rolling_branch_kernel } does not exists creating ' )
234+ print (f'[rolling release update] Creating new branch: { new_rolling_branch_kernel } ' )
222235 results = subprocess .run (['git' , 'checkout' , '-b' , new_rolling_branch_kernel ], stderr = subprocess .PIPE ,
223236 stdout = subprocess .PIPE , cwd = args .repo )
224237 if results .returncode != 0 :
@@ -246,14 +259,15 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
246259 new_base_commit_map [ciq_commit ] = upstream_commit
247260 new_base_commit_map_rev [upstream_commit ] = ciq_commit
248261
249- print ('[rolling release update] Total Commit in new branch: ' , len (new_base_commit_map ))
250- print ('{ "CIQ COMMMIT" : "UPSTREAM COMMMIT" }' )
251- if len (new_base_commit_map ) > 10 :
252- print ('Printing first 5 and last 5 commits' )
253- print (json .dumps ({k : new_base_commit_map [k ] for k in list (new_base_commit_map )[:5 ]}, indent = 2 ))
254- print (json .dumps ({k : new_base_commit_map [k ] for k in list (new_base_commit_map )[- 5 :]}, indent = 2 ))
255- else :
256- print (json .dumps (new_base_commit_map , indent = 2 ))
262+ print (f'[rolling release update] Total commits in new branch: { len (new_base_commit_map )} ' )
263+ if DEBUG :
264+ print ('{ "CIQ COMMIT" : "UPSTREAM COMMIT" }' )
265+ if len (new_base_commit_map ) > 10 :
266+ print ('Printing first 5 and last 5 commits' )
267+ print (json .dumps ({k : new_base_commit_map [k ] for k in list (new_base_commit_map )[:5 ]}, indent = 2 ))
268+ print (json .dumps ({k : new_base_commit_map [k ] for k in list (new_base_commit_map )[- 5 :]}, indent = 2 ))
269+ else :
270+ print (json .dumps (new_base_commit_map , indent = 2 ))
257271
258272 print ('[rolling release update] Checking if any of the commits from the old rolling release are already present in the new base branch' )
259273 commits_to_remove = {}
@@ -266,20 +280,28 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
266280 commits_to_remove [ciq_commit ] = upstream_commit
267281
268282
269- print ('[rolling release update] Removing commits from the new branch' )
270- for ciq_commit , upstream_commit in commits_to_remove .items ():
271- del rolling_commit_map [ciq_commit ]
272- if args .verbose_git_show :
273- print (repo .git .show (ciq_commit ))
274- else :
275- print (repo .git .show ('--pretty=oneline' , '-s' , ciq_commit ))
283+ print (f'[rolling release update] Found { len (commits_to_remove )} duplicate commits to remove' )
284+ if commits_to_remove :
285+ print ('[rolling release update] Removing duplicate commits:' )
286+ for ciq_commit , upstream_commit in commits_to_remove .items ():
287+ del rolling_commit_map [ciq_commit ]
288+ if args .verbose_git_show :
289+ print (repo .git .show (ciq_commit ))
290+ else :
291+ print (f' - { repo .git .show ("--pretty=oneline" , "-s" , ciq_commit )} ' )
276292
277- print ('[rolling release update] Applying the remaining commits to the new branch' )
293+ print (f'[rolling release update] Applying { len (rolling_commit_map )} remaining commits to the new branch' )
294+ commits_applied = 0
278295 for ciq_commit , upstream_commit in reversed (rolling_commit_map .items ()):
279- print ('Applying commit ' , repo .git .show ('--pretty="%H %s"' , '-s' , ciq_commit ))
296+ commits_applied += 1
297+ commit_info = repo .git .show ('--pretty=%h %s' , '-s' , ciq_commit )
298+ print (f' [{ commits_applied } /{ len (rolling_commit_map )} ] { commit_info } ' )
280299 result = subprocess .run (['git' , 'cherry-pick' , '-s' , ciq_commit ], stderr = subprocess .PIPE ,
281300 stdout = subprocess .PIPE , cwd = args .repo )
282301 if result .returncode != 0 :
283- print (result .stderr .split (b'\n ' ))
302+ print (f'[rolling release update] ERROR: Failed to cherry-pick commit { ciq_commit } ' )
303+ print (result .stderr .decode ('utf-8' ))
284304 exit (1 )
285305
306+ print (f'[rolling release update] Successfully applied all { commits_applied } commits' )
307+
0 commit comments