Last active
August 29, 2015 13:57
-
-
Save motoishmz/9384488 to your computer and use it in GitHub Desktop.
creating/applying patches to ofxaddons
This file contains hidden or 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 | |
dir_addons = File.expand_path("../addons") | |
module PatchingMode | |
CREATE = 1 | |
APPLY = 2 | |
end | |
def patch(patching_mode, path_to_addons_dir, ofxaddon) | |
ofxaddon_path = path_to_addons_dir + "/" + ofxaddon | |
return puts ofxaddon_path + " not found" unless FileTest.exists?(ofxaddon_path) | |
Dir.chdir(ofxaddon_path) { | |
patch_filename = "#{ofxaddon}.patch" | |
if (patching_mode == PatchingMode::CREATE) then | |
`git diff --no-prefix HEAD~ > #{path_to_addons_dir}/#{patch_filename}` | |
puts "Finished creating #{patch_filename}" | |
elsif (patching_mode == PatchingMode::APPLY) then | |
`patch -p0 < #{path_to_addons_dir}/#{patch_filename}` | |
puts "Finished applying #{patch_filename}" | |
else | |
puts "Unknown patching mode... done nothing to #{ofxaddon}" | |
end | |
} | |
end | |
# our main code | |
# ・゜・*:.。..:*・'。. .。.:*・゜・* | |
# create | |
patch(PatchingMode::CREATE, dir_addons, "ofxBlackMagic") | |
# apply | |
# patch(PatchingMode::APPLY, dir_addons, "ofxBlackMagic") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment