Skip to content

Commit eba2b45

Browse files
committed
Fix git author identity for PR commits and enforce atomic max_prs slot reservation
1 parent f9bdd12 commit eba2b45

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

.ci/autoupdater/catalog_audit.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,23 @@ def process_single_family(item):
130130
if max_prs > 0:
131131
with pr_lock:
132132
if pr_counter[0] < max_prs:
133+
pr_counter[0] += 1
133134
should_create_pr = True
134135

135136
try:
136137
res = pipeline.process_family(filepath, create_pr=should_create_pr, base_branch=base_branch)
137138

138-
if res.get("has_update") and res.get("pr_info") and res["pr_info"].get("created"):
139-
with pr_lock:
140-
pr_counter[0] += 1
139+
# If we pre-allocated PR slot but family had no update or PR creation failed, release slot
140+
if should_create_pr:
141+
pr_created = res.get("has_update") and res.get("pr_info") and res["pr_info"].get("created")
142+
if not pr_created:
143+
with pr_lock:
144+
pr_counter[0] = max(0, pr_counter[0] - 1)
141145
return res
142146
except Exception as e:
147+
if should_create_pr:
148+
with pr_lock:
149+
pr_counter[0] = max(0, pr_counter[0] - 1)
143150
return {
144151
"family_name": meta.name if meta else Path(filepath).parent.name,
145152
"has_update": False,
@@ -148,6 +155,7 @@ def process_single_family(item):
148155
}
149156

150157

158+
151159
def run_full_catalog_audit(
152160
fonts_repo_path: str = ".",
153161
max_families: int = 2000,

.ci/autoupdater/pr_creator.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ def create_pull_request(
6868
# 5. Add and commit METADATA.pb
6969
subprocess.run(["git", "-c", "core.hooksPath=/dev/null", "add", str(meta_path)], check=True)
7070
commit_msg = f"Update {family_name} METADATA.pb to upstream {upstream_version or upstream_commit}"
71-
subprocess.run(["git", "-c", "core.hooksPath=/dev/null", "commit", "-m", commit_msg], check=True)
71+
subprocess.run([
72+
"git", "-c", "core.hooksPath=/dev/null",
73+
"-c", "user.name=github-actions[bot]",
74+
"-c", "user.email=github-actions[bot]@users.noreply.github.com",
75+
"commit", "-m", commit_msg
76+
], check=True)
7277

7378
# 6. Push branch to origin
7479
subprocess.run(["git", "-c", "core.hooksPath=/dev/null", "push", "origin", branch_name, "--force"], check=True)
@@ -120,18 +125,19 @@ def create_pull_request(
120125
# Return to original branch
121126
subprocess.run(["git", "-c", "core.hooksPath=/dev/null", "checkout", original_branch], check=False)
122127

123-
124128
return {
125129
"created": True,
126130
"branch_name": branch_name,
127131
"pr_url": pr_url or f"https://github.com/{self.repo_slug}/pulls",
128132
"status": "PR_CREATED",
129133
}
130134
except Exception as e:
131-
# Return to original branch on failure
132-
subprocess.run(["git", "checkout", original_branch], check=False)
135+
# Revert any uncommitted/unstaged changes and restore original branch
136+
subprocess.run(["git", "-c", "core.hooksPath=/dev/null", "checkout", "--", "."], check=False)
137+
subprocess.run(["git", "-c", "core.hooksPath=/dev/null", "checkout", original_branch], check=False)
133138
return {
134139
"created": False,
135140
"error": str(e),
136141
"status": "PR_CREATION_FAILED",
137142
}
143+

.github/workflows/weekly_autoupdate.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ jobs:
6262
python -m pip install --upgrade pip
6363
pip install fontTools requests
6464
65+
- name: Configure Git Author Identity
66+
run: |
67+
git config --global user.name "github-actions[bot]"
68+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
69+
6570
- name: Run Upstream Update Audit Sweep & Submit PR
71+
6672
env:
6773
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6874
run: |

0 commit comments

Comments
 (0)