Skip to content

Commit

Permalink
ci: translate commit_checks.py to english
Browse files Browse the repository at this point in the history
  • Loading branch information
matheuswhite committed May 10, 2024
1 parent 030e3ca commit 628e42c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions .github/commit_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@

def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("-s", "--srcb", metavar="sbranch", help="Branch de origem da comparação.")
parser.add_argument("-t", "--tgtb", metavar="tbranch", help="Branch de destino da comparação.",
parser.add_argument("-s", "--srcb", metavar="sbranch", help="Source branch to compare.")
parser.add_argument("-t", "--tgtb", metavar="tbranch", help="Target branch to compare.",
default="origin/main")

source_branch = str(parser.parse_args().srcb)
target_branch = str(parser.parse_args().tgtb)

if source_branch == "None":
print("\nBranch a ser verificada não fornecida.")
print("\nSource branch is empty.")
return -1

invocation = f"git rev-list --count --left-right {target_branch}...{source_branch}"
Expand All @@ -32,39 +32,39 @@ def main() -> int:
out = subprocess.check_output(invocation, shell=True)
behind, ahead = [int(dist) for dist in out.decode("utf-8").rsplit("\t", maxsplit=1)]
except Exception as e:
print(f"\nErro ao verificar o histórico: {e}")
print(f"\nError to check the history: {e}")
return -1

if behind > 0:
print(f"\n{behind} commits que precisam ser incorporados no PR por rebase à main.\n")
print(f"\nThere are {behind} commits to be included in PR using rebase to main.\n")

return 1

if ahead > COMMIT_LIMIT:
print(f"\n{ahead} commits a serem adicionados, divida o PR para que contenha menos que {COMMIT_LIMIT + 1}"
" commits.")
print(f"\nThere are {ahead} commits to be added, divide PR to have less than {COMMIT_LIMIT + 1} commits.")

return 1

print(f"\nHistórico está atualizado. ({ahead} commits a frente)")
print(f"\nHistory is updated. ({ahead} commits ahead)")

invocation = f"git describe --all --first-parent {source_branch}~1 --abbrev=0"

try:
out = subprocess.check_output(invocation, shell=True)
parent_head = out.decode("utf-8").split("/")[-1].strip()
except Exception as e:
print(f"\nErro ao verificar o histórico: {e}")
print(f"\nError to check the history: {e}")

return -1

if parent_head != "main":
print(f"\nA branch tem origem em `{parent_head}`, resolva a `{parent_head}` primeiro. (A branch deve ter origem "
"na main)")
print(
f"\nThe branch has its origin on `{parent_head}`, resolve `{parent_head}` first. (the branch must have "
f"origin on main)")

return 1

print("\nA branch tem origem na main.")
print("\nThe branch has its origin on main.")

return 0

Expand Down

0 comments on commit 628e42c

Please sign in to comment.