Skip to content

Conversation

@mohammedahmed18
Copy link
Contributor

@mohammedahmed18 mohammedahmed18 commented Aug 8, 2025

PR Type

Bug fix


Description

  • should_modify_pyproject_toml returns config tuple

  • init_codeflash extracts git_remote from config or setup_info

  • install_github_app signature updated with git_remote

  • include git_remote in get_repo_owner_and_name call


Diagram Walkthrough

flowchart LR
  A["should_modify_pyproject_toml()"] -->|"(should_modify, config)"| B["init_codeflash"]
  B -->| "sets git_remote" | C["install_github_app(git_remote)"]
  C -->| "calls get_repo_owner_and_name with git_remote" | D["get_repo_owner_and_name()"]
Loading

File Walkthrough

Relevant files
Bug fix
cmd_init.py
Support custom git remotes in installation                             

codeflash/cli_cmds/cmd_init.py

  • Change should_modify_pyproject_toml to return config tuple
  • Extract git_remote from config or setup_info in init
  • Update install_github_app signature to accept git_remote
  • Pass git_remote to get_repo_owner_and_name
+18/-12 

@github-actions
Copy link

github-actions bot commented Aug 8, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Uninitialized variable

The variable setup_info is used outside the if should_modify block and may be undefined when should_modify is False.

if should_modify:
    setup_info: SetupInfo = collect_setup_info()
    git_remote = setup_info.git_remote
    configure_pyproject_toml(setup_info)
Default git_remote behavior

Defaulting git_remote to "origin" may not reflect users' custom remote names; consider validating available remotes or informing the user if the default is absent.

git_remote = config.get("git_remote", "origin") if config else "origin"

@github-actions
Copy link

github-actions bot commented Aug 8, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Validate and handle git remote

Before invoking get_repo_owner_and_name, verify that git_remote exists in the
repository remotes and wrap the call in a try/except to raise a clear ClickException
on failure, preventing unhandled errors if the remote is missing or malformed.

codeflash/cli_cmds/cmd_init.py [971]

-owner, repo = get_repo_owner_and_name(git_repo, git_remote)
+if git_remote not in [r.name for r in git_repo.remotes]:
+    raise click.ClickException(f"Git remote '{git_remote}' does not exist in this repository.")
+try:
+    owner, repo = get_repo_owner_and_name(git_repo, git_remote)
+except Exception as e:
+    raise click.ClickException(f"Failed to resolve remote '{git_remote}': {e}")
Suggestion importance[1-10]: 6

__

Why: Adding checks for the existence of git_remote and wrapping the lookup in a try/except prevents unhandled errors and improves UX by providing clear failure messages.

Low

@mohammedahmed18 mohammedahmed18 merged commit 681fa17 into main Aug 8, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants