New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 12 users

Issue metadata

Status: New
Owner:
Cc:
Components:
ReleasedIn: 522.0



Sign in to add a comment

Gitiles links do not work because they use wrong relative paths

Reported by jkt@flaska.net, Jan 22 2017

Issue description

Affected Version:

- Gerrit 640381f50ddfe5c2c73e36d4fafae731678f0202 with Ic2df0f270c178e7a93dde5d0460dd24f10edf321 and I8b674550e34b0c6fed4cc0af2f069aaeadbae6cc applied

- Gitiles 7239ac50bfe6ceda5fa82a37b57ed9b7a6aa7139

When I'm on https://gerrit.cesnet.cz/c/5/ , there's a "Links" field with a "browse" text which points to gitiles, but the produced URL is https://gerrit.cesnet.cz/c/5/plugins/gitiles/dummy/+/c51c13c3a2625349018521f051e652ef04d7eac0 . That doesn't work, the "/c/5" should not be there.

In addition, the patchset view shows a short hash of the commit which was merged, but it is not clickable. That thing is clickable on gerrit-review.googlesource.com.
 
Status: AwaitingInformation (was: New)
When I go to https://gerrit.cesnet.cz/c/5/ the "browse" link is:

   https://gerrit.cesnet.cz/plugins/gitiles/dummy/+/c51c13c3a2625349018521f051e652ef04d7eac0

> the patchset view shows a short hash of the commit which was merged, but it is not clickable

Can you elaborate where this is?  A screenshot would help.
Status: New (was: AwaitingInformation)
Sorry, disregard my previous comments.  I missed that this was for Polygerrit, and I was testing the GWT version...

Comment 3 by jkt@flaska.net, Jan 23 2017

The attached picture shows what gets turned into a link on googlesource, but not on my instance of Polygerrit.
gerrit-5316-sshot.png
48.8 KB View Download
Project Member

Comment 4 by andyb...@chromium.org, Jan 23 2017

Status: Accepted (was: New)
I'm running into this with 2.14-rc0. The "browse" anchor's source is "plugins/gitiles/ansible-repo/+/27e78b687c8dc17e01fe35c4cdd1e153ea942b23" which, when clicked, opens "/c/5/plugins/gitiles/ansible-repo/+/27e78b687c8dc17e01fe35c4cdd1e153ea942b23" which is not correct.
Any update on this? I would assume it's a small change but is extremely frustrating to not have the browse link work.
Project Member

Comment 7 by wyatta@google.com, Jun 21 2017

Status: AwaitingInformation (was: Accepted)
Is the browse link setup using a weblinks section of that server's Gerrit config file? If so, is it possible that the URL pattern in the "browse" link config needs a slash prepended to it?

Comment 8 by drifk...@gmail.com, Aug 1 2017

I believe there is a fix for this issue that needs review at https://gerrit-review.googlesource.com/#/c/plugins/gitiles/+/104783/

Comment 9 by jkt@flaska.net, Sep 23 2017

It seems that there are two issues that are getting mixed in this report. The first one of them is that the Gitiles plugin currently only produces relative URLs which do not work. That's being addressed by https://gerrit-review.googlesource.com/c/plugins/gitiles/+/104783 .

There is also other problem which is illustrated by Comment 3. On a Polygerrit change screen, the commit SHA in between the patchset selection and the Download link is not clickable. Given that it *is* clickable on gerrit-review.googlesource.com, it is probably due to some misconfiguration on my side. I'm running with no config for the gitiles plugin, and my server's error log says that the plugin is using its defaults. The documentation says that noWebLinks defaults to false.

> Is the browse link setup using a weblinks section of that server's Gerrit config file? If so, is it possible that the URL pattern in the "browse" link config needs a slash prepended to it?

I am a bit lost here -- the documentation does not contain anything about "weblinks" as far as I can tell. Do I have to enable something to get a clickable link here? This is not about a "commentlink", is it? I also do not have any configuration related to "gitweb" in case that might matter.
Project Member

Comment 10 by kaspern@google.com, Apr 20

Is this still not working?
Project Member

Comment 11 by gertvdijk@gmail.com, Jun 4

Yes this is still an issue, also on master.

I wanted to point out that the 'browse' link on the file pages are OK, but just wrong on the change page.

So, with Gerrit running under the webroot /, the link generated on a change page for project 'mycategory/myrepo' (e.g. /c/mycategory/myrepo/+/1234) is (wrongfully):

hxxps://gerrit.mydomain.tld/c/mycategory//plugins/gitiles/mycategory/myrepo/+/<hash>

That makes 'c/mycategory//' superfluous in this URL (and yes this is somehow 'missing' the 'myrepo' part).

When viewing the file diff on a page, the link to the file in Gitiles is generated OK:

hxxps://gerrit.mydomain.tld/plugins/gitiles/mycategory/myrepo/+/refs/changes/34/1234/1/path/to/file

Versions used:
gerrit 2.15.2-3879-g436b57ea85 from gerrit-ci
gitiles fd51b3f2b9 from gerrit-ci as well
Project Member

Comment 12 by logan@google.com, Jun 6

If you configure an absolute URL for gitweb.url (see https://gerrit-review.googlesource.com/Documentation/config-gerrit.html#gitweb.url), does that resolve this problem?
Project Member

Comment 13 by logan@google.com, Jun 6

 Issue 8656  has been merged into this issue.
Project Member

Comment 14 by gertvdijk@gmail.com, Jun 6

@logan:
I should note that I haven't installed gitweb in my installation. Are you intentionally pointing to a *gitweb* and not *gitiles* setting - and don't you mean the gitiles.config gerrit.baseUrl setting [1] instead?

With gerrit.config gitweb.url set, nothing changes for Gitiles in my installation. (Same versions used as previous comment.)

I've tried adjusting the gitiles.config gerrit.baseUrl setting and restarted Gerrit, but this only has effect on the change page 'browse' URL generated, *not* on those when viewing a file. Sounds like a(n) (un)related bug?

However, I tried to outsmart the current behaviour here to make it working for my situation by setting the base path to the default but absolute /plugins/gitiles path:

gitiles.config:
[gerrit]
    baseUrl = https://gerrit.mydomain.tld/plugins/gitiles

And now my browse links work everywhere, but this is clearly not how it should be and I still consider this a bug.

Hope this helps.

[1]: https://gerrit.googlesource.com/plugins/gitiles/+/HEAD/src/main/resources/+Documentation/config.md#file
Project Member

Comment 15 by logan@google.com, Jun 6

Labels: Triaged-Yes Hotlist-Linkification Hotlist-GWT Priority-2
Owner: wyatta@google.com
Status: Accepted (was: AwaitingInformation)
My thoughts went to gitweb config because some source browsing plugins use it, but I see now that gitiles has its own config. In any case, I'm glad you found/confirmed a workaround.

What we could do to fix this on PolyGerrit's end is detect when we're given a relative URL for any gitweb or gitiles link, and do the right thing with it to produce an absolute URL. Unfortunately I think this logic is scattered across a number of different components, dealing with a number of different kinds of links.
I have the same issue in Gerrit 2.15.2 but using GitBlit instead of Gitiles. The Links field in the change points to:

https://SERVER/c/REPO/+/plugins/gitblit/commit/?r=REPOd&h=COMMIT

Instead of:

https://SERVER/plugins/gitblit/commit/?r=REPOd&h=COMMIT

I have gitweb.url = https://SERVER/plugins/gitblit/ set in the GERRIT_SITE/etc/gerrit.config file.
The workaround to explicitly set the url worked for me.
I also had to flush the cahces. Ie: ssh -p <port> <host> gerrit flush-caches --all
@john.vik...@effnet.com, Are you saying that you set the absolute url, flush the caches and the links field in the change, using PolyGerrit, doesn't add "c/REPO/+" in the link anymore? Is it GitBlit or Gitiles? Which is the Gerrit version?
@marceloa...@gmail.com yes that is correct, I added url = http://xyz/gitweb to the [gitweb] section in the configuration and flushed the cache. The flush was necessary since the old page with the incorrect /c/ url was cached after I changed the configuration.
I'm using gitweb on gerrit 2.15.2.
Sorry everyone, I think it was my browser cache :-( The workaround (set the absolute URL using gitweb.url = https://SERVER/plugins/gitblit/ at GERRIT_SITE/etc/gerrit.config file worked pretty well in every "GitBlit" links.
Project Member

Comment 21 by sven.sel...@axis.com, Jun 28

One issue is that PolyGerrit does not trust the WebLink provider to provide a correct relative URL and tries to second-guess how the WebLink url should be presented.

https://gerrit-review.googlesource.com/c/gerrit/+/186875
Project Member

Comment 22 by wyatta@google.com, Jul 3

ReleasedIn: 522.0
Project Member

Comment 23 by wyatta@google.com, Jul 9

Status: Released (was: Accepted)
Labels: FixedIn-2.15.3
Project Member

Comment 25 by gertvdijk@gmail.com, Jul 19

Is this really fixed? It's appears not for me at least. I just tested it on master and the behavior is the same as before.

* Verified that https://gerrit-review.googlesource.com/c/gerrit/+/186875 is included in master now.
* Upgraded to master/2.15.3-4415-ga24fb63 from gerrit-ci.
* Using gitiles plugin version be8c047 from gerrit-ci.
* Undone my workaround in gitiles.config / gerrit.baseUrl setting.

Generates wrong URLs on 'browse' links, exactly the same as I mentioned in comment 11.

Restoring the workaround in gitiles.config with the new versions generates the right URLs again.
Project Member

Comment 26 by kaspern@google.com, Jul 20

Labels: -Triaged-Yes Triaged-No
Status: New (was: Released)
Repoening as per report.
Project Member

Comment 27 by wyatta@google.com, Aug 3

Labels: -Triaged-No Triaged-Undecided

Sign in to add a comment