Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Referencing repository files at a given commit in gitlab wiki

Tags:

gitlab

Gitlab Markdown has support for references to files in the repository structure, like:

[README](doc/README)

or

[README](doc/README#L13)

But are there ways to reference files and lines in these files, but from a given commit, at least in the Wiki ?

Maybe something like:

[README](1ab3fa71:doc/README#L13)

or using the file hash id like:

[README](9a27b101#L13)

like image 746
Luciano Avatar asked Mar 22 '17 23:03

Luciano


People also ask

How do I create a repository in GitLab?

Create a repository. To create a new repository, all you need to do is create a new project or fork an existing project . Files. Use a repository to store your files in GitLab. ... Host your codebase in GitLab repositories by pushing your... Branches. For details, see Branches . Commits. When you ...

Where are uploaded files stored in GitLab?

Starting with GitLab 11.3, any file that is uploaded to the wiki via GitLab’s interface will be stored in the wiki Git repository, and it will be available if you clone the wiki repository locally. All uploaded files prior to GitLab 11.3 are stored in GitLab itself.

Is there a way to link to a wiki in GitLab?

The reason for this is that, in GitLab, wiki is always a separate Git repository. For example, I'm a reference-style link will point the link to wikis/style when the link is inside of a wiki markdown file. There is, however, a syntax which seems to work currently:

How do I find the number of contributors in GitLab?

GitLab sets the size limits for GitLab.com . All code contributors are displayed under your project’s Repository > Contributors . The graph shows the contributor with the most commits to the fewest. A repository graph displays a visual history of the repository network, including branches and merges.


2 Answers

To use relative links from wiki to the repository (or wise versa) is not supported officially according to Gitlab's documentation (v11.5):

Note: Relative links do not allow referencing project files in a wiki page or wiki page in a project file. The reason for this is that, in GitLab, wiki is always a separate Git repository. For example, I'm a reference-style link will point the link to wikis/style when the link is inside of a wiki markdown file.

There is, however, a syntax which seems to work currently:

[[README|/../blob/1ab3fa71/doc/README#L13]]

But be aware: all text of the same paragraph will just be lost!

I work around that by phrasing like this, which renders like expected for Gitlab CE v11.3.0 at least:

Here you see xyz:
* [[README|/../blob/1ab3fa71/doc/README#L13]]

The root-anchored link (/../blob/<version>/<path-to-file>) ensures that it works from every Wiki page independently from their nesting depth. For sure this syntax also works for branch names or any other relative link like /../tree/1ab3fa71/doc for example.

like image 101
doak Avatar answered Nov 11 '22 09:11

doak


Maybe long after the battle, but I found a workaround : Simply make a link to a page where the README.md is. And that's it !

To get the link simply go to a page which displays the document, copy the URL, make a link to that address, append #L with the line number.

Exemple :

[Readme Pelargos](http://192.168.80.250:10080/project-root/android/Pelargos/blob/develop/README.md#L47)

like image 40
jihef Avatar answered Nov 11 '22 09:11

jihef