Skip to content

Instantly share code, notes, and snippets.

@Shinya131
Last active August 29, 2015 14:22
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 Shinya131/b35f569629275e011d99 to your computer and use it in GitHub Desktop.
Save Shinya131/b35f569629275e011d99 to your computer and use it in GitHub Desktop.
許可されたAuther以外行ったコミットを出力
require 'git'
RIPO_PATH = '/Users/xxxx_xxxx/xxxxxxxx'
BRANCH = 'develop'
LOG_COUNT = 1000
SINCE = '2 days ago'
ALLOWED_AUTHER_NAMES = ['aaa', 'bbb', 'ccc']
# 調査対象のコミットを取ってくる
def survey_target_commits
g = Git.open(RIPO_PATH)
g.checkout(BRANCH)
g.log(LOG_COUNT).since(SINCE)
end
# 調査対象のコミットから、許可されていないAutherによるコミットを取ってくる
def denied_auther_commits
survey_target_commits.select do |commit|
denied_auther_commit?(commit)
end
end
# ALLOWED_AUTHER以外のコミットだったらtrue
def denied_auther_commit?(commit)
!ALLOWED_AUTHER_NAMES.include?(commit.author.name)
end
# 適当に表示
denied_auther_commits.each do |commit|
print "#{commit.sha},#{commit.author.name},#{commit.date},"
p commit.message
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment