Skip to content

feat(blame): support /blame url#113

Merged
linrongbin16 merged 17 commits intomasterfrom
feat-host-mapping
Nov 15, 2023
Merged

feat(blame): support /blame url#113
linrongbin16 merged 17 commits intomasterfrom
feat-host-mapping

Conversation

@linrongbin16
Copy link
Owner

@linrongbin16 linrongbin16 commented Nov 15, 2023

Regression Test

Platforms

  • windows
  • macOS
  • linux

Tasks

  • Use <leader>gl to copy git link.
  • Use <leader>gL to open git link 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.

@github-actions github-actions bot added the feat label Nov 15, 2023
@linrongbin16
Copy link
Owner Author

linrongbin16 commented Nov 15, 2023

feat(bitbucket): support bitbucket.org via src router

@codecov
Copy link

codecov bot commented Nov 15, 2023

Codecov Report

Attention: 13 lines in your changes are missing coverage. Please review.

Comparison is base (2cac1b7) 81.46% compared to head (5536594) 79.86%.

❗ Current head 5536594 differs from pull request most recent head a371afb. Consider uploading reports for the commit a371afb to get more accurate results

Files Patch % Lines
lua/gitlinker.lua 38.88% 11 Missing ⚠️
lua/gitlinker/linker.lua 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #113      +/-   ##
==========================================
- Coverage   81.46%   79.86%   -1.61%     
==========================================
  Files          12       12              
  Lines         696      715      +19     
==========================================
+ Hits          567      571       +4     
- Misses        129      144      +15     

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

@linrongbin16 linrongbin16 merged commit 39acdb7 into master Nov 15, 2023
@linrongbin16 linrongbin16 deleted the feat-host-mapping branch November 15, 2023 10:36
- `require('gitlinker.routers').blob`: generate the `/blob` url, by default `link` API will use this router.
- `require('gitlinker.routers').blame` (todo): generate the `/blame` url.
- `require('gitlinker.routers').blame`: generate the `/blame` url.
- `require('gitlinker.routers').src`: generate the `/src` url (for [BitBucket.org](https://bitbucket.org/)).
Copy link

Choose a reason for hiding this comment

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

I think /src should not be considered as a separate router. We should have two main routers blob and blame.

In blob router we should decide the url keyword like blob, src or tree based on host pattern. Similar to vim-gh-line.vim

Same behaviour can be achieved for the blame router. Here we can decide the keyword blame or annotate as per host type.

I am suggesting this because current implementation will enforce user to created separate binding for each host type with different router config. In my opinion user should be creating the mapping based on action and router irrespective of the git host.

Copy link

Choose a reason for hiding this comment

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

Would recommend to rename the blob router to browse, that would make more sense if backward compatibility is not a concern.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Hi, @G0V1NDS, your point makes sense.

for now I am using the router_binding option to auto bind different routers to different host.

but just like you said, the blame is still need to be manually configured for different hosts.

I will refactor this part.

again thanks for your contribution!

Copy link
Owner Author

Choose a reason for hiding this comment

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

hi @G0V1NDS , I submit PR: #118, would you please help review?

Copy link

Choose a reason for hiding this comment

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

Sure, will check in few hours.

Copy link

Choose a reason for hiding this comment

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

Added comment on router_binding implementation, see if that makes sense.

Copy link

@guruor guruor left a comment

Choose a reason for hiding this comment

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

Added some enhancement pointers.

- `require('gitlinker.routers').blob`: generate the `/blob` url, by default `link` API will use this router.
- `require('gitlinker.routers').blame` (todo): generate the `/blame` url.
- `require('gitlinker.routers').blame`: generate the `/blame` url.
- `require('gitlinker.routers').src`: generate the `/src` url (for [BitBucket.org](https://bitbucket.org/)).
Copy link

Choose a reason for hiding this comment

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

Would recommend to rename the blob router to browse, that would make more sense if backward compatibility is not a concern.

router_binding = {
["^github"] = require("gitlinker.routers").blob,
["^gitlab"] = require("gitlinker.routers").blob,
["^bitbucket"] = require("gitlinker.routers").src,
Copy link

Choose a reason for hiding this comment

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

As an initial implementation this pattern match will work. Please consider the self hosted setup for gitlab and bitbucket where these patterns won't match. Consider this as a feature request, people might be interested in.

We can ask user to define the custom pattern for their host similar to this fubitive.vim

Copy link
Owner Author

Choose a reason for hiding this comment

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

hi @G0V1NDS , I submit PR: #118, would you please help review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants