Skip to content

Commit da56498

Browse files
authored
Merge pull request #9607 from ruby/release-check-remote-branches
Detect stale release branches on origin
2 parents 6d7faaa + 7ce7105 commit da56498

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

tool/release.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ def check_git_state!
253253
errors << "Release branches already exist: #{existing.join(", ")}. Please delete them before running this task."
254254
end
255255

256+
existing_remote = branches.select {|b| system("git", "rev-parse", "--verify", "refs/remotes/origin/#{b}", out: IO::NULL, err: IO::NULL) }
257+
unless existing_remote.empty?
258+
errors << "Release branches already exist on origin: #{existing_remote.map {|b| "origin/#{b}" }.join(", ")}. `git checkout` would silently base work on them instead of the intended branch. Delete them from origin, or run `git fetch --prune origin` if they are already gone."
259+
end
260+
256261
raise errors.join("\n") unless errors.empty?
257262
end
258263

0 commit comments

Comments
 (0)