@@ -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
@@ -372,6 +379,19 @@ def install_github_actions() -> None:
372379 workflows_path = git_root / ".github" / "workflows"
373380 optimize_yaml_path = workflows_path / "codeflash.yaml"
374381
382+ # Check if the workflow file already exists
383+ if optimize_yaml_path .exists ():
384+ confirm_overwrite = inquirer_wrapper (
385+ inquirer .confirm ,
386+ message = f"⚡️ GitHub Actions workflow already exists at { optimize_yaml_path } . Overwrite?" ,
387+ default = False , # Don't overwrite by default
388+ )
389+ ph ("cli-github-optimization-confirm-workflow-overwrite" , {"confirm_overwrite" : confirm_overwrite })
390+ if not confirm_overwrite :
391+ click .echo ("⏩️ Skipping workflow creation." )
392+ ph ("cli-github-workflow-skipped" )
393+ return
394+
375395 confirm_creation_yes = inquirer_wrapper (
376396 inquirer .confirm ,
377397 message = "⚡️Shall I set up a GitHub action that will continuously optimize all new code in GitHub PRs"
@@ -574,6 +594,11 @@ def configure_pyproject_toml(setup_info: SetupInfo) -> None:
574594 )
575595 elif formatter == "don't use a formatter" :
576596 formatter_cmds .append ("disabled" )
597+ if formatter in ["black" , "ruff" ]:
598+ try :
599+ result = subprocess .run ([formatter ], capture_output = True , check = False )
600+ except FileNotFoundError as e :
601+ click .echo (f"⚠️ Formatter not found: { formatter } , please ensure it is installed" )
577602 codeflash_section ["formatter-cmds" ] = formatter_cmds
578603 # Add the 'codeflash' section, ensuring 'tool' section exists
579604 tool_section = pyproject_data .get ("tool" , tomlkit .table ())
0 commit comments