Skip to content

Instantly share code, notes, and snippets.

@lokeshjain2008
Created March 4, 2015 09:19
Show Gist options
  • Save lokeshjain2008/ebfa338f7b1e75494541 to your computer and use it in GitHub Desktop.
Save lokeshjain2008/ebfa338f7b1e75494541 to your computer and use it in GitHub Desktop.
to create patch folder from git status
#get all the files changed by git
files_raw = `git status | grep modified` # => "\tmodified: tests/AllTests.php\n\tmodified: tests/RLTestConfig.php\n"
files = files_raw
.gsub(/\n/,"#")
.gsub(/[\t\n]/,"") #remove unwanted elements
.split('#').reject{|element| element.length < 2} # get each line for the file
.map{|file| file.split(":").last.strip } # git the file name
p files # => ["tests/AllTests.php", "tests/RLTestConfig.php"]
foldername = 'localNeeded'
files.each do |file|
`rsync -R #{file} #{foldername}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment