From fe79836f4ecb8ad973d99ff3f4d2284bef3fb544 Mon Sep 17 00:00:00 2001 From: rcmdnk Date: Wed, 4 Sep 2024 14:03:26 +0900 Subject: [PATCH] fix: update ok_failed function calls in Rakefile to include error handling flags --- Rakefile | 68 ++++++++++++++++++++-------------------- patches/Rakefile.patch | 70 +++++++++++++++++++++--------------------- setup.sh | 2 +- 3 files changed, 70 insertions(+), 70 deletions(-) diff --git a/Rakefile b/Rakefile index ed70a63..6fcace6 100644 --- a/Rakefile +++ b/Rakefile @@ -143,8 +143,8 @@ task :generate, :opt do |t, args| end end - ok_failed("rm -f .integrated") - ok_failed("rm -f .preview-mode") + ok_failed("rm -f .integrated", false) + ok_failed("rm -f .preview-mode", false) end desc "Same as generate" @@ -379,15 +379,15 @@ task :isolate, :filename do |t, args| end end end - ok_failed("touch .isolated") + ok_failed("touch .isolated", false) end desc "Move all stashed posts back into the posts directory, ready for site generation." task :integrate do FileUtils.mv Dir.glob("#{full_stash_dir}/*"), "#{source_dir}/#{posts_dir}/" FileUtils.mv Dir.glob("#{full_stash_root_dir}/*"), "#{source_dir}/" - ok_failed("rm -f .isolated") - ok_failed("touch .integrated") + ok_failed("rm -f .isolated", false) + ok_failed("touch .integrated", false) end desc "Clean out caches: .pygments-cache, .gist-cache, .sass-cache, thumbnail" @@ -437,7 +437,7 @@ task :deploy, :deploy_method do |t, args| # Check if preview posts exists, which should not be published if File.exist?(".integrated") or File.exist?(".isolated") puts "## Found isolated history, regenerating files ..." - ok_failed("rm -f .integrated .isolated") + ok_failed("rm -f .integrated .isolated", false) Rake::Task[:integrate].execute Rake::Task[:generate].execute end @@ -450,7 +450,7 @@ task :deploy, :deploy_method do |t, args| Rake::Task[:copydot].invoke(source_dir, public_dir) # Check if files are fine or not - ok_failed("if [ -f #{word_avoid} ];then while read a;do if ret=`grep -i -r -q $a #{public_dir}`;then echo \"A word $a is included, must be avoided!!!\"; echo $ret; exit 1;fi; done < #{word_avoid};fi") + ok_failed("if [ -f #{word_avoid} ];then while read a;do if ret=`grep -i -r -q $a #{public_dir}`;then echo \"A word $a is included, must be avoided!!!\"; echo $ret; exit 1;fi; done < #{word_avoid};fi", false) if args.deploy_method deploy_method = args.deploy_method; @@ -490,7 +490,7 @@ task :rsync do exclude = "--exclude-from '#{File.expand_path('./rsync-exclude')}'" end puts "## Deploying website via Rsync" - ok_failed("rsync -avze 'ssh -p #{ssh_port}' #{exclude} #{rsync_args} #{"--delete" unless rsync_delete == false} #{public_dir}/ #{ssh_user}:#{document_root}") + ok_failed("rsync -avze 'ssh -p #{ssh_port}' #{exclude} #{rsync_args} #{"--delete" unless rsync_delete == false} #{public_dir}/ #{ssh_user}:#{document_root}", false) end desc "deploy public directory to github pages" @@ -498,20 +498,20 @@ multitask :push do puts "## Deploying branch to Github Pages " puts "## Pulling any updates from Github Pages " cd "#{deploy_dir}" do - Bundler.with_original_env { ok_failed("git pull") } + Bundler.with_original_env { ok_failed("git pull", false) } end (Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) } Rake::Task[:copydot].invoke(public_dir, deploy_dir) puts "\n## Copying #{public_dir} to #{deploy_dir}" cp_r "#{public_dir}/.", deploy_dir cd "#{deploy_dir}" do - ok_failed("git add -A") + ok_failed("git add -A", false) message = "Site updated at #{Time.now.utc}" puts "\n## Committing: #{message}" - ok_failed("git commit -m \"#{message}\"") + ok_failed("git commit -m \"#{message}\"", false) puts "\n## Pushing generated #{deploy_dir} website" output = (use_token)? " >/dev/null 2>&1":"" - Bundler.with_original_env { ok_failed("git push origin #{deploy_branch} #{output}") } + Bundler.with_original_env { ok_failed("git push origin #{deploy_branch} #{output}", false) } puts "\n## Github Pages deploy complete" end end @@ -527,22 +527,22 @@ multitask :push_ex do rm_rf deploy_dir mkdir_p deploy_dir cd "#{deploy_dir}" do - ok_failed("git init") - ok_failed("git remote add origin #{repo_url}") + ok_failed("git init", false) + ok_failed("git remote add origin #{repo_url}", false) end Rake::Task[:copydot].invoke(public_dir, deploy_dir) puts "\n## Copying #{public_dir} to #{deploy_dir}" cp_r "#{public_dir}/.", deploy_dir cd "#{deploy_dir}" do - ok_failed("git add -A") + ok_failed("git add -A", false) puts "\n## Commiting: Site updated at #{Time.now.utc}" message = "Site updated at #{Time.now.utc}" - ok_failed("git commit -m \"#{message}\" >/dev/null") - ok_failed("git branch -m #{deploy_branch}") + ok_failed("git commit -m \"#{message}\" >/dev/null", false) + ok_failed("git branch -m #{deploy_branch}", false) puts "\n## Pushing generated #{deploy_dir} website" output = (use_token) ? " >/dev/null 2>&1" : "" - Bundler.with_unbundled_env { ok_failed("git push -u -f origin #{deploy_branch} #{output}") } + Bundler.with_unbundled_env { ok_failed("git push -u -f origin #{deploy_branch} #{output}", false) } puts "\n## Github Pages deploy complete" end end @@ -603,19 +603,19 @@ task :setup_github_pages, [:repo, :yes] do |t, args| use_token_val = use_token ? "true" : "false" unless (`git remote -v` =~ /origin.+?octopress(?:\.git)?/).nil? # If octopress is still the origin remote (from cloning) rename it to octopress - ok_failed("git remote rename origin octopress") + ok_failed("git remote rename origin octopress", false) if branch == 'master' # If this is a user/organization pages repository, add the correct origin remote # and checkout the source branch for committing changes to the blog source. - ok_failed("git remote add origin #{repo_url}") + ok_failed("git remote add origin #{repo_url}", false) if use_token puts "Added given remote as origin" else puts "Added remote #{repo_url} as origin" end - ok_failed("git config branch.master.remote origin") + ok_failed("git config branch.master.remote origin", false) puts "Set origin as default remote" - ok_failed("git branch -m master source") + ok_failed("git branch -m master source", false) puts "Master branch renamed to 'source' for committing your blog source files" end end @@ -659,12 +659,12 @@ task :setup_github_pages, [:repo, :yes] do |t, args| rm_rf deploy_dir mkdir deploy_dir cd "#{deploy_dir}" do - ok_failed("git init") - ok_failed("echo 'My Octopress Page is coming soon …' > index.html") - ok_failed("git add -A") - ok_failed("git commit -m \"Octopress init\"") - ok_failed("git branch -m #{deploy_branch}") unless branch == 'master' - ok_failed("git remote add origin #{repo_url}") + ok_failed("git init", false) + ok_failed("echo 'My Octopress Page is coming soon …' > index.html", false) + ok_failed("git add -A", false) + ok_failed("git commit -m \"Octopress init\"", false) + ok_failed("git branch -m #{deploy_branch}", false) unless branch == 'master' + ok_failed("git remote add origin #{repo_url}", false) rakefile.sub!(/deploy_default(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_default\\1=\\2\\3push\\3") end if use_token @@ -676,7 +676,7 @@ task :setup_github_pages, [:repo, :yes] do |t, args| File.open(__FILE__, 'w') do |f| f.write rakefile end - ok_failed("rake set_root_dir[#{project}]") + ok_failed("rake set_root_dir[#{project}]", false) end def get_stdin(message) @@ -746,7 +746,7 @@ def grep_check(word, grep_option, opt) echo #{comment};\ printf \"\\\\e[m\\\\n\";\ exit 1;\ - fi") + fi", false) end desc 'Check source' @@ -777,7 +777,7 @@ task :check, :opt do |t, args| exit 1;\ fi;\ done < #{word_avoid};\ - fi") + fi", false) puts "" end @@ -886,10 +886,10 @@ task :ping do end task :test do - #ok_failed("if [ -f #{word_avoid} ];then while read a;do if ret=`grep -i -r -q $a #{public_dir}`;then echo \"A word $a is included, must be avoided!!!\"; echo $ret; exit 1;fi; done < #{word_avoid};fi") - #ok_failed("cd #{public_dir};pwd;cd -") + #ok_failed("if [ -f #{word_avoid} ];then while read a;do if ret=`grep -i -r -q $a #{public_dir}`;then echo \"A word $a is included, must be avoided!!!\"; echo $ret; exit 1;fi; done < #{word_avoid};fi", false) + #ok_failed("cd #{public_dir};pwd;cd -", false) #raise "eror" - ok_failed("git ls >& log") + ok_failed("git ls >& log", false) end def ok_failed(command, print_ok = false) diff --git a/patches/Rakefile.patch b/patches/Rakefile.patch index b662ef1..ebfc86b 100644 --- a/patches/Rakefile.patch +++ b/patches/Rakefile.patch @@ -1,5 +1,5 @@ diff --git a/Rakefile b/Rakefile -index 9367ea1..ed70a63 100644 +index 9367ea1..6fcace6 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,8 @@ @@ -141,8 +141,8 @@ index 9367ea1..ed70a63 100644 + end + end + -+ ok_failed("rm -f .integrated") -+ ok_failed("rm -f .preview-mode") ++ ok_failed("rm -f .integrated", false) ++ ok_failed("rm -f .preview-mode", false) +end + +desc "Same as generate" @@ -374,7 +374,7 @@ index 9367ea1..ed70a63 100644 + end + end + end -+ ok_failed("touch .isolated") ++ ok_failed("touch .isolated", false) end desc "Move all stashed posts back into the posts directory, ready for site generation." @@ -382,8 +382,8 @@ index 9367ea1..ed70a63 100644 - FileUtils.mv Dir.glob("#{source_dir}/#{stash_dir}/*.*"), "#{source_dir}/#{posts_dir}/" + FileUtils.mv Dir.glob("#{full_stash_dir}/*"), "#{source_dir}/#{posts_dir}/" + FileUtils.mv Dir.glob("#{full_stash_root_dir}/*"), "#{source_dir}/" -+ ok_failed("rm -f .isolated") -+ ok_failed("touch .integrated") ++ ok_failed("rm -f .isolated", false) ++ ok_failed("touch .integrated", false) end -desc "Clean out caches: .pygments-cache, .gist-cache, .sass-cache" @@ -406,7 +406,7 @@ index 9367ea1..ed70a63 100644 + # Check if preview posts exists, which should not be published + if File.exist?(".integrated") or File.exist?(".isolated") + puts "## Found isolated history, regenerating files ..." -+ ok_failed("rm -f .integrated .isolated") ++ ok_failed("rm -f .integrated .isolated", false) + Rake::Task[:integrate].execute + Rake::Task[:generate].execute + end @@ -420,7 +420,7 @@ index 9367ea1..ed70a63 100644 - Rake::Task["#{deploy_default}"].execute + + # Check if files are fine or not -+ ok_failed("if [ -f #{word_avoid} ];then while read a;do if ret=`grep -i -r -q $a #{public_dir}`;then echo \"A word $a is included, must be avoided!!!\"; echo $ret; exit 1;fi; done < #{word_avoid};fi") ++ ok_failed("if [ -f #{word_avoid} ];then while read a;do if ret=`grep -i -r -q $a #{public_dir}`;then echo \"A word $a is included, must be avoided!!!\"; echo $ret; exit 1;fi; done < #{word_avoid};fi", false) + + if args.deploy_method + deploy_method = args.deploy_method; @@ -458,7 +458,7 @@ index 9367ea1..ed70a63 100644 end puts "## Deploying website via Rsync" - ok_failed system("rsync -avze 'ssh -p #{ssh_port}' #{exclude} #{rsync_args} #{"--delete" unless rsync_delete == false} #{public_dir}/ #{ssh_user}:#{document_root}") -+ ok_failed("rsync -avze 'ssh -p #{ssh_port}' #{exclude} #{rsync_args} #{"--delete" unless rsync_delete == false} #{public_dir}/ #{ssh_user}:#{document_root}") ++ ok_failed("rsync -avze 'ssh -p #{ssh_port}' #{exclude} #{rsync_args} #{"--delete" unless rsync_delete == false} #{public_dir}/ #{ssh_user}:#{document_root}", false) end desc "deploy public directory to github pages" @@ -468,7 +468,7 @@ index 9367ea1..ed70a63 100644 - cd "#{deploy_dir}" do - Bundler.with_clean_env { system "git pull" } + cd "#{deploy_dir}" do -+ Bundler.with_original_env { ok_failed("git pull") } ++ Bundler.with_original_env { ok_failed("git pull", false) } end (Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) } Rake::Task[:copydot].invoke(public_dir, deploy_dir) @@ -476,15 +476,15 @@ index 9367ea1..ed70a63 100644 cp_r "#{public_dir}/.", deploy_dir cd "#{deploy_dir}" do - system "git add -A" -+ ok_failed("git add -A") ++ ok_failed("git add -A", false) message = "Site updated at #{Time.now.utc}" puts "\n## Committing: #{message}" - system "git commit -m \"#{message}\"" -+ ok_failed("git commit -m \"#{message}\"") ++ ok_failed("git commit -m \"#{message}\"", false) puts "\n## Pushing generated #{deploy_dir} website" - Bundler.with_clean_env { system "git push origin #{deploy_branch}" } + output = (use_token)? " >/dev/null 2>&1":"" -+ Bundler.with_original_env { ok_failed("git push origin #{deploy_branch} #{output}") } ++ Bundler.with_original_env { ok_failed("git push origin #{deploy_branch} #{output}", false) } + puts "\n## Github Pages deploy complete" + end +end @@ -500,22 +500,22 @@ index 9367ea1..ed70a63 100644 + rm_rf deploy_dir + mkdir_p deploy_dir + cd "#{deploy_dir}" do -+ ok_failed("git init") -+ ok_failed("git remote add origin #{repo_url}") ++ ok_failed("git init", false) ++ ok_failed("git remote add origin #{repo_url}", false) + end + + Rake::Task[:copydot].invoke(public_dir, deploy_dir) + puts "\n## Copying #{public_dir} to #{deploy_dir}" + cp_r "#{public_dir}/.", deploy_dir + cd "#{deploy_dir}" do -+ ok_failed("git add -A") ++ ok_failed("git add -A", false) + puts "\n## Commiting: Site updated at #{Time.now.utc}" + message = "Site updated at #{Time.now.utc}" -+ ok_failed("git commit -m \"#{message}\" >/dev/null") -+ ok_failed("git branch -m #{deploy_branch}") ++ ok_failed("git commit -m \"#{message}\" >/dev/null", false) ++ ok_failed("git branch -m #{deploy_branch}", false) + puts "\n## Pushing generated #{deploy_dir} website" + output = (use_token) ? " >/dev/null 2>&1" : "" -+ Bundler.with_unbundled_env { ok_failed("git push -u -f origin #{deploy_branch} #{output}") } ++ Bundler.with_unbundled_env { ok_failed("git push -u -f origin #{deploy_branch} #{output}", false) } puts "\n## Github Pages deploy complete" end end @@ -593,7 +593,7 @@ index 9367ea1..ed70a63 100644 unless (`git remote -v` =~ /origin.+?octopress(?:\.git)?/).nil? # If octopress is still the origin remote (from cloning) rename it to octopress - system "git remote rename origin octopress" -+ ok_failed("git remote rename origin octopress") ++ ok_failed("git remote rename origin octopress", false) if branch == 'master' # If this is a user/organization pages repository, add the correct origin remote # and checkout the source branch for committing changes to the blog source. @@ -606,15 +606,15 @@ index 9367ea1..ed70a63 100644 - else - unless !public_dir.match("#{project}").nil? - system "rake set_root_dir[#{project}]" -+ ok_failed("git remote add origin #{repo_url}") ++ ok_failed("git remote add origin #{repo_url}", false) + if use_token + puts "Added given remote as origin" + else + puts "Added remote #{repo_url} as origin" end -+ ok_failed("git config branch.master.remote origin") ++ ok_failed("git config branch.master.remote origin", false) + puts "Set origin as default remote" -+ ok_failed("git branch -m master source") ++ ok_failed("git branch -m master source", false) + puts "Master branch renamed to 'source' for committing your blog source files" end end @@ -672,12 +672,12 @@ index 9367ea1..ed70a63 100644 + rm_rf deploy_dir + mkdir deploy_dir + cd "#{deploy_dir}" do -+ ok_failed("git init") -+ ok_failed("echo 'My Octopress Page is coming soon …' > index.html") -+ ok_failed("git add -A") -+ ok_failed("git commit -m \"Octopress init\"") -+ ok_failed("git branch -m #{deploy_branch}") unless branch == 'master' -+ ok_failed("git remote add origin #{repo_url}") ++ ok_failed("git init", false) ++ ok_failed("echo 'My Octopress Page is coming soon …' > index.html", false) ++ ok_failed("git add -A", false) ++ ok_failed("git commit -m \"Octopress init\"", false) ++ ok_failed("git branch -m #{deploy_branch}", false) unless branch == 'master' ++ ok_failed("git remote add origin #{repo_url}", false) + rakefile.sub!(/deploy_default(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_default\\1=\\2\\3push\\3") + end + if use_token @@ -697,7 +697,7 @@ index 9367ea1..ed70a63 100644 + File.open(__FILE__, 'w') do |f| + f.write rakefile end -+ ok_failed("rake set_root_dir[#{project}]") ++ ok_failed("rake set_root_dir[#{project}]", false) end def get_stdin(message) @@ -768,7 +768,7 @@ index 9367ea1..ed70a63 100644 + echo #{comment};\ + printf \"\\\\e[m\\\\n\";\ + exit 1;\ -+ fi") ++ fi", false) +end + +desc 'Check source' @@ -799,7 +799,7 @@ index 9367ea1..ed70a63 100644 + exit 1;\ + fi;\ + done < #{word_avoid};\ -+ fi") ++ fi", false) + puts "" +end + @@ -908,10 +908,10 @@ index 9367ea1..ed70a63 100644 +end + +task :test do -+ #ok_failed("if [ -f #{word_avoid} ];then while read a;do if ret=`grep -i -r -q $a #{public_dir}`;then echo \"A word $a is included, must be avoided!!!\"; echo $ret; exit 1;fi; done < #{word_avoid};fi") -+ #ok_failed("cd #{public_dir};pwd;cd -") ++ #ok_failed("if [ -f #{word_avoid} ];then while read a;do if ret=`grep -i -r -q $a #{public_dir}`;then echo \"A word $a is included, must be avoided!!!\"; echo $ret; exit 1;fi; done < #{word_avoid};fi", false) ++ #ok_failed("cd #{public_dir};pwd;cd -", false) + #raise "eror" -+ ok_failed("git ls >& log") ++ ok_failed("git ls >& log", false) +end + +def ok_failed(command, print_ok = false) diff --git a/setup.sh b/setup.sh index 04ffff0..2472648 100755 --- a/setup.sh +++ b/setup.sh @@ -121,7 +121,7 @@ fi echo # replace plugins -yesno "Do you want to replace plugins ($(find $theme_dir/plugins/ -name "*.rb" -print0 |xargs -0 basename|tr "\n" " " ))?" +yesno "Do you want to replace plugins ($(find $theme_dir/plugins/ -name "*.rb" -exec basename {} \;|tr "\n" " " ))?" ret=$? if [ $ret -eq 0 ];then for p in $theme_dir/plugins/*rb;do