Skip to content
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

Minor update for the pre-commit check for need of rebase: Enable output logging #116

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/check_branch-needs-rebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
# pylint: disable=using-f-string-in-unsupported-version
import subprocess
import sys
from logging import info as log
from logging import basicConfig, INFO, info as log


def run(command: list[str], check=False) -> tuple[int, str]:
"""Run a command and return the output."""
log(" ".join(command))
cmd: subprocess.CompletedProcess[str] = subprocess.run(
command,
check=check,
Expand All @@ -30,8 +31,7 @@ def check_if_local_branch_is_behind_target(

# Fetch the remote branch in order to get the number of commits behind
if run(["git", "fetch", *target.split("/", maxsplit=1)])[0]:
log("Failed to fetch the remote branch")
return 1
log("Failed to fetch the remote branch, but you may be offline, go online.")

# Get the number of commits behind the remote branch
error, commits_behind = run(
Expand Down Expand Up @@ -99,4 +99,5 @@ def main():


if __name__ == "__main__":
basicConfig(format="%(message)s", level=INFO)
sys.exit(main())
Loading