@@ -85,12 +85,16 @@ def init_codeflash() -> None:
85
85
86
86
did_add_new_key = prompt_api_key ()
87
87
88
- if should_modify_pyproject_toml ():
89
- setup_info : SetupInfo = collect_setup_info ()
88
+ should_modify , config = should_modify_pyproject_toml ()
89
+
90
+ git_remote = config .get ("git_remote" , "origin" ) if config else "origin"
90
91
92
+ if should_modify :
93
+ setup_info : SetupInfo = collect_setup_info ()
94
+ git_remote = setup_info .git_remote
91
95
configure_pyproject_toml (setup_info )
92
96
93
- install_github_app ()
97
+ install_github_app (git_remote )
94
98
95
99
install_github_actions (override_formatter_check = True )
96
100
@@ -151,7 +155,7 @@ def ask_run_end_to_end_test(args: Namespace) -> None:
151
155
run_end_to_end_test (args , bubble_sort_path , bubble_sort_test_path )
152
156
153
157
154
- def should_modify_pyproject_toml () -> bool :
158
+ def should_modify_pyproject_toml () -> tuple [ bool , dict [ str , Any ] | None ] :
155
159
"""Check if the current directory contains a valid pyproject.toml file with codeflash config.
156
160
157
161
If it does, ask the user if they want to re-configure it.
@@ -160,22 +164,22 @@ def should_modify_pyproject_toml() -> bool:
160
164
161
165
pyproject_toml_path = Path .cwd () / "pyproject.toml"
162
166
if not pyproject_toml_path .exists ():
163
- return True
167
+ return True , None
164
168
try :
165
169
config , config_file_path = parse_config_file (pyproject_toml_path )
166
170
except Exception :
167
- return True
171
+ return True , None
168
172
169
173
if "module_root" not in config or config ["module_root" ] is None or not Path (config ["module_root" ]).is_dir ():
170
- return True
174
+ return True , None
171
175
if "tests_root" not in config or config ["tests_root" ] is None or not Path (config ["tests_root" ]).is_dir ():
172
- return True
176
+ return True , None
173
177
174
178
return Confirm .ask (
175
179
"✅ A valid Codeflash config already exists in this project. Do you want to re-configure it?" ,
176
180
default = False ,
177
181
show_default = True ,
178
- )
182
+ ), config
179
183
180
184
181
185
# Custom theme for better UX
@@ -958,16 +962,18 @@ def configure_pyproject_toml(setup_info: SetupInfo) -> None:
958
962
click .echo ()
959
963
960
964
961
- def install_github_app () -> None :
965
+ def install_github_app (git_remote : str ) -> None :
962
966
try :
963
967
git_repo = git .Repo (search_parent_directories = True )
964
968
except git .InvalidGitRepositoryError :
965
969
click .echo ("Skipping GitHub app installation because you're not in a git repository." )
966
970
return
967
- owner , repo = get_repo_owner_and_name (git_repo )
971
+ owner , repo = get_repo_owner_and_name (git_repo , git_remote )
968
972
969
973
if is_github_app_installed_on_repo (owner , repo , suppress_errors = True ):
970
- click .echo ("🐙 Looks like you've already installed the Codeflash GitHub app on this repository! Continuing…" )
974
+ click .echo (
975
+ f"🐙 Looks like you've already installed the Codeflash GitHub app on this repository ({ owner } /{ repo } )! Continuing…"
976
+ )
971
977
972
978
else :
973
979
click .prompt (
0 commit comments