0621944db50aec931850806644b673e39b650163
- Author
- Carlo Sala <carlosalag@protonmail.com>
- Committer
- Carlo Sala <carlosalag@protonmail.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/.github/workflows/dependencies/updater.py b/.github/workflows/dependencies/updater.py
2index 4533b7aeba324a83bce35b14c90747df4a5837c7..e64d69939966deb93adf9a7d08a0c94e35036119 100644
3--- a/.github/workflows/dependencies/updater.py
4+++ b/.github/workflows/dependencies/updater.py
5@@ -228,21 +228,22 @@ class Dependency:
6 self.__apply_upstream_changes()
7
8 # Add all changes and commit
9- Git.add_and_commit(self.name, short_sha)
10+ has_new_commit = Git.add_and_commit(self.name, short_sha)
11
12- # Push changes to remote
13- Git.push(branch)
14+ if has_new_commit:
15+ # Push changes to remote
16+ Git.push(branch)
17
18- # Create GitHub PR
19- GitHub.create_pr(
20- branch,
21- f"feat({self.name}): update to version {new_version}",
22- f"""## Description
23+ # Create GitHub PR
24+ GitHub.create_pr(
25+ branch,
26+ f"feat({self.name}): update to version {new_version}",
27+ f"""## Description
28
29-Update for **{self.desc}**: update to version [{new_version}]({status['head_url']}).
30-Check out the [list of changes]({status['compare_url']}).
31-""",
32- )
33+ Update for **{self.desc}**: update to version [{new_version}]({status['head_url']}).
34+ Check out the [list of changes]({status['compare_url']}).
35+ """,
36+ )
37
38 # Clean up repository
39 Git.clean_repo()
40@@ -377,7 +378,21 @@ class Git:
41 return branch_name
42
43 @staticmethod
44- def add_and_commit(scope: str, version: str):
45+ def add_and_commit(scope: str, version: str) -> bool:
46+ """
47+ Returns `True` if there were changes and were indeed commited.
48+ Returns `False` if the repo was clean and no changes were commited.
49+ """
50+ # check if repo is clean (clean => no error, no commit)
51+ try:
52+ CommandRunner.run_or_fail(
53+ ["git", "diff", "--exit-code"], stage="CheckRepoClean"
54+ )
55+ return False
56+ except CommandRunner.Exception:
57+ # if it's other kind of error just throw!
58+ pass
59+
60 user_name = os.environ.get("GIT_APP_NAME")
61 user_email = os.environ.get("GIT_APP_EMAIL")
62
63@@ -390,27 +405,22 @@ class Git:
64 clean_env["GIT_CONFIG_GLOBAL"] = "/dev/null"
65 clean_env["GIT_CONFIG_NOSYSTEM"] = "1"
66
67- # check if repo is clean (clean => no error, no commit)
68- try:
69- CommandRunner.run_or_fail(
70- ["git", "diff", "--exit-code"], stage="CheckRepoClean", env=clean_env
71- )
72- except CommandRunner.Exception:
73- # Commit with settings above
74- CommandRunner.run_or_fail(
75- [
76- "git",
77- "-c",
78- f"user.name={user_name}",
79- "-c",
80- f"user.email={user_email}",
81- "commit",
82- "-m",
83- f"feat({scope}): update to {version}",
84- ],
85- stage="CreateCommit",
86- env=clean_env,
87- )
88+ # Commit with settings above
89+ CommandRunner.run_or_fail(
90+ [
91+ "git",
92+ "-c",
93+ f"user.name={user_name}",
94+ "-c",
95+ f"user.email={user_email}",
96+ "commit",
97+ "-m",
98+ f"feat({scope}): update to {version}",
99+ ],
100+ stage="CreateCommit",
101+ env=clean_env,
102+ )
103+ return True
104