Last active
July 25, 2017 15:57
-
-
Save IanVaughan/bc43ab9cac870e55b2a5bd18798183cd to your computer and use it in GitHub Desktop.
Convert todo list into git merge commands
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/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