Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _init_project(project):
log.small_banner(f'{project.name}: initializing')
project.git(['init', project.abspath], cwd=util.west_topdir())
# This remote is added as a convenience for the user.
# However, west always fetches project data by URL, not remote name.
# The user is therefore free to change the URL of this remote.
project.git(f'remote add -- {project.remote_name} {project.url}')
def clone_manifest(self, url: str, rev: str, dest: str,
exist_ok=False) -> None:
log.small_banner(f'Cloning manifest repository from {url}, rev. {rev}')
if not exist_ok and exists(dest):
log.die(f'refusing to clone into existing location {dest}')
self.check_call(('git', 'init', dest))
self.check_call(('git', 'remote', 'add', 'origin', '--', url),
cwd=dest)
maybe_sha = _maybe_sha(rev)
if maybe_sha:
# Fetch the ref-space and hope the SHA is contained in
# that ref-space
self.check_call(('git', 'fetch', 'origin', '--tags',
'--', 'refs/heads/*:refs/remotes/origin/*'),
cwd=dest)
else:
# Fetch the ref-space similar to git clone plus the ref
# given by user. Redundancy is ok, for example if the user
def print_lst(projects):
for p in projects:
log.small_banner(p.format('{name_and_path}'))
else:
# We use PurePath() here in case manifest_url is a
# windows-style path. That does the right thing in that
# case, without affecting POSIX platforms, where PurePath
# is PurePosixPath.
manifest_path = PurePath(urlparse(manifest_url).path).name
manifest_abspath = topdir / manifest_path
log.dbg('moving', tempdir, 'to', manifest_abspath,
level=log.VERBOSE_EXTREME)
try:
shutil.move(os.fspath(tempdir), os.fspath(manifest_abspath))
except shutil.Error as e:
log.die(e)
log.small_banner('setting manifest.path to', manifest_path)
update_config('manifest', 'path', manifest_path, topdir=topdir)
return topdir
else:
status = ('diverged from upstream: {} ahead, {} behind'.
format(ahead, behind))
upstream_rev = 'upstream revision: ' + zrev
if zrev != zsha:
upstream_rev += ' ({})'.format(zsha)
downstream_rev = 'NCS revision: ' + nrev
if nrev != nsha:
downstream_rev += ' ({})'.format(nsha)
if 'up to date' in status or 'ahead by' in status:
if log.VERBOSE > log.VERBOSE_NONE:
# Up to date or ahead: only print in verbose mode.
log.small_banner(banner)
status += ', ' + downstream_rev
if 'ahead by' in status:
status += ', ' + upstream_rev
log.inf(status)
self.likely_merged(np, zp, nsha, zsha)
else:
# Behind or diverged: always print.
log.small_banner(banner)
log.msg(status, color=log.WRN_COLOR)
log.inf(upstream_rev)
log.inf(downstream_rev)
self.likely_merged(np, zp, nsha, zsha)