File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed
Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments