sshaw / git-link

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

Feature request: support for Gitiles #100

Closed peterbecich closed 1 year ago

peterbecich commented 2 years ago

Request for a function git-link-gitiles

Gitiles - A simple JGit repository browser Gitiles is a simple repository browser for Git repositories, built on JGit. Its guiding principle is simplicity: it has no formal access controls, no write access, no fancy Javascript, etc.

https://gerrit.googlesource.com/gitiles/

Example file in Gitiles: https://gerrit.googlesource.com/gitiles/+/refs/heads/master/java/com/google/gitiles/DateFormatter.java

sshaw commented 2 years ago

Hi, thanks for the suggestion.

Does the Google example represent the path that one would get with a default JGit installation?

Also, if you can provide the following link structures for the follwing it would be helpful to explore adding this:

  1. a commit
  2. a file with a line number
  3. a file with a line number range (if supported)
  4. a Markdown or similar file with a line number, i.e., an unrendered version of the Markdown file. GitHub uses plain=1 for this.
peterbecich commented 2 years ago

Thanks for the quick response

Does the Google example represent the path that one would get with a default JGit installation?

~I don't have any other examples of Gitile repositories outside of https://gerrit.googlesource.com/~ I don't think so, I have found another example with a different address scheme: https://github.com/sshaw/git-link/issues/100#issuecomment-1153092849 I don't know which, if either, is default.

I will guess that ~all~ some Gitile repositories take this form:

[Git http remote address]/+/[Git commit hash]/[file#line number]

For example repository https://gerrit.googlesource.com/bazlets/ with remote:

% git remote -v
origin  https://gerrit.googlesource.com/bazlets (fetch)
origin  https://gerrit.googlesource.com/bazlets (push)
  1. An example commit: https://gerrit.googlesource.com/bazlets/+/efb3ad71f38e515eb1805ff457a077264b9f3dcc
  2. A file with a line number: https://gerrit.googlesource.com/bazlets/+/efb3ad71f38e515eb1805ff457a077264b9f3dcc/lib/prolog/java/PrologCompiler.java#46
  3. It appears a line number range is unsupported
  4. It appears Markdown rendering can only be configured server-side: https://gerrit.googlesource.com/gitiles/+/HEAD/Documentation/config.md#disabling-markdown There is no URL parameter I can find which disables it. Example markdown https://gerrit.googlesource.com/bazlets/+/efb3ad71f38e515eb1805ff457a077264b9f3dcc/README.md
peterbecich commented 2 years ago

Here is another collection of Gitile repositories: https://git.eclipse.org/r/plugins/gitiles/?format=HTML

One repository: https://git.eclipse.org/r/plugins/gitiles/www.eclipse.org/eef/

git clone ssh://git.eclipse.org:29418/www.eclipse.org/eef

It cannot be cloned due to an SSH access restriction.

One file in that repository: https://git.eclipse.org/r/plugins/gitiles/www.eclipse.org/eef/+/e9cbc436ca18671c1a5a6ae1fd40a9489259b08d/javadoc/2.1.1/org/eclipse/eef/provider/EEFRuleAuditDescriptionItemProvider.html

So I understand this could be complicated, because the address implied by the Git remote is:

https://git.eclipse.org/www.eclipse.org/eef/+/[commit]/[file name....]

but the actual address is

https://git.eclipse.org/r/plugins/gitiles/www.eclipse.org/eef/+/[commit]/[file name....]
sshaw commented 2 years ago

Hi, thanks for all the information.

Given this, it seems that there is not standard config that one can use rather, they'd have to do a custom config based on their JGit-based service's defaults. Right?

Maybe an argument could be made to add something for gerrit.googlesource.com but then wouldn't that be Gerrit support? For that there was #81.

modulitos commented 1 year ago

(Update: Looks like my change is limited to only googlesource.com repos. I missed the fact that Gitiles repos can customize their URLs :facepalm: Sorry for the confusion!)

@sshaw @peterbecich Thanks for the investigation here! I believe I have implemented support for gitiles in my PR: https://github.com/sshaw/git-link/pull/105

I used googlesource.com as an example (detailed in the PR), which hosts gitiles repos as well.

Unfortunately I was unable to test on the Eclipse repo above, because running git clone ssh://git.eclipse.org:29418/www.eclipse.org/eef fails with a <$USER>@git.eclipse.org: Permission denied (publickey). error.:

❯ git clone ssh://git.eclipse.org:29418/www.eclipse.org/eef eclipse-test
Cloning into 'eclipse-test'...
lucas@git.eclipse.org: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

(note that I don't have a lucas@git.eclipse.org account)

It seems like the repository for https://git.eclipse.org/r/plugins/gitiles/www.eclipse.org/eef/ has been moved to Github (see screenshot below), which might explain why that gitiles repo is no longer publicly available.

screenshot_1672205536