aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Sylvain <nsylvain@google.com>2016-05-02 18:58:22 -0700
committerAlex Vakulenko <avakulenko@google.com>2016-05-03 11:41:20 -0700
commit6f7988675e801269ff2a50db75557df10459833f (patch)
tree2a70be7a850e295fc9ec5be13de90490bade4ff0
parent8ec324d239f459307a9bbc8751ecf3112c09466d (diff)
downloadrepohooks-6f7988675e801269ff2a50db75557df10459833f.tar.gz
Add PRESUBMIT_COMMIT_MESSAGE to the env.
This will allow custom hooks to perform checks on the commit message in addition to the content of changed files. BUG: None Change-Id: I70ab8a570e5436bb90f061e1cc3174ebc5654e6b
-rw-r--r--README.md2
-rwxr-xr-xpre-upload.py1
-rw-r--r--rh/hooks.py2
3 files changed, 5 insertions, 0 deletions
diff --git a/README.md b/README.md
index e6b8d0c..5862930 100644
--- a/README.md
+++ b/README.md
@@ -74,6 +74,7 @@ that is executed.
my_first_hook = program --gogog ${PREUPLOAD_FILES}
another_hook = funtimes --i-need "some space" ${PREUPLOAD_FILES}
some_fish = linter --ate-a-cat ${PREUPLOAD_FILES}
+some_dog = tool --no-cat-in-commit-message ${PREUPLOAD_COMMIT_MESSAGE}
```
### `[Builtin Hooks]`
@@ -118,6 +119,7 @@ such will be expanded correctly via argument positions, so do not try to
force your own quote handling.
* `${PREUPLOAD_FILES}`: List of files to operate on.
+* `${PREUPLOAD_COMMIT_MESSAGE}`: Commit message.
```
[Builtin Hooks Options]
diff --git a/pre-upload.py b/pre-upload.py
index e9bdfa2..6cb19b7 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -165,6 +165,7 @@ def _run_project_hooks(project_name, proj_dir=None,
os.environ['PREUPLOAD_COMMIT'] = commit
diff = rh.git.get_affected_files(commit)
desc = rh.git.get_commit_desc(commit)
+ os.environ['PREUPLOAD_COMMIT_MESSAGE'] = desc
results = []
for hook in hooks:
diff --git a/rh/hooks.py b/rh/hooks.py
index 8979bf1..2b9960b 100644
--- a/rh/hooks.py
+++ b/rh/hooks.py
@@ -89,6 +89,8 @@ def _update_options(options, diff):
for option in options:
if option == '${PREUPLOAD_FILES}':
ret.extend(x.file for x in diff if x.status != 'D')
+ elif option == '${PREUPLOAD_COMMIT_MESSAGE}':
+ ret.append(os.environ['PREUPLOAD_COMMIT_MESSAGE'])
else:
ret.append(option)
return ret