Skip to content

Commit d34ebaa

Browse files
sorahclaude
andcommitted
GitHubPusher: add commits instead of resetting branch
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 <[email protected]>
1 parent ad18d61 commit d34ebaa

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

app/jobs/generate_sponsors_yaml_file_job.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,26 +169,23 @@ def push
169169
return
170170
end
171171

172-
reset_branch
172+
ensure_branch
173173
commit_content
174174
create_or_update_pull_request
175175
end
176176

177177
private
178178

179-
def reset_branch
180-
begin
181-
octokit.delete_branch(@repo.name, @branch_name)
182-
rescue Octokit::UnprocessableEntity
183-
end
184-
185-
head = octokit.branch(@repo.name, base_branch)
186-
octokit.create_ref(@repo.name, "refs/heads/#{@branch_name}", head[:commit][:sha])
179+
def ensure_branch
180+
octokit.branch(@repo.name, @branch_name)
181+
rescue Octokit::NotFound
182+
head_sha = octokit.branch(@repo.name, base_branch)[:commit][:sha]
183+
octokit.create_ref(@repo.name, "refs/heads/#{@branch_name}", head_sha)
187184
end
188185

189186
def commit_content
190187
begin
191-
blob_sha = octokit.contents(@repo.name, path: @filepath, ref: base_branch)[:sha]
188+
blob_sha = octokit.contents(@repo.name, path: @filepath, ref: @branch_name)[:sha]
192189
rescue Octokit::NotFound
193190
blob_sha = nil
194191
end

0 commit comments

Comments
 (0)