Created
September 4, 2012 16:56
-
-
Save pobo380/3623427 to your computer and use it in GitHub Desktop.
post-commit-hook-for-git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'fileutils' | |
log = open('|git log HEAD -1 --name-only --pretty="format:"').read | |
base_changes = log.scan(/^base\/(.*)\.(textile|yaml)$/) | |
unless base_changes.empty? | |
base_changes.each do |path, ext| | |
src_path, dest_path = ['base/', 'html/'].map{|e| e + path} | |
FileUtils.mkpath(File.dirname(dest_path)) | |
FileUtils.cp(src_path + '.' + ext, dest_path + '.copied.html') | |
end | |
puts open('|git add html/').read | |
puts open('|git commit html/ -m "auto commit"').read | |
puts open('|git checkout adjusted').read | |
puts open('|git merge source').read | |
end | |
html_changes = log.scan(/^html\/(.*)\.html$/) | |
unless html_changes.empty? | |
puts open('|git push origin adjusted') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment