From 7d2cc811dbf0ceb646e6411dffa3525a9784c621 Mon Sep 17 00:00:00 2001 From: bohung Date: Sat, 13 Mar 2021 19:19:04 +0800 Subject: [PATCH] Fix bug. --- lib/personal_plugin_generator/engine.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/personal_plugin_generator/engine.rb b/lib/personal_plugin_generator/engine.rb index 5848c05..aa1755c 100644 --- a/lib/personal_plugin_generator/engine.rb +++ b/lib/personal_plugin_generator/engine.rb @@ -52,9 +52,9 @@ module PersonalPluginGenerator end git = 'git_1.9.1/usr/bin/git' end - @branch = %x(#{git} rev-parse --abbrev-ref HEAD).gsub("\n","") - new_commit_id = %x(#{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("'","")} + @branch = %x(cd #{ENV['PWD']} && #{git} rev-parse --abbrev-ref HEAD).gsub("\n","") + new_commit_id = %x(cd #{ENV['PWD']} && #{git} log #{@branch}..origin/#{@branch} --pretty=format:"%H") + new_updates = %x(cd #{ENV['PWD']} && #{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}'" @@ -70,7 +70,7 @@ module PersonalPluginGenerator if %x[#{git} config user.email].empty? %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") + system("cd #{ENV['PWD']} && sh -l -c \"#{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