Remove foreign .git from copied templates not registered as submodules

This commit is contained in:
rulingcom committed 2026-10-24 22:53:46 +08:00
1 parent a7415f2ca3
commit ad7c692f59
1 file changed
+7
+7
View File
@@ -24,6 +24,7 @@ if bundle_update_flag
ENV['ORBIT_GITMODULES_REBUILT'] = '1'
begin
require 'open3'
require 'fileutils'
if Dir.exist?(File.join(dir_pwd, '.git')) && Dir.exist?(template_path)
Dir.chdir(dir_pwd) do
candidates = {}
@@ -61,6 +62,12 @@ if bundle_update_flag
end
system('git', 'rm', '-q', '--cached', '--ignore-unmatch', '--', '.gitmodules')
(gitlinks - keep.keys).each { |p| system('git', 'rm', '-q', '--cached', '--', p) }
Dir.glob('app/templates/*/.git').each do |g|
next unless File.directory?(g)
next if keep.key?(File.dirname(g))
FileUtils.rm_rf(g)
puts "removed copied .git in #{File.dirname(g)}"
end
end
puts "finish rebuilding .gitmodules in #{dir_pwd}"
end