packages/cli: add --switch-branch to cmd_init
This commit is contained in:
parent
60d8cb77ea
commit
45eba305cb
2 changed files with 17 additions and 4 deletions
|
@ -10,7 +10,7 @@ from constants import SRCINFO_METADATA_FILE
|
||||||
from exec.cmd import run_cmd
|
from exec.cmd import run_cmd
|
||||||
from exec.file import get_temp_dir
|
from exec.file import get_temp_dir
|
||||||
from logger import setup_logging
|
from logger import setup_logging
|
||||||
from packages.cli import SRCINFO_CACHE_FILES, cmd_build, cmd_clean, cmd_update
|
from packages.cli import SRCINFO_CACHE_FILES, cmd_build, cmd_clean, cmd_init, cmd_update
|
||||||
from utils import git_get_branch
|
from utils import git_get_branch
|
||||||
|
|
||||||
tempdir = None
|
tempdir = None
|
||||||
|
@ -57,7 +57,7 @@ def test_packages_update(ctx: click.Context):
|
||||||
for branch, may_fail in branches.items():
|
for branch, may_fail in branches.items():
|
||||||
config.file.pkgbuilds.git_branch = branch
|
config.file.pkgbuilds.git_branch = branch
|
||||||
try:
|
try:
|
||||||
ctx.invoke(cmd_update, non_interactive=True, switch_branch=True, discard_changes=True, init_caches=False)
|
ctx.invoke(cmd_init, update=True, non_interactive=True, switch_branch=True, discard_changes=True, init_caches=False)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print(f'may_fail: {may_fail}; Exception: {ex}')
|
print(f'may_fail: {may_fail}; Exception: {ex}')
|
||||||
if not may_fail:
|
if not may_fail:
|
||||||
|
|
|
@ -135,6 +135,8 @@ remove_outdated_src_flag = click.option(
|
||||||
show_default=True,
|
show_default=True,
|
||||||
help="Remove outdated src/ directories to avoid problems",
|
help="Remove outdated src/ directories to avoid problems",
|
||||||
)
|
)
|
||||||
|
switch_branch_flag = click.option('--switch-branch', is_flag=True, help="Force the branch to be corrected even in non-interactive mode")
|
||||||
|
discard_changes_flag = click.option('--discard-changes', is_flag=True, help="When switching branches, discard any locally changed conflicting files")
|
||||||
|
|
||||||
|
|
||||||
@click.group(name='packages')
|
@click.group(name='packages')
|
||||||
|
@ -145,6 +147,8 @@ def cmd_packages():
|
||||||
@cmd_packages.command(name='update')
|
@cmd_packages.command(name='update')
|
||||||
@non_interactive_flag
|
@non_interactive_flag
|
||||||
@init_caches_flag
|
@init_caches_flag
|
||||||
|
@switch_branch_flag
|
||||||
|
@discard_changes_flag
|
||||||
@remove_outdated_src_flag
|
@remove_outdated_src_flag
|
||||||
def cmd_update(
|
def cmd_update(
|
||||||
non_interactive: bool = False,
|
non_interactive: bool = False,
|
||||||
|
@ -164,11 +168,20 @@ def cmd_update(
|
||||||
@cmd_packages.command(name='init')
|
@cmd_packages.command(name='init')
|
||||||
@non_interactive_flag
|
@non_interactive_flag
|
||||||
@init_caches_flag
|
@init_caches_flag
|
||||||
|
@switch_branch_flag
|
||||||
|
@discard_changes_flag
|
||||||
@remove_outdated_src_flag
|
@remove_outdated_src_flag
|
||||||
@click.option('-u', '--update', is_flag=True, help='Use git pull to update the PKGBUILDs')
|
@click.option('-u', '--update', is_flag=True, help='Use git pull to update the PKGBUILDs')
|
||||||
def cmd_init(non_interactive: bool = False, init_caches: bool = True, clean_src_dirs: bool = True, update: bool = False):
|
def cmd_init(
|
||||||
|
non_interactive: bool = False,
|
||||||
|
init_caches: bool = True,
|
||||||
|
clean_src_dirs: bool = True,
|
||||||
|
switch_branch: bool = False,
|
||||||
|
discard_changes: bool = False,
|
||||||
|
update: bool = False,
|
||||||
|
):
|
||||||
"Ensure PKGBUILDs git repo is checked out locally"
|
"Ensure PKGBUILDs git repo is checked out locally"
|
||||||
init_pkgbuilds(interactive=not non_interactive, lazy=False, update=update, switch_branch=False)
|
init_pkgbuilds(interactive=not non_interactive, lazy=False, update=update, switch_branch=switch_branch, discard_changes=discard_changes)
|
||||||
if init_caches:
|
if init_caches:
|
||||||
init_pkgbuild_caches(clean_src_dirs=clean_src_dirs)
|
init_pkgbuild_caches(clean_src_dirs=clean_src_dirs)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue