This commit is contained in:
BoHung Chiu 2021-03-13 18:45:32 +08:00
parent f4e929541e
commit 56091b7245
1 changed files with 5 additions and 4 deletions

View File

@ -52,10 +52,10 @@ module PersonalPluginGenerator
end
git = 'git_1.9.1/usr/bin/git'
end
local_commit_id = `git rev-parse --short origin/master`.split("\n").first
remote_url = `git config --get remote.origin.url`.split("\n").first
remote_commit_id = `git ls-remote #{remote_url} refs/heads/master`.split("\n").first
if local_commit_id != remote_commit_id[0...local_commit_id.length]
@branch = `git rev-parse --abbrev-ref HEAD`.gsub("\n","")
new_commit_id = `git log #{@branch}..origin/#{@branch} --pretty=format:"%H"`
new_updates = %x(git log #{@branch}..origin/#{@branch} --pretty=format:"%ad' , '%s" --date=short).split("\n").map{|log| log.gsub("'","")}
if new_commit_id.present?
git_add_except_public = Dir['*'].select{|v| v!= 'public' && v!= 'log' && v != 'dump' && v != 'tmp'}.collect do |v|
"#{git} add -f --all --ignore-errors '#{v}'"
end.join(' ; ')
@ -71,6 +71,7 @@ module PersonalPluginGenerator
%x[#{git} config --global user.email "orbit@rulingcom.com"]
end
system("#{git_add_except_public} ; #{git} commit -m auto_backup_before_#{type}_#{time_now} --allow-empty && #{git} reset #{commit} --mixed ; #{git_add_custom} ; #{git_restore} ; #{git_add_except_public} ; #{git} clean -f -- app/models ; #{git} commit -m complete_#{type}_#{time_now} --allow-empty")
puts "Updated! " + new_updates.first.to_s
end
end
end