mirror of
https://github.com/discourse/discourse.git
synced 2025-03-26 13:25:36 +08:00
DEV: Support for main
branches in plugin:update (#12027)
Based on https://github.com/discourse/docker_manager/pull/94
This commit is contained in:
parent
f2de7842bb
commit
43948f6a10
@ -84,7 +84,26 @@ task 'plugin:update', :plugin do |t, args|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
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_status
|
abort('Unable to pull latest version of plugin') unless update_status
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user