mirror of https://github.com/xemu-project/xemu.git
scripts/ci: clean up default args logic a little
This allows us to do: ./scripts/ci/gitlab-pipeline-status -w -b HEAD -p 2961854 to check out own pipeline status of a recently pushed branch. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Message-Id: <20201117173635.29101-2-alex.bennee@linaro.org>
This commit is contained in:
parent
8cc30eb140
commit
e4b937d3c4
|
@ -31,7 +31,7 @@ class NoPipelineFound(Exception):
|
||||||
"""Communication is successfull but pipeline is not found."""
|
"""Communication is successfull but pipeline is not found."""
|
||||||
|
|
||||||
|
|
||||||
def get_local_branch_commit(branch='staging'):
|
def get_local_branch_commit(branch):
|
||||||
"""
|
"""
|
||||||
Returns the commit sha1 for the *local* branch named "staging"
|
Returns the commit sha1 for the *local* branch named "staging"
|
||||||
"""
|
"""
|
||||||
|
@ -126,18 +126,16 @@ def create_parser():
|
||||||
help=('The GitLab project ID. Defaults to the project '
|
help=('The GitLab project ID. Defaults to the project '
|
||||||
'for https://gitlab.com/qemu-project/qemu, that '
|
'for https://gitlab.com/qemu-project/qemu, that '
|
||||||
'is, "%(default)s"'))
|
'is, "%(default)s"'))
|
||||||
try:
|
parser.add_argument('-b', '--branch', type=str, default="staging",
|
||||||
default_commit = get_local_branch_commit()
|
help=('Specify the branch to check. '
|
||||||
commit_required = False
|
'Use HEAD for your current branch. '
|
||||||
except ValueError:
|
'Otherwise looks at "%(default)s"'))
|
||||||
default_commit = ''
|
parser.add_argument('-c', '--commit',
|
||||||
commit_required = True
|
default=None,
|
||||||
parser.add_argument('-c', '--commit', required=commit_required,
|
|
||||||
default=default_commit,
|
|
||||||
help=('Look for a pipeline associated with the given '
|
help=('Look for a pipeline associated with the given '
|
||||||
'commit. If one is not explicitly given, the '
|
'commit. If one is not explicitly given, the '
|
||||||
'commit associated with the local branch named '
|
'commit associated with the default branch '
|
||||||
'"staging" is used. Default: %(default)s'))
|
'is used.'))
|
||||||
parser.add_argument('--verbose', action='store_true', default=False,
|
parser.add_argument('--verbose', action='store_true', default=False,
|
||||||
help=('A minimal verbosity level that prints the '
|
help=('A minimal verbosity level that prints the '
|
||||||
'overall result of the check/wait'))
|
'overall result of the check/wait'))
|
||||||
|
@ -149,6 +147,10 @@ def main():
|
||||||
"""
|
"""
|
||||||
parser = create_parser()
|
parser = create_parser()
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if not args.commit:
|
||||||
|
args.commit = get_local_branch_commit(args.branch)
|
||||||
|
|
||||||
success = False
|
success = False
|
||||||
try:
|
try:
|
||||||
if args.wait:
|
if args.wait:
|
||||||
|
|
Loading…
Reference in New Issue