Skip to content

Commit

Permalink
fix(dependencies): check if repo is clean before committing
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosala committed May 12, 2024
1 parent 1d31ff6 commit 0493eab
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions .github/workflows/dependencies/updater.py
Expand Up @@ -390,21 +390,27 @@ def add_and_commit(scope: str, version: str):
clean_env["GIT_CONFIG_GLOBAL"] = "/dev/null"
clean_env["GIT_CONFIG_NOSYSTEM"] = "1"

# Commit with settings above
CommandRunner.run_or_fail(
[
"git",
"-c",
f"user.name={user_name}",
"-c",
f"user.email={user_email}",
"commit",
"-m",
f"feat({scope}): update to {version}",
],
stage="CreateCommit",
env=clean_env,
)
# check if repo is clean (clean => no error, no commit)
try:
CommandRunner.run_or_fail(
["git", "diff", "--exit-code"], stage="CheckRepoClean", env=clean_env
)
except CommandRunner.Exception:
# Commit with settings above
CommandRunner.run_or_fail(
[
"git",
"-c",
f"user.name={user_name}",
"-c",
f"user.email={user_email}",
"commit",
"-m",
f"feat({scope}): update to {version}",
],
stage="CreateCommit",
env=clean_env,
)

@staticmethod
def push(branch: str):
Expand Down

0 comments on commit 0493eab

Please sign in to comment.