diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2023-06-11 01:40:12 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-06-11 01:40:12 +0000 |
commit | e669af6414ef37f30e6a27a50f80b77620c244df (patch) | |
tree | 93e5405f5926588e7dd9663c7faa0e9af96be97b | |
parent | 13285896d0e51447e5d7e20fb21d89d091d911b9 (diff) | |
parent | 5f194f1138c18387845ac63a519dddfe6ca05018 (diff) | |
download | repohooks-e669af6414ef37f30e6a27a50f80b77620c244df.tar.gz |
Merge "pre-upload: handle Ctrl+C when running directly"
-rwxr-xr-x | pre-upload.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/pre-upload.py b/pre-upload.py index cf97e10..5c820c6 100755 --- a/pre-upload.py +++ b/pre-upload.py @@ -22,6 +22,7 @@ when developing. import argparse import datetime import os +import signal import sys from typing import List, Optional @@ -551,9 +552,13 @@ def direct_main(argv): if not opts.project: parser.error(f"Couldn't identify the project of {opts.dir}") - if _run_projects_hooks([opts.project], [opts.dir], from_git=opts.git, - commit_list=opts.commits): - return 0 + try: + if _run_projects_hooks([opts.project], [opts.dir], from_git=opts.git, + commit_list=opts.commits): + return 0 + except KeyboardInterrupt: + print('Aborting execution early due to user interrupt', file=sys.stderr) + return 128 + signal.SIGINT return 1 |