Skip to content

[Buildbot] fix usage of buildbot outside of repo#1727

Merged
tdavidcl merged 1 commit intoShamrock-code:mainfrom
tdavidcl:patch-2026-03-25-21-58
Mar 25, 2026
Merged

[Buildbot] fix usage of buildbot outside of repo#1727
tdavidcl merged 1 commit intoShamrock-code:mainfrom
tdavidcl:patch-2026-03-25-21-58

Conversation

@tdavidcl
Copy link
Copy Markdown
Member

No description provided.

@github-actions
Copy link
Copy Markdown
Contributor

Thanks @tdavidcl for opening this PR!

You can do multiple things directly here:
1 - Comment pre-commit.ci run to run pre-commit checks.
2 - Comment pre-commit.ci autofix to apply fixes.
3 - Add label autofix.ci to fix authorship & pre-commit for every commit made.
4 - Add label light-ci to only trigger a reduced & faster version of the CI (need the full one before merge).
5 - Add label trigger-ci to create an empty commit to trigger the CI.

Once the workflow completes a message will appear displaying informations related to the run.

Also the PR gets automatically reviewed by gemini, you can:
1 - Comment /gemini review to trigger a review
2 - Comment /gemini summary for a summary
3 - Tag it using @gemini-code-assist either in the PR or in review comments on files

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves the robustness of the buildbot utility's git status reporting mechanism. By migrating from os.popen to the more modern and flexible subprocess module for executing git commands, and by adding comprehensive error handling, the utility can now operate more reliably in diverse environments, including those where git repositories are not present, ensuring a smoother user experience.

Highlights

  • Git Command Execution: Replaced the use of os.popen with subprocess.run for executing the git log command, enhancing reliability and control over process execution.
  • Error Handling: Implemented a try-except block around git command execution to gracefully handle situations where git commands might fail, such as when the utility is run outside a git repository, preventing crashes and providing a warning message instead.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the print_buildbot_info function in buildbot/lib/buildbot.py to use subprocess.run for executing git log commands, replacing the less secure and less robust os.popen. It also introduces a try-except block to handle potential errors during git status retrieval, printing a warning if the status cannot be obtained. Review feedback indicates a bug where the git_head variable is duplicated in the output when multiple heads are present. Additionally, it's suggested to update the git diff-index command to also use subprocess.run for consistency and improved error handling, and to refine the exception handling to catch more specific exceptions instead of a generic Exception.

Comment on lines +80 to +81
git_head = (
"\033[1;92m" + git_head[0] + "\033[0;0m , \033[1;91m" + git_head[0] + "\033[0;0m"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The git_head variable is duplicated in the string formatting when len(git_head) > 1. It appears there might be an intention to display multiple heads or branches, but currently, it prints the first element twice. If there are multiple heads (e.g., HEAD -> main, origin/main), you should display git_head[0] and git_head[1] (or iterate through git_head if more are possible).

Suggested change
git_head = (
"\033[1;92m" + git_head[0] + "\033[0;0m , \033[1;91m" + git_head[0] + "\033[0;0m"
git_head = (
"\033[1;92m" + git_head[0] + "\033[0;0m , \033[1;91m" + git_head[1] + "\033[0;0m"
)

print(" \033[1;93mcommit \033[0;0m: ", git_hash)
print(" \033[1;36mHEAD \033[0;0m: ", git_head)
print(" \033[1;31mmodified files\033[0;0m (since last commit):")
print(os.popen('git diff-index --name-only HEAD -- | sed "s/^/ /g"').read())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The git diff-index command still uses os.popen. For consistency and improved error handling, it's recommended to use subprocess.run for all external command executions, similar to how git log was updated. This also allows for better error handling and avoids shell injection risks associated with os.popen.

Suggested change
print(os.popen('git diff-index --name-only HEAD -- | sed "s/^/ /g"').read())
r_diff = subprocess.run(
["git", "diff-index", "--name-only", "HEAD", "--"],
capture_output=True,
text=True,
check=True,
)
modified_files = "".join([" " + line for line in r_diff.stdout.splitlines(keepends=True)])
print(modified_files)

@github-actions
Copy link
Copy Markdown
Contributor

Workflow report

workflow report corresponding to commit fe76c84
Commiter email is timothee.davidcleris@proton.me
GitHub page artifact URL GitHub page artifact link (can expire)

Pre-commit check report

Pre-commit check: ✅

trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check for merge conflicts................................................Passed
check that executables have shebangs.....................................Passed
check that scripts with shebangs are executable..........................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check for broken symlinks................................................Passed
check yaml...............................................................Passed
detect private key.......................................................Passed
No-tabs checker..........................................................Passed
Tabs remover.............................................................Passed
Validate GitHub Workflows................................................Passed
clang-format.............................................................Passed
ruff check...............................................................Passed
ruff format..............................................................Passed
Check doxygen headers....................................................Passed
Check license headers....................................................Passed
Check #pragma once.......................................................Passed
Check SYCL #include......................................................Passed
No ssh in git submodules remote..........................................Passed
No UTF-8 in files (except for authors)...................................Passed

Test pipeline can run.

Clang-tidy diff report

No relevant changes found.
Well done!

You should now go back to your normal life and enjoy a hopefully sunny day while waiting for the review.

Doxygen diff with main

Removed warnings : 0
New warnings : 0
Warnings count : 8366 → 8366 (0.0%)

Detailed changes :

@tdavidcl tdavidcl merged commit 0c12011 into Shamrock-code:main Mar 25, 2026
81 checks passed
@tdavidcl tdavidcl deleted the patch-2026-03-25-21-58 branch March 25, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant