diff options
author | Mike Frysinger <vapier@google.com> | 2023-06-23 18:31:23 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-06-23 18:31:23 +0000 |
commit | 13cc37978b7d2e0a075a4c802cbada1037d43716 (patch) | |
tree | 5b83239021d12e8021c81e765fe58e94a5326e5c | |
parent | 52613a9ca6a00be9137f5453da3ecbf845fb4bc7 (diff) | |
parent | 1fc51c305b4b77365b3119062332843956b1be77 (diff) | |
download | repohooks-13cc37978b7d2e0a075a4c802cbada1037d43716.tar.gz |
pre-upload: hoist exclusion logic earlier am: 1fc51c305b
Original change: https://android-review.googlesource.com/c/platform/tools/repohooks/+/2634960
Change-Id: Iab5aefda34830c12b96b547c21b1edae31fd2e88
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rwxr-xr-x | pre-upload.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/pre-upload.py b/pre-upload.py index 5d57a71..6c43c42 100755 --- a/pre-upload.py +++ b/pre-upload.py @@ -319,8 +319,6 @@ def _run_project_hooks_in_cwd( if not hooks: return ret - output.set_num_hooks(len(hooks)) - # Set up the environment like repo would with the forall command. try: remote = rh.git.get_upstream_remote() @@ -334,6 +332,12 @@ def _run_project_hooks_in_cwd( project = rh.Project(name=project_name, dir=proj_dir) rel_proj_dir = os.path.relpath(proj_dir, rh.git.find_repo_root()) + # Filter out the hooks to process. + hooks = [x for x in hooks if rel_proj_dir not in x.scope] + if not hooks: + return ret + output.set_num_hooks(len(hooks)) + os.environ.update({ 'REPO_LREV': rh.git.get_commit_for_ref(upstream_branch), 'REPO_PATH': rel_proj_dir, @@ -357,11 +361,9 @@ def _run_project_hooks_in_cwd( commit_summary = desc.split('\n', 1)[0] output.commit_start(commit=commit, commit_summary=commit_summary) - for name, hook, exclusion_scope in hooks: - if rel_proj_dir in exclusion_scope: - continue - output.hook_start(name) - hook_results = hook(project, commit, desc, diff) + for hook in hooks: + output.hook_start(hook.name) + hook_results = hook.hook(project, commit, desc, diff) output.hook_finish() ret.add_results(hook_results) (error, warning) = _process_hook_results(hook_results) |