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
|
||||
def force_checkout(self):
|
||||
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',
|
||||
help='Always checkout the desired refspec of each '
|
||||
'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():
|
||||
"""
|
||||
|
21
kas/repos.py
21
kas/repos.py
@ -193,17 +193,18 @@ class RepoImpl(Repo):
|
||||
if self.refspec is None:
|
||||
return 0
|
||||
|
||||
# Does refspec exist in the current repository?
|
||||
(retc, output) = await run_cmd_async(self.contains_refspec_cmd(),
|
||||
cwd=self.path,
|
||||
fail=False,
|
||||
liveupdate=False)
|
||||
if retc == 0:
|
||||
logging.info('Repository %s already contains %s as %s',
|
||||
self.name, self.refspec, output.strip())
|
||||
return retc
|
||||
if not get_context().update:
|
||||
# Does refspec exist in the current repository?
|
||||
(retc, output) = await run_cmd_async(self.contains_refspec_cmd(),
|
||||
cwd=self.path,
|
||||
fail=False,
|
||||
liveupdate=False)
|
||||
if retc == 0:
|
||||
logging.info('Repository %s already contains %s as %s',
|
||||
self.name, self.refspec, output.strip())
|
||||
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(),
|
||||
cwd=self.path,
|
||||
fail=False)
|
||||
|
Loading…
Reference in New Issue
Block a user