|
| 1 | +# Supported Links into GitLens |
| 2 | + |
| 3 | +This document covers the various VSCode link formats that work with GitLens, along with their formats, parameters and descriptions. |
| 4 | + |
| 5 | +## Notation |
| 6 | + |
| 7 | +The following are used in link notation in this document: |
| 8 | + |
| 9 | +- _[option1|option2]_ notation means that either _option1_ or _option2_ can be used in the deep link. The actual deep link does not include the _[]_ or the _|_ symbols. |
| 10 | + |
| 11 | +- _(contents)_ notation means that the _contents_ within the _()_ are optional in the deep link. The actual deep link does not include the _()_ symbols if the contents are included. |
| 12 | + |
| 13 | +- _{reference}_ is a short-form reference to some content previously defined in the document. For example, if we define _branchLink_ as _b_ and _prefix_ as _vscode://eamodio.gitlens/link_, then the notation _{prefix}/{branchLink}_ is short-form for _vscode://eamodio.gitlens/link/b_. The reference name and _{}_ should not be included in the link. |
| 14 | + |
| 15 | +## Repository Item Deep Links |
| 16 | + |
| 17 | +### Common References |
| 18 | + |
| 19 | +- _{prefix}_ = _vscode://eamodio.gitlens/link_ |
| 20 | + |
| 21 | +- _{remoteUrl}_ is the pull URL of a git remote, including the .git part. You can see this url when, for example, choosing “Clone” on the repo’s/remote’s page in GitHub. |
| 22 | + |
| 23 | +- _{repoPath}_ is the local disk path to a git remote on the link creator’s machine. |
| 24 | + |
| 25 | +- _{repoId}_ is the first commit SHA of the repo (the full SHA, not just the short version). This field is not required to locate the repo (remote url or repo path can be used, one of which should also be on the link). If it is not known, the value should be set to _-_. |
| 26 | + |
| 27 | +- _{baseQuery}_ = _[url={remoteUrl}|path={repoPath}]_ |
| 28 | + |
| 29 | +### Notes |
| 30 | + |
| 31 | +- **Repository Matching**: To find a matching repository in repo item deep links, we first check the list of GitLens' known/open repositories in state. We use the repo’s disk path first, if provided, and then the remote URL, if provided, and then the repo ID (first commit SHA), if provided, to find a match within this list. If no matches are found, we check the shared GK folder on the user’s machine to match against the remote URL provided. This shared folder contains a mapping of remote URL to disk path on machine. If matches are found there, we offer the user the option to open one of those matching repos in a prompt. |
| 32 | + |
| 33 | +- **Remote URL**: Make sure you set a remote url on the deep link in which the target the link is pointing to exists. |
| 34 | + |
| 35 | +### Repository |
| 36 | + |
| 37 | +#### Format |
| 38 | + |
| 39 | +_{prefix}/r/{repoId}?{baseQuery}_ |
| 40 | + |
| 41 | +### Branch |
| 42 | + |
| 43 | +#### Format |
| 44 | + |
| 45 | +_{prefix}/r/{repoId}/b/{branchName}?{baseQuery}(&action={action})_ |
| 46 | + |
| 47 | +#### References |
| 48 | + |
| 49 | +- _{branchName}_ is the name of the branch. Note that the remote name should not be included. Instead, _{remoteUrl}_ is used to determine the remote for the branch. So if the branch _test_ is located on _origin_, for example, _{branchName}_ should just be _test_ and the remote url of _origin_ should be used for the _{remoteUrl}_ parameter. You should not set _{branchName}_ to _origin/test_ in this example. |
| 50 | + |
| 51 | +- _{action}_ is an optional query parameter that represents the action to take on the branch target. By default, the action on all repository item deep links, including branch deep links, is to open the commit graph and select the row pertaining to the item. This parameter allows the link to complete other actions instead: |
| 52 | + |
| 53 | + - _switch_: Switch to the branch (with options to checkout, create a new local branch if desired, or create/open a worktree). |
| 54 | + |
| 55 | + - _switch-to-pr_: Does everything that the _switch_ action does, but also opens the inspect overview, which contains details about pull requests related to the branch. |
| 56 | + |
| 57 | + - _switch-to-and-suggest-pr_: Does everything that the _switch-to-pr_ action does, but also opens the form to submit a new code suggestion. |
| 58 | + |
| 59 | + - _switch-to-pr-worktree_: Does everything that the _switch-to-pr_ action does, but always chooses to open the branch in a worktree, creating a new one if needed and creating a new local branch if needed. For creating the local branch and worktree, default options are chosen. The worktree is then opened in a new window. |
| 60 | + |
| 61 | +### Commit |
| 62 | + |
| 63 | +#### Format |
| 64 | + |
| 65 | +_{prefix}/r/{repoId}/c/{commitSha}?{baseQuery}_ |
| 66 | + |
| 67 | +#### References |
| 68 | + |
| 69 | +- _{commitSha}_ is the full SHA of the commit. |
| 70 | + |
| 71 | +### Tag |
| 72 | + |
| 73 | +#### Format |
| 74 | + |
| 75 | +_{prefix}/r/{repoId}/t/{tagName}?{baseQuery}_ |
| 76 | + |
| 77 | +#### References |
| 78 | + |
| 79 | +- _{tagName}_ is the name of the tag. Note that the remote name should not be included. Instead, _{remoteUrl}_ is used to determine the remote for the tag. So if the tag _15.2.0_ is located on _origin_, for example, _{tagName}_ should just be _15.2.0_ and the remote url of _origin_ should be used for the _{remoteUrl}_ parameter. You should not set _{tagName}_ to _origin/15.2.0_ in this example. |
| 80 | + |
| 81 | +### Comparison |
| 82 | + |
| 83 | +#### Format |
| 84 | + |
| 85 | +_{prefix}/r/{repoId}/compare/{ref1}[..|...]{ref2}?{baseQuery}(&prRepoUrl={prRepoUrl})_ |
| 86 | + |
| 87 | +#### References |
| 88 | + |
| 89 | +- _{ref1}_ and _{ref2}_ are the two refs to compare, in reverse order i.e. GitLens will compare _{ref2}_ to _{ref1}_ in the _Search & Compare_ view. These refs can be a branch name, tag name, or commit SHA. A blank ref means “working tree”. Both refs cannot be blank. |
| 90 | + |
| 91 | +- _{prRepoUrl}_ is an optional parameter, generally used for Pull Request comparisons, representing the pull URL of the git remote that represents the head commit of the Pull Request. It is formatted similar to _{remoteUrl}_, so see Common References section above to learn how to format it. |
| 92 | + |
| 93 | +### File/Lines |
| 94 | + |
| 95 | +#### Format |
| 96 | + |
| 97 | +_{prefix}/r/{repoId}/f/{filePath}?{baseQuery}(&lines={lines})(&ref={ref})_ |
| 98 | + |
| 99 | +#### References |
| 100 | + |
| 101 | +- _{filePath}_ is the path to the file relative to the root of the repo (such as _src/stuff.md_). |
| 102 | + |
| 103 | +- _{lines}_ is an optional parameter representing the lines of code, and can be a single number or two separated by a dash. |
| 104 | + |
| 105 | +- _{ref}_ is an optional parameter representing the ref at which the file is referenced. Can be a branch name or tag name, fully qualified ref like _refs/tags/…_ or a commit SHA/revision. If this is not supplied, the link points to the working version of the file. |
| 106 | + |
| 107 | +## GitKraken Cloud Item Deep Links |
| 108 | + |
| 109 | +### Common References |
| 110 | + |
| 111 | +- _{prefix}_ = _vscode://eamodio.gitlens/link_ |
| 112 | + |
| 113 | +### Notes |
| 114 | + |
| 115 | +- Accessing these deep links requires a GitKraken account. |
| 116 | + |
| 117 | +### Cloud Patch/Code Suggestion |
| 118 | + |
| 119 | +#### Format |
| 120 | + |
| 121 | +_{prefix}/drafts/{draftId}(?patch={patchId})(&type=suggested_pr_change&prEntityId={prEntityId})_ |
| 122 | + |
| 123 | +#### References |
| 124 | + |
| 125 | +- _{draftId}_ is the ID of the cloud patch. |
| 126 | + |
| 127 | +- _{patchId}_ is an optional query parameter used to access a specific revision/patch within the cloud patch. If not set, the most recent is used. |
| 128 | + |
| 129 | +- _type=suggested_pr_change&prEntityId={prEntityId}_ should be included in the query for deep links to code suggestions. These parameters should not be included for standard cloud patch links. |
| 130 | + |
| 131 | + - _{prEntityId}_ refers to the GK entity identifier for the Pull Request related to the code suggestion. |
| 132 | + |
| 133 | +### Cloud Workspace |
| 134 | + |
| 135 | +#### Format |
| 136 | + |
| 137 | +_{prefix}/workspace/{workspaceId}_ |
| 138 | + |
| 139 | +#### References |
| 140 | + |
| 141 | +- _{workspaceId}_ is the ID of the cloud workspace. |
| 142 | + |
| 143 | +## GitKraken Account Links |
| 144 | + |
| 145 | +### Login |
| 146 | + |
| 147 | +#### Format |
| 148 | + |
| 149 | +_vscode://eamodio.gitlens/login?code={code}(&state={state})(&context={context})_ |
| 150 | + |
| 151 | +#### References |
| 152 | + |
| 153 | +- _{code}_ is an exchange code used to authenticate the user with GitKraken’s API. |
| 154 | + |
| 155 | +- _{state}_ is an optional parameter representing the state used to retrieve the code, if applicable. If a state was used to retrieve the code, it must be included in the link or the login will fail. |
| 156 | + |
| 157 | +- _{context}_ is an optional parameter representing the context of the login. Currently supported values include: |
| 158 | + |
| 159 | + - _start_trial_ - Log in to start a Pro trial. |
0 commit comments