Skip to content

Instantly share code, notes, and snippets.

@IanVaughan
Last active July 25, 2017 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanVaughan/bc43ab9cac870e55b2a5bd18798183cd to your computer and use it in GitHub Desktop.
Save IanVaughan/bc43ab9cac870e55b2a5bd18798183cd to your computer and use it in GitHub Desktop.
Convert todo list into git merge commands
#!/usr/bin/env ruby
# Usage :
# In slack `/todo list`
# Copy output into a file, eg branches.txt
# Run this against branches.txt
# ./rebuild branches.txt
#
# Output
# git reset origin/master --hard
# git merge --no-edit --no-ff origin/fix1
# git merge --no-edit --no-ff origin/feature two
#
# Copy and paste that to execute it
file = ARGV[0]
data = File.read(file)
# sed -e 's/.*`\(.*\)`.*/git merge --no-edit --no-ff origin\/\1/'
FIND = /.*`(.*)`.*/
REPLACE = 'git merge --no-edit --no-ff origin/\1'.freeze
cmds = []
cmds << 'git reset origin/master --hard'
cmds << data.split("\n").map { |l| l.sub FIND, REPLACE }
puts cmds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment