summaryrefslogtreecommitdiff
path: root/.github/workflows
diff options
context:
space:
mode:
authorCarlo Sala <carlosalag@protonmail.com>2025-12-01 09:59:09 +0100
committerGitHub <noreply@github.com>2025-12-01 09:59:09 +0100
commitca5c467db1d495a4b5c0049a4cf476ca7f34b790 (patch)
tree93502a8f7ba744fa4f65968375433fdaf687460e /.github/workflows
parenta449c0247d69726fe4f3ca4fe88182bdb215a5d3 (diff)
downloadzsh-ca5c467db1d495a4b5c0049a4cf476ca7f34b790.tar.gz
zsh-ca5c467db1d495a4b5c0049a4cf476ca7f34b790.tar.bz2
zsh-ca5c467db1d495a4b5c0049a4cf476ca7f34b790.zip
fix(dependencies): only open PR if there are relevant changes (#13454)
Fixes cases like #13453
Diffstat (limited to '.github/workflows')
-rw-r--r--.github/workflows/dependencies/updater.py62
1 files changed, 35 insertions, 27 deletions
diff --git a/.github/workflows/dependencies/updater.py b/.github/workflows/dependencies/updater.py
index 02cff9030..aee15d9e0 100644
--- a/.github/workflows/dependencies/updater.py
+++ b/.github/workflows/dependencies/updater.py
@@ -219,31 +219,32 @@ class Dependency:
# Create new branch
branch = Git.checkout_or_create_branch(branch_name)
- # Update dependencies.yml file
- self.__update_yaml(
- f"tag:{new_version}" if is_tag else status["version"]
- )
-
# Update dependency files
self.__apply_upstream_changes()
- # Add all changes and commit
- has_new_commit = Git.add_and_commit(self.name, new_version)
+ if not Git.repo_is_clean():
+ # Update dependencies.yml file
+ self.__update_yaml(
+ f"tag:{new_version}" if is_tag else status["version"]
+ )
+
+ # Add all changes and commit
+ has_new_commit = Git.add_and_commit(self.name, new_version)
- if has_new_commit:
- # Push changes to remote
- Git.push(branch)
+ if has_new_commit:
+ # Push changes to remote
+ Git.push(branch)
- # Create GitHub PR
- GitHub.create_pr(
- branch,
- f"feat({self.name}): update to version {new_version}",
- f"""## Description
+ # Create GitHub PR
+ GitHub.create_pr(
+ branch,
+ f"feat({self.name}): update to version {new_version}",
+ f"""## Description
-Update for **{self.desc}**: update to version [{new_version}]({status['head_url']}).
-Check out the [list of changes]({status['compare_url']}).
+Update for **{self.desc}**: update to version [{new_version}]({status["head_url"]}).
+Check out the [list of changes]({status["compare_url"]}).
""",
- )
+ )
# Clean up repository
Git.clean_repo()
@@ -275,8 +276,8 @@ Check out the [list of changes]({status['compare_url']}).
There is a new version of `{self.name}` {self.kind} available.
-New version: [{new_version}]({status['head_url']})
-Check out the [list of changes]({status['compare_url']}).
+New version: [{new_version}]({status["head_url"]})
+Check out the [list of changes]({status["compare_url"]}).
"""
print("Creating GitHub issue", file=sys.stderr)
@@ -378,20 +379,27 @@ class Git:
return branch_name
@staticmethod
- def add_and_commit(scope: str, version: str) -> bool:
+ def repo_is_clean() -> bool:
"""
- Returns `True` if there were changes and were indeed commited.
- Returns `False` if the repo was clean and no changes were commited.
+ Returns `True` if the repo is clean.
+ Returns `False` if the repo is dirty.
"""
- # check if repo is clean (clean => no error, no commit)
try:
CommandRunner.run_or_fail(
["git", "diff", "--exit-code"], stage="CheckRepoClean"
)
- return False
+ return True
except CommandRunner.Exception:
- # if it's other kind of error just throw!
- pass
+ return False
+
+ @staticmethod
+ 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.
+ """
+ if Git.repo_is_clean():
+ return False
user_name = os.environ.get("GIT_APP_NAME")
user_email = os.environ.get("GIT_APP_EMAIL")