From dc2d826362766c7a8be4c08531c6d4b0e7d279a2 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Mon, 17 Oct 2022 05:08:50 +0200 Subject: [PATCH] packages: clean up cmd_init --- packages/cli.py | 13 ++++++++++--- packages/pkgbuild.py | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/cli.py b/packages/cli.py index fe288e4..3f1666c 100644 --- a/packages/cli.py +++ b/packages/cli.py @@ -50,8 +50,11 @@ def cmd_packages(): """Build and manage packages and PKGBUILDs""" +non_interactive_flag = click.option('--non-interactive', is_flag=True) + + @cmd_packages.command(name='update') -@click.option('--non-interactive', is_flag=True) +@non_interactive_flag @click.option('--switch-branch', is_flag=True, help="Force the branch to be corrected even in non-interactive mode") def cmd_update(non_interactive: bool = False, switch_branch: bool = False): """Update PKGBUILDs git repo""" @@ -60,8 +63,12 @@ def cmd_update(non_interactive: bool = False, switch_branch: bool = False): discover_pkgbuilds(lazy=False) -# alias "update" to "init" -cmd_packages.add_command(cmd_update, 'init') +@cmd_packages.command(name='init') +@non_interactive_flag +@click.option('-u', '--update', is_flag=True, help='Use git pull to update the PKGBUILDs') +def cmd_init(non_interactive: bool = False, update: bool = False): + "Ensure PKGBUILDs git repo is checked out locally" + init_pkgbuilds(interactive=not non_interactive, lazy=False, update=update, switch_branch=False) @cmd_packages.command(name='build') diff --git a/packages/pkgbuild.py b/packages/pkgbuild.py index 12f52d5..9959cae 100644 --- a/packages/pkgbuild.py +++ b/packages/pkgbuild.py @@ -38,6 +38,7 @@ def clone_pkgbuilds(pkgbuilds_dir: str, repo_url: str, branch: str, interactive= result = git(['switch', branch], dir=pkgbuilds_dir) if result.returncode != 0: raise Exception('failed switching PKGBUILDs branches') + logging.warning('Hint: you can use `kupferbootstrap packages update` to switch branches') if update: if interactive: