forked from sds/overcommit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gerrit_change_id.rb
22 lines (19 loc) · 761 Bytes
/
gerrit_change_id.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true
module Overcommit::Hook::CommitMsg
# Ensures a Gerrit Change-Id line is included in the commit message.
#
# It may seem odd to do this here instead of in a prepare-commit-msg hook, but
# the reality is that if you want to _ensure_ the Change-Id is included then
# you need to do it in a commit-msg hook. This is because the user could still
# edit the message after a prepare-commit-msg hook was run.
#
# @see https://code.google.com/p/gerrit/
class GerritChangeId < Base
SCRIPT_LOCATION = Overcommit::Utils.script_path('gerrit-change-id')
def run
result = execute(['sh', SCRIPT_LOCATION, commit_message_file])
return :pass if result.success?
[:fail, result.stdout]
end
end
end