Created
October 13, 2016 09:09
-
-
Save kkyouhei/a116674edfabdd9d1216e06c21b8fc42 to your computer and use it in GitHub Desktop.
特定のラベルのブランチのマージコミットを作ってくれるコマンド
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
#! /usr/bin/env ruby | |
require 'thor' | |
require 'octokit' | |
require 'io/console' | |
class Matomarukun < Thor | |
desc "matomeru usage", "matomeru desc" | |
def matomeru user_id | |
print "please github password" | |
passwd = STDIN.noecho(&:gets).chomp | |
client = Octokit::Client.new login: user_id, password: passwd | |
timestamp = Time.now.to_i | |
commands = ["git fetch --all", "git checkout -b develop-#{timestamp} upstream/master"] | |
client.pull_requests("your repo name", state: "opened").each do |pr| | |
pr.rels[:issue].get.data.rels[:labels].get.data.each do |label| | |
if label[:name] == 'マージさせたいラベル名' || label[:name] == 'merge target this label name' | |
commands << "git merge remotes/pr/#{pr[:number]}/merge" | |
end | |
end | |
end | |
exec commands.join(" && ") | |
end | |
end | |
Matomarukun.start ARGV |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment