mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-19 20:29:45 +01:00
fix(dependencies): only open PR if there are changes
This commit is contained in:
parent
309129f651
commit
0621944db5
1 changed files with 44 additions and 34 deletions
78
.github/workflows/dependencies/updater.py
vendored
78
.github/workflows/dependencies/updater.py
vendored
|
@ -228,21 +228,22 @@ class Dependency:
|
||||||
self.__apply_upstream_changes()
|
self.__apply_upstream_changes()
|
||||||
|
|
||||||
# Add all changes and commit
|
# Add all changes and commit
|
||||||
Git.add_and_commit(self.name, short_sha)
|
has_new_commit = Git.add_and_commit(self.name, short_sha)
|
||||||
|
|
||||||
# Push changes to remote
|
if has_new_commit:
|
||||||
Git.push(branch)
|
# Push changes to remote
|
||||||
|
Git.push(branch)
|
||||||
|
|
||||||
# Create GitHub PR
|
# Create GitHub PR
|
||||||
GitHub.create_pr(
|
GitHub.create_pr(
|
||||||
branch,
|
branch,
|
||||||
f"feat({self.name}): update to version {new_version}",
|
f"feat({self.name}): update to version {new_version}",
|
||||||
f"""## Description
|
f"""## Description
|
||||||
|
|
||||||
Update for **{self.desc}**: update to version [{new_version}]({status['head_url']}).
|
Update for **{self.desc}**: update to version [{new_version}]({status['head_url']}).
|
||||||
Check out the [list of changes]({status['compare_url']}).
|
Check out the [list of changes]({status['compare_url']}).
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Clean up repository
|
# Clean up repository
|
||||||
Git.clean_repo()
|
Git.clean_repo()
|
||||||
|
@ -377,7 +378,21 @@ class Git:
|
||||||
return branch_name
|
return branch_name
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_and_commit(scope: str, version: str):
|
def add_and_commit(scope: str, version: str) -> bool:
|
||||||
|
"""
|
||||||
|
Returns `True` if there were changes and were indeed commited.
|
||||||
|
Returns `False` if the repo was clean and no changes were commited.
|
||||||
|
"""
|
||||||
|
# check if repo is clean (clean => no error, no commit)
|
||||||
|
try:
|
||||||
|
CommandRunner.run_or_fail(
|
||||||
|
["git", "diff", "--exit-code"], stage="CheckRepoClean"
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
except CommandRunner.Exception:
|
||||||
|
# if it's other kind of error just throw!
|
||||||
|
pass
|
||||||
|
|
||||||
user_name = os.environ.get("GIT_APP_NAME")
|
user_name = os.environ.get("GIT_APP_NAME")
|
||||||
user_email = os.environ.get("GIT_APP_EMAIL")
|
user_email = os.environ.get("GIT_APP_EMAIL")
|
||||||
|
|
||||||
|
@ -390,27 +405,22 @@ class Git:
|
||||||
clean_env["GIT_CONFIG_GLOBAL"] = "/dev/null"
|
clean_env["GIT_CONFIG_GLOBAL"] = "/dev/null"
|
||||||
clean_env["GIT_CONFIG_NOSYSTEM"] = "1"
|
clean_env["GIT_CONFIG_NOSYSTEM"] = "1"
|
||||||
|
|
||||||
# check if repo is clean (clean => no error, no commit)
|
# Commit with settings above
|
||||||
try:
|
CommandRunner.run_or_fail(
|
||||||
CommandRunner.run_or_fail(
|
[
|
||||||
["git", "diff", "--exit-code"], stage="CheckRepoClean", env=clean_env
|
"git",
|
||||||
)
|
"-c",
|
||||||
except CommandRunner.Exception:
|
f"user.name={user_name}",
|
||||||
# Commit with settings above
|
"-c",
|
||||||
CommandRunner.run_or_fail(
|
f"user.email={user_email}",
|
||||||
[
|
"commit",
|
||||||
"git",
|
"-m",
|
||||||
"-c",
|
f"feat({scope}): update to {version}",
|
||||||
f"user.name={user_name}",
|
],
|
||||||
"-c",
|
stage="CreateCommit",
|
||||||
f"user.email={user_email}",
|
env=clean_env,
|
||||||
"commit",
|
)
|
||||||
"-m",
|
return True
|
||||||
f"feat({scope}): update to {version}",
|
|
||||||
],
|
|
||||||
stage="CreateCommit",
|
|
||||||
env=clean_env,
|
|
||||||
)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def push(branch: str):
|
def push(branch: str):
|
||||||
|
|
Loading…
Reference in a new issue