veler / CopyGitLink

Copy links to files or selections to GitHub and Azure DevOps directly from Visual Studio's text editor, Solution Explorer and document tab.
https://marketplace.visualstudio.com/items?itemName=EtienneBAUDOUX.CopyGitLink
MIT License
42 stars 9 forks source link

Does not work with private gitlab repositories. #11

Closed pointcache closed 2 years ago

pointcache commented 2 years ago

The working link is user/repo -/blob/main/src/Something/File.cs your link user/repo blob/eae7f475ff2efa34e8asd559062baeab0/src/Something/File.cs#L27-27 Which gives me 404 even tho im logged in and have access to the repository. I would really like to use this extension.

veler commented 2 years ago

Hello,

Thank you for your feedback. I do not have a private GitLab for testing it, but based on what I'm reading online, it looks like permalink (link to a file, to a specific commit) looks like the following:

{base}/{repository}/-/blob/{ref}/{file}

So it sounds like user/repo blob/eae7f475ff2efa34e8asd559062baeab0/src/Something/File.cs#L27-27 should be transformed to user/repo/-/blob/eae7f475ff2efa34e8asd559062baeab0/src/Something/File.cs#L27-27

Can you please confirm whether such a URL would work?

@hmaiga , if I recall correctly, you are familiar with GitLab Enterprise. Would you be able to confirm my assumption?

Thank you :)

hmaiga commented 2 years ago

Hi 👋, I'm checking and will come back to you asap @veler .

hmaiga commented 2 years ago

Hi @pointcache, On my side, i cannot reproduce this issue. The only scenario in which you will have this 404 error is when the commit ref in the permalink has not been pushed on the remote server. The behavior is the same for Gitlab Entreprise or Github.

Example: The url format: {base}/{repository}/-/blob/{ref|branch_name}/{file} Case 1: These two links will lead you to the same code snippet version

Case 2: So for this case let's try to use a fake commit hash, that means this commit is not known by the remote server: 805d6d7ba16ff8fdc1ca4fd3d8b0ccf4176f3d40

So for your case @pointcache, could you double check and be sure that this commit eae7f475ff2efa34e8asd559062baeab0 has been pushed on your remote server please ?

veler commented 2 years ago

Thanks @hmaiga for this! Super helpful! On a side note, perhaps a UX could be provided for when a commit isn't pushed yet.

pointcache commented 2 years ago

Can't replicate anymore, youre most likely right, if i run into it again ill just read this page. Thank for you for this ext, extremely helpful.