Skip to content

Commit f2c7784

Browse files
committed
ICU-23231 Update scrub script for robustness and clarity
See #3713
1 parent cd53e18 commit f2c7784

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed

tools/scripts/scrub_issues/scrub_issues.py

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def create_test_files(base_directory):
7070
'output_file': 'icu4j/TODOs.txt'},
7171
{'subdir': 'icu4c/source',
7272
'match_string': 'logKnownIssue',
73-
'output_file': 'icu/source/logKnownIssue.txt'},
73+
'output_file': 'icu4c/source/logKnownIssue.txt'},
7474
{'subdir': 'icu4c/source',
7575
'match_string': 'TODO',
7676
'output_file': 'icu4c/source/TODOs.txt'},
@@ -93,7 +93,7 @@ def create_test_files(base_directory):
9393
result_lines = result.stdout.splitlines()
9494

9595
# This may include None items
96-
issue_details = [extract_issue_detail(str(line)) for line in result_lines]
96+
issue_details = [extract_issue_detail(base_directory, str(line)) for line in result_lines]
9797

9898
all_results.append([item['output_file'], issue_details])
9999

@@ -104,7 +104,7 @@ def create_test_files(base_directory):
104104
# Get the file name if it's a match
105105
file_linenum_re = re.compile(r'^([^:]+):(\d+)')
106106

107-
def extract_issue_detail(line):
107+
def extract_issue_detail(base_directory, line):
108108
code_file = None
109109
code_line = -1
110110
issue_detail = None
@@ -121,21 +121,20 @@ def extract_issue_detail(line):
121121
return None
122122

123123
issue_type = None
124+
short_file_path = ''
124125
if ki_search:
125126
issue_type = ki_search.group(1)
126127
issue_id = ki_search.group(2)
127128
issue_id = issue_id.replace('\"', '')
128129
comma_pos = issue_id.find(',')
129130
if comma_pos >= 0:
130131
issue_id = issue_id[0:comma_pos]
131-
try:
132-
short_file_path = code_file[code_file.find('/icu/'):]
133-
except BaseException as err:
134-
short_file_path = code_file
135-
pass
136132

137-
if comma_pos >= 0:
138-
issue_id = issue_id[0:comma_pos]
133+
# Use a shorter path name
134+
short_file_path = code_file.replace(base_directory, '')
135+
136+
if short_file_path == '':
137+
print('--- WHY??? %s' % line)
139138

140139
if code_file:
141140
issue_detail = [issue_id, issue_type, short_file_path, code_line]
@@ -202,20 +201,31 @@ def check_jira_status_for_all_issues(issue_dict, settings):
202201
if not status:
203202
# TODO: check if the issue id can be fixed
204203
try:
205-
int_id = int(issue)
206-
try_id = 'ICU-' + issue
204+
int_id = int(issue.replace('#', ''))
205+
try_id = 'ICU-%d' % int_id
207206
status = check_jira_issue(try_id)
208207

209208
if not status:
210209
# Try CLDR
211-
try_id = 'CLDR-' + issue
210+
try_id = 'CLDR-%d' % int_id
212211
status = check_jira_issue(try_id)
212+
213213
except BaseException as error:
214214
# Not a simple number. Try other replacements
215215
try_id = issue.replace('cldrbug:', 'CLDR-')
216216
if try_id != issue:
217217
status = check_jira_issue(try_id)
218218

219+
if not status:
220+
# Some items have 'Jira ' in the issue name
221+
try_id = issue.replace('Jira ', '')
222+
status = check_jira_issue(try_id)
223+
224+
if not status:
225+
# Some items have 'cldrbug:' in the issue name
226+
try_id = issue.replace('cldrbug: ', 'CLDR-')
227+
status = check_jira_issue(try_id)
228+
219229
if not status:
220230
logger.debug('Not in JIRA: issue "%s"', issue)
221231
problem_ids.append(issue)
@@ -282,27 +292,19 @@ def main(args):
282292
# Next, look at the status of all of these in JIRA
283293
closed_issue_ids, problem_ids, unresolved_ids = check_jira_status_for_all_issues(issue_dict, settings)
284294

285-
# Check on all the problem ids
286-
logger.info('----------------------------------------------------------------')
287-
logger.info('%d Closed ids: %s',
288-
len(closed_issue_ids), (closed_issue_ids))
289-
for id in sorted(closed_issue_ids):
290-
lines_from_grep = issue_dict[id]
291-
for line in lines_from_grep:
292-
logger.info(' %s', line)
293-
294-
295+
logger.info('')
295296
logger.info('----------------------------------------------------------------')
296297
logger.info('PROBLEM IDS: %d not found in JIRA' % (len(problem_ids)))
297298
for id in sorted(problem_ids):
298299
issues = issue_dict[id]
299-
logger.warning('Not in JIRA : "%s" (%d instances)', id, len(issues))
300+
logger.warning('Not in JIRA : missing id = "%s" (%d instances)', id, len(issues))
300301
if settings.detail_level != 'summary':
301302
show_detail(issue_dict, id)
302303

303304
for issue in issues:
304305
logger.debug(' %s', issue)
305306

307+
logger.info('')
306308
logger.info('----------------------------------------------------------------')
307309
logger.info('Unresolved IDS: %d still not "Done" in Jira' % (len(unresolved_ids)))
308310
for id in sorted(unresolved_ids):
@@ -311,6 +313,16 @@ def main(args):
311313
if settings.detail_level != 'summary':
312314
show_detail(issue_dict, issue_key)
313315

316+
# Check on all the problem ids
317+
logger.info('')
318+
logger.info('----------------------------------------------------------------')
319+
logger.info('%d Closed ids: %s',
320+
len(closed_issue_ids), (closed_issue_ids))
321+
for id in sorted(closed_issue_ids):
322+
lines_from_grep = issue_dict[id]
323+
for line in lines_from_grep:
324+
logger.info(' %s', line)
325+
314326
# Try to fix the comment in the file(s) for each resolved ID.
315327

316328
if __name__ == '__main__':

0 commit comments

Comments
 (0)