Skip to content

Commit 3531e0a

Browse files
author
Codeflash Bot
committed
don't panic on keyboard interrupt if the user doesn't want to install the github app
1 parent 459b5cc commit 3531e0a

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

codeflash/cli_cmds/cmd_init.py

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,43 +1085,47 @@ def install_github_app(git_remote: str) -> None:
10851085
)
10861086

10871087
else:
1088-
click.prompt(
1089-
f"Finally, you'll need to install the Codeflash GitHub app by choosing the repository you want to install Codeflash on.{LF}"
1090-
f"I will attempt to open the github app page - https://github.com/apps/codeflash-ai/installations/select_target {LF}"
1091-
f"Press Enter to open the page to let you install the app…{LF}",
1092-
default="",
1093-
type=click.STRING,
1094-
prompt_suffix="",
1095-
show_default=False,
1096-
)
1097-
click.launch("https://github.com/apps/codeflash-ai/installations/select_target")
1098-
click.prompt(
1099-
f"Press Enter once you've finished installing the github app from https://github.com/apps/codeflash-ai/installations/select_target{LF}",
1100-
default="",
1101-
type=click.STRING,
1102-
prompt_suffix="",
1103-
show_default=False,
1104-
)
1105-
1106-
count = 2
1107-
while not is_github_app_installed_on_repo(owner, repo, suppress_errors=True):
1108-
if count == 0:
1109-
click.echo(
1110-
f"❌ It looks like the Codeflash GitHub App is not installed on the repository {owner}/{repo}.{LF}"
1111-
f"You won't be able to create PRs with Codeflash until you install the app.{LF}"
1112-
f"In the meantime you can make local only optimizations by using the '--no-pr' flag with codeflash.{LF}"
1113-
)
1114-
break
1088+
try:
11151089
click.prompt(
1116-
f"❌ It looks like the Codeflash GitHub App is not installed on the repository {owner}/{repo}.{LF}"
1117-
f"Please install it from https://github.com/apps/codeflash-ai/installations/select_target {LF}"
1118-
f"Press Enter to continue once you've finished installing the github app…{LF}",
1090+
f"Finally, you'll need to install the Codeflash GitHub app by choosing the repository you want to install Codeflash on.{LF}"
1091+
f"I will attempt to open the github app page - https://github.com/apps/codeflash-ai/installations/select_target {LF}"
1092+
f"Press Enter to open the page to let you install the app…{LF}",
11191093
default="",
11201094
type=click.STRING,
11211095
prompt_suffix="",
11221096
show_default=False,
11231097
)
1124-
count -= 1
1098+
click.launch("https://github.com/apps/codeflash-ai/installations/select_target")
1099+
click.prompt(
1100+
f"Press Enter once you've finished installing the github app from https://github.com/apps/codeflash-ai/installations/select_target{LF}",
1101+
default="",
1102+
type=click.STRING,
1103+
prompt_suffix="",
1104+
show_default=False,
1105+
)
1106+
1107+
count = 2
1108+
while not is_github_app_installed_on_repo(owner, repo, suppress_errors=True):
1109+
if count == 0:
1110+
click.echo(
1111+
f"❌ It looks like the Codeflash GitHub App is not installed on the repository {owner}/{repo}.{LF}"
1112+
f"You won't be able to create PRs with Codeflash until you install the app.{LF}"
1113+
f"In the meantime you can make local only optimizations by using the '--no-pr' flag with codeflash.{LF}"
1114+
)
1115+
break
1116+
click.prompt(
1117+
f"❌ It looks like the Codeflash GitHub App is not installed on the repository {owner}/{repo}.{LF}"
1118+
f"Please install it from https://github.com/apps/codeflash-ai/installations/select_target {LF}"
1119+
f"Press Enter to continue once you've finished installing the github app…{LF}",
1120+
default="",
1121+
type=click.STRING,
1122+
prompt_suffix="",
1123+
show_default=False,
1124+
)
1125+
count -= 1
1126+
except (KeyboardInterrupt, EOFError, click.exceptions.Abort):
1127+
# leave empty line for the next prompt to be properly rendered
1128+
click.echo()
11251129

11261130

11271131
class CFAPIKeyType(click.ParamType):

0 commit comments

Comments
 (0)