A platform for community discussion. Free, open, simple.
DEV: Use detached worktrees for release processes (#38918)
David Taylor7b39c4c65953
diff --git a/lib/release_utils.rb b/lib/release_utils.rbindex 105b0599231..c22049929f2 100644--- a/lib/release_utils.rb+++ b/lib/release_utils.rb@@ -131,7 +131,7 @@ module ReleaseUtilsconfirm_or_abort "Ready to merge #{branch}?"if test_mode?- git "push", "origin", "#{branch}:#{base}"+ git "push", "origin", "HEAD:#{base}"breakelseif !gh("pr", "ready", branch) # remove draft status@@ -175,7 +175,7 @@ module ReleaseUtilspath = "#{Rails.root}/tmp/version-bump-worktree-#{SecureRandom.hex}"beginFileUtils.mkdir_p(path)- git "worktree", "add", path, "origin/#{origin_branch}"+ git "worktree", "add", "--detach", path, "origin/#{origin_branch}"Dir.chdir(path) { yield } # rubocop:disable Discourse/NoChdirensureputs "Cleaning up temporary worktree..."diff --git a/lib/tasks/release.rake b/lib/tasks/release.rakeindex 61081989cda..9fcfa11cba5 100644--- a/lib/tasks/release.rake+++ b/lib/tasks/release.rake@@ -235,9 +235,6 @@ namespace :release dobranch = "security/#{base}-security-fixes"ReleaseUtils.with_clean_worktree(base) do- ReleaseUtils.git "branch", "-D", branch if ReleaseUtils.ref_exists?(branch)- ReleaseUtils.git "checkout", "-b", branch-fix_refs.each do |ref|origin, origin_branch = ref.split("/", 2)ReleaseUtils.git "fetch", origin, origin_branch@@ -261,11 +258,11 @@ namespace :release doReleaseUtils.commit_version_bump(new_version, "DEV: Bump release branch to v#{new_version}")end- puts "Finished merging commits into a locally-staged #{branch} branch. Git log is:"- puts ReleaseUtils.git("log", "origin/#{base}..#{branch}")+ puts "Finished merging commits into a locally-staged branch. Git log is:"+ puts ReleaseUtils.git("log", "origin/#{base}..HEAD")ReleaseUtils.confirm_or_abort "Check the log above. Ready to push this branch to the origin and create a PR?"- ReleaseUtils.git("push", "-f", "--set-upstream", "origin", branch)+ ReleaseUtils.git("push", "-f", "origin", "HEAD:refs/heads/#{branch}")ReleaseUtils.make_pr(base: base,