sshaw / git-link

Emacs package to get the GitHub/Bitbucket/GitLab/... URL for a buffer location
399 stars 74 forks source link

Add support for googlesource.com #105

Closed modulitos closed 1 year ago

modulitos commented 1 year ago

Resolves: https://github.com/sshaw/git-link/issues/100 (Update: this doesn't actually provide support for gitiles, and is limited to googelsource)

Also adds support for the repos hosted by googlesource.com, which I believe are all using gitiles. Such as https://android.googlesource.com/ and https://go.googlesource.com/go I checked several projects under https://opensource.google/projects, and I believe all repos under the googlesource.com domain are using gitiles.

Testing

I added a test to git-link-test.el to ensure the behavior of git-link--parse-remote-test was correct.

For the rest of the behavior, I ran the following tests manually, since I didn't see any existing automated tests (although it seems like the project can use some unit tests here):

git-link

I tested this by running git-link in several gitiles repos. The following value is copies to my clipboard:

  1. with git-link-use-commit set to t: https://go.googlesource.com/go/+/38cfb3be9d486833456276777155980d1ec0823e/src/go/token/token.go#162
  2. with git-link-use-commit set to nil (the default vaue): https://go.googlesource.com/go/+/master/src/go/token/token.go#162

git-link-commit

I tested this by running git-link-commit over some code like // 38cfb3be9d486833456276777155980d1ec0823e and got this: https://go.googlesource.com/go/+/38cfb3be9d486833456276777155980d1ec0823e

git-link-homepage

Running git-link-homepage copies this to my clipboard: https://go.googlesource.com/go

sshaw commented 1 year ago

Hi @modulitos, thanks so much for your contribution and detailed explanation. Give me a week or so and I will review. Please follow-up if you don't hear back from me!

modulitos commented 1 year ago

@sshaw Thank you for the review! I made some updates, per your feedback. I think you're right, that this is limited to only googlesource.com repos :)

sshaw commented 1 year ago

Great thanks. Can you just squash into single commit?

modulitos commented 1 year ago

@sshaw Done :+1: