A platform for community discussion. Free, open, simple.
DEV: Support for `main` branches in plugin:update (#12027)
Jarek Radosz43948f6a10b2
diff --git a/lib/tasks/plugin.rake b/lib/tasks/plugin.rakeindex 57f659a82f5..e4ac9e7d6c9 100644--- a/lib/tasks/plugin.rake+++ b/lib/tasks/plugin.rake@@ -84,7 +84,26 @@ task 'plugin:update', :plugin do |t, args|endend- update_status = system('git --git-dir "' + plugin_path + '/.git" --work-tree "' + plugin_path + '" pull')+ `git -C '#{plugin_path}' fetch origin --tags --force`++ upstream_branch = `git -C '#{plugin_path}' for-each-ref --format='%(upstream:short)' $(git -C '#{plugin_path}' symbolic-ref -q HEAD)`.strip+ has_origin_main = `git -C '#{plugin_path}' branch -a`.match?(/remotes\/origin\/main$/)+ has_local_main = `git -C '#{plugin_path}' show-ref refs/heads/main`.present?++ if upstream_branch == "origin/master" && has_origin_main+ puts "Branch has changed to `origin/main`"++ if has_local_main+ update_status = system("git -C '#{plugin_path}' checkout main")+ abort('Unable to pull latest version of plugin') unless update_status+ else+ `git -C '#{plugin_path}' branch -m master main`+ end++ `git -C '#{plugin_path}' branch -u origin/main main`+ end++ update_status = system("git -C '#{plugin_path}' pull")abort('Unable to pull latest version of plugin') unless update_statusend