Impr upgrade
This commit is contained in:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user