-
Notifications
You must be signed in to change notification settings - Fork 25
[Buildbot] fix usage of buildbot outside of repo #1727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -59,24 +59,36 @@ def print_buildbot_info(utility_name): | |||||||||||||||||||
|
|
||||||||||||||||||||
| print() | ||||||||||||||||||||
|
|
||||||||||||||||||||
| str_git = os.popen("git log -n 1 --decorate=full").read() | ||||||||||||||||||||
| try: | ||||||||||||||||||||
| r_log = subprocess.run( | ||||||||||||||||||||
| ["git", "log", "-n", "1", "--decorate=full"], | ||||||||||||||||||||
| capture_output=True, | ||||||||||||||||||||
| text=True, | ||||||||||||||||||||
| ) | ||||||||||||||||||||
| if r_log.returncode != 0: | ||||||||||||||||||||
| raise RuntimeError("git log failed") | ||||||||||||||||||||
|
|
||||||||||||||||||||
| git_hash = str_git.split()[1] | ||||||||||||||||||||
| git_head = str_git[str_git.find("HEAD -> ") + 8 : str_git.find(")")] | ||||||||||||||||||||
| str_git = r_log.stdout | ||||||||||||||||||||
| git_hash = str_git.split()[1] | ||||||||||||||||||||
| git_head = str_git[str_git.find("HEAD -> ") + 8 : str_git.find(")")] | ||||||||||||||||||||
|
|
||||||||||||||||||||
| git_head = git_head.split(",") | ||||||||||||||||||||
| git_head = git_head.split(",") | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if len(git_head) == 1: | ||||||||||||||||||||
| git_head = "\033[1;92m" + git_head[0] + "\033[0;0m" | ||||||||||||||||||||
| else: | ||||||||||||||||||||
| git_head = "\033[1;92m" + git_head[0] + "\033[0;0m , \033[1;91m" + git_head[0] + "\033[0;0m" | ||||||||||||||||||||
| if len(git_head) == 1: | ||||||||||||||||||||
| git_head = "\033[1;92m" + git_head[0] + "\033[0;0m" | ||||||||||||||||||||
| else: | ||||||||||||||||||||
| git_head = ( | ||||||||||||||||||||
| "\033[1;92m" + git_head[0] + "\033[0;0m , \033[1;91m" + git_head[0] + "\033[0;0m" | ||||||||||||||||||||
| ) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| print("\033[1;34mGit status \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()) | ||||||||||||||||||||
| print("\033[1;90m" + "-" * col_cnt + "\033[0;0m\n") | ||||||||||||||||||||
| print("\033[1;34mGit status \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()) | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||||
| print("\033[1;90m" + "-" * col_cnt + "\033[0;0m\n") | ||||||||||||||||||||
| except Exception: # noqa: BLE001 | ||||||||||||||||||||
|
tdavidcl marked this conversation as resolved.
|
||||||||||||||||||||
| print("Warn : couldn't get git status") | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| def run_cmd(str): | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
git_headvariable is duplicated in the string formatting whenlen(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 displaygit_head[0]andgit_head[1](or iterate throughgit_headif more are possible).