aboutsummaryrefslogtreecommitdiff
path: root/pre-upload.py
diff options
context:
space:
mode:
authorLuis Hector Chavez <lhchavez@google.com>2016-10-16 21:56:58 -0700
committerLuis Hector Chavez <lhchavez@google.com>2016-10-17 21:51:54 -0700
commit5c4c293174bb61f0f39035a71acd9084abfa743d (patch)
treeb4ae15a61eb8f8309bc6022edc4d36bab7e0e5c7 /pre-upload.py
parent25abf4bf354f937d46c125776f33478f0b4b71b9 (diff)
downloadrepohooks-5c4c293174bb61f0f39035a71acd9084abfa743d.tar.gz
Add an option to ignore merged commits
When uploading merge-commits, git log will list commits that are not necessarily uploaded (since they have usually been already committed to another branch). In order to avoid developers skipping verification on these cases, this change adds an option to the config file that will add --first-parent to the git log invocation, so pre-upload checks are only performed on the commits that the developer intended. Bug: 31926893 Test: repo upload Change-Id: I76959906ed05b5cd09c4263fb54997b55dd6cfc3
Diffstat (limited to 'pre-upload.py')
-rwxr-xr-xpre-upload.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/pre-upload.py b/pre-upload.py
index 61bda1e..cc8d24a 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -140,8 +140,8 @@ def _process_hook_results(results):
return ret or None
-def _get_project_hooks():
- """Returns a list of hooks that need to be run for a project.
+def _get_project_config():
+ """Returns the configuration for a project.
Expects to be called from within the project root.
"""
@@ -161,7 +161,7 @@ def _get_project_hooks():
except rh.config.ValidationError as e:
print('invalid config file: %s' % (e,), file=sys.stderr)
sys.exit(1)
- return config.callable_hooks()
+ return config
def _run_project_hooks(project_name, proj_dir=None,
@@ -200,7 +200,8 @@ def _run_project_hooks(project_name, proj_dir=None,
os.chdir(proj_dir)
# If the repo has no pre-upload hooks enabled, then just return.
- hooks = list(_get_project_hooks())
+ config = _get_project_config()
+ hooks = list(config.callable_hooks())
if not hooks:
return True
@@ -221,7 +222,8 @@ def _run_project_hooks(project_name, proj_dir=None,
project = Project(name=project_name, dir=proj_dir, remote=remote)
if not commit_list:
- commit_list = rh.git.get_commits()
+ commit_list = rh.git.get_commits(
+ ignore_merged_commits=config.ignore_merged_commits)
ret = True