kas: Support --update argument
By default we do not update a repository if the desired refspec is already checked out and so we do not pull any new commits that may have been added to this refspec upstream. If the new `--update` argument is passed on the command line then we instead pull in any new upstream commits. Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
1569895001
commit
24f2f66cf5
@ -130,3 +130,7 @@ class Context:
|
|||||||
@property
|
@property
|
||||||
def force_checkout(self):
|
def force_checkout(self):
|
||||||
return getattr(self.args, 'force_checkout', None)
|
return getattr(self.args, 'force_checkout', None)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def update(self):
|
||||||
|
return getattr(self.args, 'update', None)
|
||||||
|
@ -109,6 +109,10 @@ def setup_parser_common_args(parser):
|
|||||||
parser.add_argument('--force-checkout', action='store_true',
|
parser.add_argument('--force-checkout', action='store_true',
|
||||||
help='Always checkout the desired refspec of each '
|
help='Always checkout the desired refspec of each '
|
||||||
'repository, discarding any local changes')
|
'repository, discarding any local changes')
|
||||||
|
parser.add_argument('--update', action='store_true',
|
||||||
|
help='Pull new upstream changes to the desired '
|
||||||
|
'refspec even if it is already checked out locally')
|
||||||
|
|
||||||
|
|
||||||
def kas_get_argparser():
|
def kas_get_argparser():
|
||||||
"""
|
"""
|
||||||
|
@ -193,6 +193,7 @@ class RepoImpl(Repo):
|
|||||||
if self.refspec is None:
|
if self.refspec is None:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
if not get_context().update:
|
||||||
# Does refspec exist in the current repository?
|
# Does refspec exist in the current repository?
|
||||||
(retc, output) = await run_cmd_async(self.contains_refspec_cmd(),
|
(retc, output) = await run_cmd_async(self.contains_refspec_cmd(),
|
||||||
cwd=self.path,
|
cwd=self.path,
|
||||||
@ -203,7 +204,7 @@ class RepoImpl(Repo):
|
|||||||
self.name, self.refspec, output.strip())
|
self.name, self.refspec, output.strip())
|
||||||
return retc
|
return retc
|
||||||
|
|
||||||
# No it is missing, try to fetch
|
# Try to fetch if refspec is missing or if --update argument was passed
|
||||||
(retc, output) = await run_cmd_async(self.fetch_cmd(),
|
(retc, output) = await run_cmd_async(self.fetch_cmd(),
|
||||||
cwd=self.path,
|
cwd=self.path,
|
||||||
fail=False)
|
fail=False)
|
||||||
|
Loading…
Reference in New Issue
Block a user