mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-03 10:17:21 +00:00
buildman: Create a function to get number of built commits
Move this code into a function. This removes the last pylint error in the control module. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
f6df5edc8d
commit
1d0c55d83a
1 changed files with 25 additions and 9 deletions
|
@ -29,7 +29,24 @@ def get_plural(count):
|
||||||
"""Returns a plural 's' if count is not 1"""
|
"""Returns a plural 's' if count is not 1"""
|
||||||
return 's' if count != 1 else ''
|
return 's' if count != 1 else ''
|
||||||
|
|
||||||
def get_action_summary(is_summary, commits, selected, step, threads, jobs):
|
|
||||||
|
def count_build_commits(commits, step):
|
||||||
|
"""Calculate the number of commits to be built
|
||||||
|
|
||||||
|
Args:
|
||||||
|
commits (list of Commit): Commits to build or None
|
||||||
|
step (int): Step value for commits, typically 1
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Number of commits that will be built
|
||||||
|
"""
|
||||||
|
if commits:
|
||||||
|
count = len(commits)
|
||||||
|
return (count + step - 1) // step
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def get_action_summary(is_summary, commit_count, selected, threads, jobs):
|
||||||
"""Return a string summarising the intended action.
|
"""Return a string summarising the intended action.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -43,10 +60,8 @@ def get_action_summary(is_summary, commits, selected, step, threads, jobs):
|
||||||
Returns:
|
Returns:
|
||||||
Summary string.
|
Summary string.
|
||||||
"""
|
"""
|
||||||
if commits:
|
if commit_count:
|
||||||
count = len(commits)
|
commit_str = f'{commit_count} commit{get_plural(commit_count)}'
|
||||||
count = (count + step - 1) // step
|
|
||||||
commit_str = f'{count} commit{get_plural(count)}'
|
|
||||||
else:
|
else:
|
||||||
commit_str = 'current source'
|
commit_str = 'current source'
|
||||||
msg = (f"{'Summary of' if is_summary else 'Building'} "
|
msg = (f"{'Summary of' if is_summary else 'Building'} "
|
||||||
|
@ -83,8 +98,8 @@ def show_actions(series, why_selected, boards_selected, output_dir,
|
||||||
commits = series.commits
|
commits = series.commits
|
||||||
else:
|
else:
|
||||||
commits = None
|
commits = None
|
||||||
print(get_action_summary(False, commits, boards_selected, step, threads,
|
print(get_action_summary(False, count_build_commits(commits, step),
|
||||||
jobs))
|
boards_selected, threads, jobs))
|
||||||
print(f'Build directory: {output_dir}')
|
print(f'Build directory: {output_dir}')
|
||||||
if commits:
|
if commits:
|
||||||
for upto in range(0, len(series.commits), step):
|
for upto in range(0, len(series.commits), step):
|
||||||
|
@ -494,8 +509,9 @@ def run_builder(builder, commits, board_selected, options):
|
||||||
builder.gnu_make = gnu_make
|
builder.gnu_make = gnu_make
|
||||||
|
|
||||||
if not options.ide:
|
if not options.ide:
|
||||||
tprint(get_action_summary(options.summary, commits, board_selected,
|
commit_count = count_build_commits(commits, options.step)
|
||||||
options.step, options.threads, options.jobs))
|
tprint(get_action_summary(options.summary, commit_count, board_selected,
|
||||||
|
options.threads, options.jobs))
|
||||||
|
|
||||||
builder.SetDisplayOptions(
|
builder.SetDisplayOptions(
|
||||||
options.show_errors, options.show_sizes, options.show_detail,
|
options.show_errors, options.show_sizes, options.show_detail,
|
||||||
|
|
Loading…
Add table
Reference in a new issue