Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Brookke
Copy link
Contributor

@Brookke Brookke commented Sep 29, 2025

This handles cases where the git editor is set to $EDITOR. The steps for reproducing are as follows.

  1. Set the EDITOR env var
  2. Update your .gitconfig to include editor=$EDITOR
  3. Run av pr --edit

According to man 1 git-var, GIT_EDITOR is "meant to be interpreted by the shell when it is used". Hence, this variable needs to be interpreted.

Credit to @tgandrews for spotting the issue

@Brookke Brookke requested a review from a team as a code owner September 29, 2025 09:09
@aviator-app
Copy link
Contributor

aviator-app bot commented Sep 29, 2025

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged using Aviator.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

@aviator-app
Copy link
Contributor

aviator-app bot commented Sep 29, 2025

✅ FlexReview Status

Common Owner: aviator-co/engineering (expert-load-balance assignment)
Owner and Assignment:

  • aviator-co/engineering (expert-load-balance assignment)
    Owned Files
    • internal/editor/editor.go
    CODEOWNERS Required Files
    • internal/editor/editor.go

Review SLO: 7 business hours if PR size is <= 200 LOC for the first response.

@aviator-app aviator-app bot requested a review from draftcode September 29, 2025 09:09
@gemini-code-assist
Copy link

Summary of Changes

Hello @Brookke, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where environment variables embedded within the editor command string were not being expanded, leading to incorrect editor invocation. By integrating os.ExpandEnv, the system can now correctly interpret and execute editor configurations that rely on dynamic environment variable values, enhancing the flexibility and robustness of editor command resolution.

Highlights

  • Environment Variable Expansion: The pull request introduces a fix to correctly expand environment variables within the configured editor command string.
  • Editor Command Resolution: This change specifically addresses scenarios where the editor command itself might contain references to other environment variables, such as GIT_EDITOR="$EDITOR", ensuring they are properly resolved.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to add support for environment variable expansion in the Git editor command, for cases like GIT_EDITOR="$EDITOR". However, the current implementation using os.ExpandEnv is not safe as it doesn't respect shell quoting rules, which can lead to incorrect behavior and potential security vulnerabilities. I've left a comment with a detailed explanation and a suggestion for a more robust implementation that involves executing the command through a shell, which is how Git itself handles it.

@Brookke
Copy link
Contributor Author

Brookke commented Sep 29, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly changes the editor launching logic to use a shell, which enables support for environment variable expansion in the editor command (e.g., GIT_EDITOR="$EDITOR"). This also implicitly fixes a bug where filenames with spaces were not handled correctly. The approach is sound, but I have one suggestion to improve portability.

@draftcode
Copy link
Contributor

Can you explain what you want to solve? If the shell has GIT_EDITOR="$EDITOR" as an env var, that expansion would have done inside that shell level before calling av, so av will see the expanded GIT_EDITOR env var I suppose?

@Brookke
Copy link
Contributor Author

Brookke commented Sep 30, 2025

Can you explain what you want to solve? If the shell has GIT_EDITOR="$EDITOR" as an env var, that expansion would have done inside that shell level before calling av, so av will see the expanded GIT_EDITOR env var I suppose?

@draftcode

This happens when the editor is read from the .gitconfig, I mistakenly thought it would also happen for GIT_EDITOR.

So the steps for reproducing were as follows.

  1. Set the EDITOR env var
  2. Update your .gitconfig to include editor=$EDITOR
  3. Run av pr --edit
❯ av pr --edit
Updating pull request for branch test-branch:
  - pushing to origin/test-branch
  - saved pull request description to <omitted> (it will be automatically re-used if you try again)
error: text editor failed: command "$EDITOR" failed: exec: "$EDITOR": executable file not found in $PATH

I'll also update the PR description

@draftcode
Copy link
Contributor

Can you explain what you want to solve? If the shell has GIT_EDITOR="$EDITOR" as an env var, that expansion would have done inside that shell level before calling av, so av will see the expanded GIT_EDITOR env var I suppose?

@draftcode

This happens when the editor is read from the .gitconfig, I mistakenly thought it would also happen for GIT_EDITOR.

So the steps for reproducing were as follows.

  1. Set the EDITOR env var
  2. Update your .gitconfig to include editor=$EDITOR
  3. Run av pr --edit
❯ av pr --edit
Updating pull request for branch test-branch:
  - pushing to origin/test-branch
  - saved pull request description to <omitted> (it will be automatically re-used if you try again)
error: text editor failed: command "$EDITOR" failed: exec: "$EDITOR": executable file not found in $PATH

I'll also update the PR description

Thanks. I added a reference as well to the PR description.

@aviator-app aviator-app bot merged commit 96a1052 into aviator-co:master Oct 1, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants