Gitiles links do not work because they use wrong relative paths
Reported by email@example.com, Jan 22 2017
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.
Jan 23 2017,
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.
Jan 23 2017,
Sorry, disregard my previous comments. I missed that this was for Polygerrit, and I was testing the GWT version...
Jan 23 2017,
The attached picture shows what gets turned into a link on googlesource, but not on my instance of Polygerrit.
Jan 23 2017,
Jun 21 2017,
Any update on this? I would assume it's a small change but is extremely frustrating to not have the browse link work.
Jun 21 2017,
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?
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/
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.
Is this still not working?
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
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?
Issue 8656 has been merged into this issue.
@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  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. : https://gerrit.googlesource.com/plugins/gitiles/+/HEAD/src/main/resources/+Documentation/config.md#file
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?
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.
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
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.
Repoening as per report.
Sign in to add a comment