Open gkns opened 1 year ago
Upon looking at the code, may the below be a fix?
change the condition :
if (commit != null) {
UrlOptionsFileAtCommit(baseUrl, repositoryFile, commit, context.lineSelection)
} else {
...
}
To may be:
if (commit != null && settings.shouldCheckRemote) {
UrlOptionsFileAtCommit(baseUrl, repositoryFile, commit, context.lineSelection)
} else {
...
}
Hi, @ben-gibson, Any ideas to fix this locally as an interim measure?
Sorry for the delayed response, I don't have my own laptop right now.
By unchecking the Check remote
option, GitLink
can't go to the remote to check if the commit or branch exists there. As it can't perform that check, it has to blindly assume it does (which is the behaviour most people wanted in https://github.com/ben-gibson/GitLink/issues/202). I think what you really need here is, a new option in the settings like Always use branch
.
The only work around that I know of would be to re-enable the check remote option for now.
Thank you! Acknowledge. For now, I have made the following tweaks in the custom-domain template and it works.
File at branch template :
https://gitlab.eng.vmware.com/core-build/{remote:url:path:1}/-/blob/<hardcoded-branch-name>/{file:path}/{file:name}#L{line:start}-L{line:end}{line-block:end}
File at commit template:
https://gitlab.eng.vmware.com/core-build/{remote:url:path:1}/-/blob/{commit}/{file:name}{line-block:start}#L{line:start}-L{line:end}{line-block:end}
Commit Template:
https://gitlab.eng.vmware.com/core-build/{remote:url:path:1}/-/commit/{commit}
Fallback branch: <empty>
disable Check remote
remote gitlab
(Added it using the git remote add command)
Although the above is completely customised for my requirements. Anyone who encounters this issue can can actually tweak the URL template and get around this.
My remote is Gerrit for review purposes, however, when I generate the link, I want it to point to the GitLab repo; Hence I have a custom domain configuration.
Since my repo is large, I have disabled the
Check remote
as recommended by the plugin.But with the above changes, The link generated by
Open in GitlabVMW
(GitlabVMW is my custom domain configuration which is described below) will always have a commit ID in the file path. This commit ID will not exist in remote since the commit IDs will be different for Gerrit and Gitlab; Making the link 404. Eg link generated:https://gitlab.eng.vmware.com/core-build/repo/-/blob/0361d35bb144cdeaf534a2b1dc03fd19d6af23e5/File.java#L116-L116
I think this is a bug that has to do with the
Check remote
feature.My custom domain configuration is as follows:
Am I missing anything or can this be fixed?