Skip to content

Instantly share code, notes, and snippets.

@tmr111116
Created June 6, 2017 13:54
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 tmr111116/86ab89ba86edb52c419e6e30fa0059d4 to your computer and use it in GitHub Desktop.
Save tmr111116/86ab89ba86edb52c419e6e30fa0059d4 to your computer and use it in GitHub Desktop.
git-flow っぽい git のログから pull requests を再現する。
git-flow っぽい git のログから pull requests を再現する。
```
git log master --reverse --grep 'feature.*into develop' --format='%p %s' --merges --after=2017-03-23 --before=2017-06-01 | ruby -pe "\$_.gsub! /Merge branch '(.+)'.*/, '\\1'"
```
で、特定期間の develop ブランチへマージしたログを切り出す。
これを make_pulls.rb に渡すと、そのマージコミットを再現する pull req を作る。
何かエラーが出たら止まるので手動で対応する。 :innocent:
#! ruby
def sh(command)
puts "$ " + command
system command or fail
end
TOKEN = "XXXXXXXXXXXXXXXXXXXXXXXXX"
def github(path, body)
sh "curl --fail -H 'Authorization: token #{TOKEN}' -X POST -d '#{body}' https://api.github.com#{path} >> /dev/null"
end
def create(title, head, base)
github("/repos/XXXXXXXXX/XXXXXXXXXXXX/pulls", %({"title":"#{title}", "head":"#{head}", "base":"#{base}"}))
end
STDIN.each_line {|line|
base, feature, name = line.split
puts "#{base} #{feature} #{name}"
sh "git checkout develop"
sh "git merge #{base}"
sh "git push origin develop"
sh "git branch #{name} #{feature}"
sh "git push origin #{name}"
sh "git branch -D #{name}"
create(name, name, 'develop')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment