Skip to content

GenerateSponsorsYamlFileJob: stable branch, reuse PR & extract GitHubPusher#132

Merged
sorah merged 4 commits intomasterfrom
generate_sponsors_yaml_file_job_reuse
Mar 2, 2026
Merged

GenerateSponsorsYamlFileJob: stable branch, reuse PR & extract GitHubPusher#132
sorah merged 4 commits intomasterfrom
generate_sponsors_yaml_file_job_reuse

Conversation

@sorah
Copy link
Copy Markdown
Member

@sorah sorah commented Mar 2, 2026

Previously each edit created a new branch (sponsor-app/<history_id>) and PR, leaving stale PRs open. Now uses a stable branch per conference (sponsor-app/<slug>) and reuses the existing open PR.

  • Staleness check: skip push if branch already has newer editing history data
  • Optimistic concurrency: retry on blob_sha conflict when our data is fresher, bail otherwise
  • PR reuse: find existing open PR on the branch and update its title, with race-condition handling on create

Second commit extracts the push-to-GitHub logic (branch reset, commit with retry, staleness check, PR upsert) into a nested GitHubPusher PORO, separating data generation from GitHub interaction.

sorah and others added 2 commits March 2, 2026 06:32
Previously each edit created a new branch (sponsor-app/<history_id>)
and PR, leaving stale PRs open. Now uses a stable branch per
conference (sponsor-app/<slug>) and reuses the existing open PR.

- Staleness check: skip push if branch already has newer
  editing history data
- Optimistic concurrency: retry on blob_sha conflict when our
  data is fresher, bail otherwise
- PR reuse: find existing open PR on the branch and update its
  title, with race-condition handling on create

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Separate data generation from GitHub interaction by moving
push_to_github internals (branch reset, commit with retry,
staleness check, PR upsert) into a nested GitHubPusher PORO.
The pusher takes explicit constructor args instead of relying
on job instance variables.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sorah sorah enabled auto-merge March 2, 2026 06:12
@sorah sorah disabled auto-merge March 2, 2026 06:13

def commit_content
begin
blob_sha = octokit.contents(@repo.name, path: @filepath)[:sha]

This comment was marked as outdated.

Comment on lines +232 to +235
rescue Octokit::UnprocessableEntity
# Concurrent job already created PR
existing_prs = octokit.pull_requests(@repo.name, state: 'open', head: "#{owner}:#{@branch_name}")
octokit.update_pull_request(@repo.name, existing_prs[0][:number], title: @pr_title) if existing_prs.any?

This comment was marked as outdated.

sorah and others added 2 commits March 2, 2026 15:17
The old check only compared last_editing_history, so event-only
changes could overwrite newer branch data (or skip when they
shouldn't). Always emit both IDs in the YAML comment (defaulting
to 0) and compare both with domination logic: branch is newer
only when both IDs are >= ours and at least one is strictly >.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Without ref:, the API defaults to the repo's default branch,
which differs from base_branch when the conference specifies a
custom branch. This caused a guaranteed conflict on the first
update_contents attempt, wasting a retry.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sorah sorah enabled auto-merge March 2, 2026 06:19
@sorah sorah added this pull request to the merge queue Mar 2, 2026
Merged via the queue into master with commit ad18d61 Mar 2, 2026
2 checks passed
@sorah sorah deleted the generate_sponsors_yaml_file_job_reuse branch March 2, 2026 06:22
sorah added a commit that referenced this pull request Mar 2, 2026
Deleting and recreating the branch causes GitHub to close the
associated PR. Force-updating has the same effect on PR history.
Instead, only create the branch when it doesn't exist and commit
on top, so the PR stays open and accumulates commits naturally.

follow-up: #132

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant