repos: Remove ctx parameter from repo functions and their callers
We can use the global context instead. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
7937c1963e
commit
b349f86457
@ -197,7 +197,7 @@ class ReposFetch(Command):
|
||||
return 'repos_fetch'
|
||||
|
||||
def execute(self, ctx):
|
||||
repos_fetch(ctx, ctx.config.get_repos())
|
||||
repos_fetch(ctx.config.get_repos())
|
||||
|
||||
|
||||
class ReposApplyPatches(Command):
|
||||
@ -209,7 +209,7 @@ class ReposApplyPatches(Command):
|
||||
return 'repos_apply_patches'
|
||||
|
||||
def execute(self, ctx):
|
||||
repos_apply_patches(ctx, ctx.config.get_repos())
|
||||
repos_apply_patches(ctx.config.get_repos())
|
||||
|
||||
|
||||
class ReposCheckout(Command):
|
||||
@ -222,7 +222,7 @@ class ReposCheckout(Command):
|
||||
|
||||
def execute(self, ctx):
|
||||
for repo in ctx.config.get_repos():
|
||||
repo.checkout(ctx)
|
||||
repo.checkout()
|
||||
|
||||
|
||||
class SetupRepos(Command):
|
||||
@ -255,10 +255,10 @@ class SetupRepos(Command):
|
||||
for repo_name in missing_repo_names
|
||||
if repo_name in ctx.config.repo_dict]
|
||||
|
||||
repos_fetch(ctx, missing_repos)
|
||||
repos_fetch(missing_repos)
|
||||
|
||||
for repo in missing_repos:
|
||||
repo.checkout(ctx)
|
||||
repo.checkout()
|
||||
|
||||
ctx.config.repo_dict = ctx.config._get_repo_dict()
|
||||
|
||||
@ -272,10 +272,10 @@ class SetupRepos(Command):
|
||||
# now fetch everything with complete config and check out layers
|
||||
# except if keep_config is set
|
||||
if not ctx.keep_config:
|
||||
repos_fetch(ctx, ctx.config.get_repos())
|
||||
repos_fetch(ctx.config.get_repos())
|
||||
|
||||
for repo in ctx.config.get_repos():
|
||||
repo.checkout(ctx)
|
||||
repo.checkout()
|
||||
|
||||
logging.debug('Configuration from config file:\n%s',
|
||||
pprint.pformat(ctx.config._config))
|
||||
|
@ -168,7 +168,7 @@ def find_program(paths, name):
|
||||
return None
|
||||
|
||||
|
||||
def repos_fetch(config, repos):
|
||||
def repos_fetch(repos):
|
||||
"""
|
||||
Fetches the list of repositories to the kas_work_dir.
|
||||
"""
|
||||
@ -176,9 +176,9 @@ def repos_fetch(config, repos):
|
||||
for repo in repos:
|
||||
if not hasattr(asyncio, 'ensure_future'):
|
||||
# pylint: disable=no-member,deprecated-method
|
||||
task = asyncio.async(repo.fetch_async(config))
|
||||
task = asyncio.async(repo.fetch_async())
|
||||
else:
|
||||
task = asyncio.ensure_future(repo.fetch_async(config))
|
||||
task = asyncio.ensure_future(repo.fetch_async())
|
||||
tasks.append(task)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
@ -189,7 +189,7 @@ def repos_fetch(config, repos):
|
||||
sys.exit(task.result())
|
||||
|
||||
|
||||
def repos_apply_patches(config, repos):
|
||||
def repos_apply_patches(repos):
|
||||
"""
|
||||
Applies the patches to the repositories.
|
||||
"""
|
||||
@ -197,9 +197,9 @@ def repos_apply_patches(config, repos):
|
||||
for repo in repos:
|
||||
if not hasattr(asyncio, 'ensure_future'):
|
||||
# pylint: disable=no-member,deprecated-method
|
||||
task = asyncio.async(repo.apply_patches_async(config))
|
||||
task = asyncio.async(repo.apply_patches_async())
|
||||
else:
|
||||
task = asyncio.ensure_future(repo.apply_patches_async(config))
|
||||
task = asyncio.ensure_future(repo.apply_patches_async())
|
||||
tasks.append(task)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
|
20
kas/repos.py
20
kas/repos.py
@ -146,7 +146,7 @@ class RepoImpl(Repo):
|
||||
"""
|
||||
|
||||
@asyncio.coroutine
|
||||
def fetch_async(self, ctx):
|
||||
def fetch_async(self):
|
||||
"""
|
||||
Start asynchronous repository fetch.
|
||||
"""
|
||||
@ -155,12 +155,13 @@ class RepoImpl(Repo):
|
||||
|
||||
if not os.path.exists(self.path):
|
||||
os.makedirs(os.path.dirname(self.path), exist_ok=True)
|
||||
sdir = os.path.join(ctx.kas_repo_ref_dir or '',
|
||||
sdir = os.path.join(get_context().kas_repo_ref_dir or '',
|
||||
self.qualified_name)
|
||||
logging.debug('Looking for repo ref dir in %s', sdir)
|
||||
|
||||
(retc, _) = yield from run_cmd_async(self.clone_cmd(sdir, ctx),
|
||||
cwd=ctx.kas_work_dir)
|
||||
(retc, _) = yield from run_cmd_async(
|
||||
self.clone_cmd(sdir),
|
||||
cwd=get_context().kas_work_dir)
|
||||
if retc == 0:
|
||||
logging.info('Repository %s cloned', self.name)
|
||||
return retc
|
||||
@ -190,7 +191,7 @@ class RepoImpl(Repo):
|
||||
logging.info('Repository %s updated', self.name)
|
||||
return 0
|
||||
|
||||
def checkout(self, _):
|
||||
def checkout(self):
|
||||
"""
|
||||
Checks out the correct revision of the repo.
|
||||
"""
|
||||
@ -217,7 +218,7 @@ class RepoImpl(Repo):
|
||||
run_cmd(self.checkout_cmd(), cwd=self.path)
|
||||
|
||||
@asyncio.coroutine
|
||||
def apply_patches_async(self, ctx):
|
||||
def apply_patches_async(self):
|
||||
"""
|
||||
Applies patches to repository asynchronously.
|
||||
"""
|
||||
@ -225,7 +226,8 @@ class RepoImpl(Repo):
|
||||
return 0
|
||||
|
||||
for patch in self._patches:
|
||||
other_repo = ctx.config.repo_dict.get(patch['repo'], None)
|
||||
other_repo = get_context().config.repo_dict.get(patch['repo'],
|
||||
None)
|
||||
|
||||
if not other_repo:
|
||||
logging.warning('Could not find referenced repo. '
|
||||
@ -274,9 +276,9 @@ class GitRepo(RepoImpl):
|
||||
"""
|
||||
# pylint: disable=no-self-use,missing-docstring
|
||||
|
||||
def clone_cmd(self, gitsrcdir, ctx):
|
||||
def clone_cmd(self, gitsrcdir):
|
||||
cmd = ['git', 'clone', '-q', self.url, self.path]
|
||||
if ctx.kas_repo_ref_dir and os.path.exists(gitsrcdir):
|
||||
if get_context().kas_repo_ref_dir and os.path.exists(gitsrcdir):
|
||||
cmd.extend(['--reference', gitsrcdir])
|
||||
return cmd
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user