Created
June 6, 2017 13:54
-
-
Save tmr111116/86ab89ba86edb52c419e6e30fa0059d4 to your computer and use it in GitHub Desktop.
git-flow っぽい git のログから pull requests を再現する。
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
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: |
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
#! 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