Skip to content

Commit c93a7ca

Browse files
authored
Merge pull request #20 from codeflash-ai/fix/issue_19
codeflash error handle when remote is empty
2 parents 474d385 + de6b7aa commit c93a7ca

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

codeflash/cli_cmds/cmd_init.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,26 @@ def collect_setup_info() -> SetupInfo:
220220
carousel=True,
221221
)
222222

223+
git_remote = ""
223224
try:
224225
repo = Repo(str(module_root), search_parent_directories=True)
225226
git_remotes = get_git_remotes(repo)
226-
if len(git_remotes) > 1:
227-
git_remote = inquirer_wrapper(
228-
inquirer.list_input,
229-
message="What git remote do you want Codeflash to use for new Pull Requests? ",
230-
choices=git_remotes,
231-
default="origin",
232-
carousel=True,
233-
)
227+
if git_remotes: # Only proceed if there are remotes
228+
if len(git_remotes) > 1:
229+
git_remote = inquirer_wrapper(
230+
inquirer.list_input,
231+
message="What git remote do you want Codeflash to use for new Pull Requests? ",
232+
choices=git_remotes,
233+
default="origin",
234+
carousel=True,
235+
)
236+
else:
237+
git_remote = git_remotes[0]
234238
else:
235-
git_remote = git_remotes[0]
239+
click.echo(
240+
"No git remotes found. You can still use Codeflash locally, but you'll need to set up a remote "
241+
"repository to use GitHub features."
242+
)
236243
except InvalidGitRepositoryError:
237244
git_remote = ""
238245

0 commit comments

Comments
 (0)