Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix repository root detection #232

Merged
merged 2 commits into from
Mar 26, 2024
Merged

fix: fix repository root detection #232

merged 2 commits into from
Mar 26, 2024

Conversation

linrongbin16
Copy link
Owner

@linrongbin16 linrongbin16 commented Mar 26, 2024

Fix #231 .

Regression Test

Platforms

  • windows
  • macOS
  • linux

Hosts

Functions

  • Use GitLink(!) to copy git link (or open in browser).
  • Use GitLink(!) blame to copy the /blame link (or open in browser).
  • Use GitLink(!) default_branch to open the /main//master link in browser (or open in browser).
  • Use GitLink(!) current_branch to open the current branch link in browser (or open in browser).
  • Copy git link in a symlink directory of git repo.
  • Copy git link in an un-pushed git branch, and receive an expected error.
  • Copy git link in a pushed git branch but edited file, and receive a warning says the git link could be wrong.

@linrongbin16
Copy link
Owner Author

linrongbin16 commented Mar 26, 2024

At last, this issue is fixed by adding the cwd options when calling all the git commands, this is the most correct solution.

The cwd is using the directory of current buffer/file that user is editing, if there's no buffer/file, it fallbacks to the real CWD/PWD that user's Neovim is working at.

Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 75.55556% with 11 lines in your changes are missing coverage. Please review.

Project coverage is 76.54%. Comparing base (69bafe6) to head (155a3c2).

Files Patch % Lines
lua/gitlinker/git.lua 73.91% 6 Missing ⚠️
lua/gitlinker/linker.lua 77.27% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #232      +/-   ##
==========================================
+ Coverage   73.61%   76.54%   +2.92%     
==========================================
  Files           9        9              
  Lines         815      827      +12     
==========================================
+ Hits          600      633      +33     
+ Misses        215      194      -21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@linrongbin16 linrongbin16 merged commit 47d163f into master Mar 26, 2024
9 checks passed
@linrongbin16 linrongbin16 deleted the fix-git-root branch March 26, 2024 01:34
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.

Feat Request: include basename of current file when running git commnads
1 participant