Closed edlandm closed 2 months ago
Open the branch in Web Editor • VS Code • Insiders
Open Preview
Latest commit: 67260565c69c053e7ad8ced615e2e4f1cd435783
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
Click here to learn what changesets are, and how to add one.
[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/edlandm/hurl.nvim/new/fix-find_env_files-git_worktree?filename=.changeset/good-balloons-sip.md&value=---%0A%22%40fake-scope%2Ffake-pkg%22%3A%20patch%0A---%0A%0Afix%3A%20git_utils.is_git_repo()%20-%20respect%20git%20command%20output%0A)
Your free trial has expired. To keep using Ellipsis, sign up at https://app.ellipsis.dev for $20/seat/month or reach us at help@ellipsis.dev
The recent update enhances the is_git_repo
function in git_utils.lua
to accurately determine if the current directory is a Git repository. This is achieved by capturing the result of a shell command and verifying it against the expected output, improving the reliability of the check.
File Path | Change Summary |
---|---|
lua/hurl/git_utils.lua |
Modified is_git_repo function to store the result of git rev-parse --is-inside-work-tree and return true only if the command succeeds and the result is 'true'. |
🐰✨ In a warren of code, where functions play,
is_git_repo
found a clearer way. With checks and balances, it now can say, "This is a Git repo, hip-hip-hooray!" 🌟🌿
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Hi @edlandm, Thank you for your work. I would prefer to expose find_env_files
as the config and let users override as they want. What do you think?
Hi @edlandm Now, you can set the find_env_files_in_folders
option. The good thing it was hardcode to follow folders.
local scan_dir = {
{
dir = '/src',
},
{
dir = '/test',
},
{
dir = '/tests',
},
{
dir = '/server',
},
{
dir = '/src/tests',
},
{
dir = '/server/tests',
},
}
Now, it's under your control :)
WHAT
git rev-parse --is-inside-work-tree
can be used to test if the command is being run from inside of git repository because it will fail if run from outside of a repository. However, it can also run successfully but output 'false' if run from within a directory inside of the repository that is not part of a worktree.This is most likely to happen if using a bare repository and the hurl file is kept in a location outside of a worktree. Previously, attempting to run such a hurl request threw an error in find_env_files for attempting to concatenate local 'git_root' (nil, in this case) and no further hurl requests could be run from neovim.
This commit allows find_env_files to continue as if not in a git repo.
WHY
I'm making this pull request because it fixes things for my workflow. Without it I get the error in the below screenshot.
Feel free to fix it a different way if you prefer, my fix was pretty quick just to get it working for me.
HOW
Screenshots (if appropriate):
Before Fix
After Fix
Types of changes
Checklist:
Summary by CodeRabbit