Impr upgrade

This commit is contained in:
Javanaut
2026-04-11 15:08:08 +02:00
parent 71553aad32
commit c384d54c12
2 changed files with 135 additions and 0 deletions

View File

@@ -112,6 +112,24 @@ def getBundleRepoPath():
return getRepoRootPath()
def getTrackedGitChanges(repoPath):
completed = subprocess.run(
['git', 'status', '--porcelain', '--untracked-files=no'],
cwd=repoPath,
capture_output=True,
text=True,
)
if completed.returncode != 0:
commandLabel = 'git status --porcelain --untracked-files=no'
errorOutput = completed.stderr.strip() or completed.stdout.strip()
raise click.ClickException(
f"Unable to inspect bundle repository state using '{commandLabel}': {errorOutput}"
)
return [line for line in completed.stdout.splitlines() if line.strip()]
@ffx.command(name='configure_workstation')
@click.pass_context
@click.option('--check', is_flag=True, default=False, help='Only verify workstation-configuration readiness')
@@ -152,6 +170,24 @@ def upgrade(ctx, branch):
raise click.ClickException(f"Bundle pip not found at {bundlePipPath}")
commandSequences = []
trackedChanges = getTrackedGitChanges(bundleRepoPath)
if trackedChanges:
click.echo("Tracked local changes detected in the bundle repository:")
for trackedChange in trackedChanges:
click.echo(f" {trackedChange}")
shouldReset = click.confirm(
"Discard these tracked changes with 'git reset --hard HEAD' before upgrade?",
default=False,
)
if not shouldReset:
raise click.ClickException(
"Upgrade aborted because tracked local changes are present."
)
commandSequences.append(['git', 'reset', '--hard', 'HEAD'])
if branch:
commandSequences.append(['git', 'checkout', branch])