Browse Source

Closes #678 - Adds support for github pr scheme

main
Eric Amodio 5 years ago
parent
commit
7980fffa49
5 changed files with 59 additions and 25 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +3
    -2
      src/codelens/codeLensProvider.ts
  3. +1
    -0
      src/constants.ts
  4. +3
    -2
      src/git/gitService.ts
  5. +51
    -21
      src/git/gitUri.ts

+ 1
- 0
CHANGELOG.md View File

@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Adds a new _co-author_ command to the _Git Commands_ quick pick menu to add a co-author to a commit message
- Adds a new _Add Co-authors_ command to the inline toolbar and context menu for the _Contributors_ node in the _Repositories_ view
- Adds the _Add as Co-author_ command to the inline toolbar for the contributors in the _Repositories_ view
- Adds support for GitHub Pull Request uri schemes (`pr://`)
- Adds new actions options to the status bar blame
- Adds a `gitlens.showCommitsInView` option to show the commit in the _Search Commits_ view
- Adds a `gitlens.revealCommitInView` option to to reveal the commit in the _Repositories_ view

+ 3
- 2
src/codelens/codeLensProvider.ts View File

@ -86,9 +86,10 @@ export class GitCodeLensProvider implements CodeLensProvider {
static selector: DocumentSelector = [
{ scheme: DocumentSchemes.File },
{ scheme: DocumentSchemes.Vsls },
{ scheme: DocumentSchemes.Git },
{ scheme: DocumentSchemes.GitLens }
{ scheme: DocumentSchemes.GitLens },
{ scheme: DocumentSchemes.PRs },
{ scheme: DocumentSchemes.Vsls }
];
constructor(

+ 1
- 0
src/constants.ts View File

@ -57,6 +57,7 @@ export enum DocumentSchemes {
Git = 'git',
GitLens = 'gitlens',
Output = 'output',
PRs = 'pr',
Vsls = 'vsls'
}

+ 3
- 2
src/git/gitService.ts View File

@ -2606,9 +2606,10 @@ export class GitService implements Disposable {
const scheme = typeof schemeOruri === 'string' ? schemeOruri : schemeOruri.scheme;
return (
scheme === DocumentSchemes.File ||
scheme === DocumentSchemes.Vsls ||
scheme === DocumentSchemes.Git ||
scheme === DocumentSchemes.GitLens
scheme === DocumentSchemes.GitLens ||
scheme === DocumentSchemes.PRs ||
scheme === DocumentSchemes.Vsls
);
}

+ 51
- 21
src/git/gitUri.ts View File

@ -268,32 +268,62 @@ export class GitUri extends ((Uri as any) as UriEx) {
// If this is a git uri, find its repoPath
if (uri.scheme === DocumentSchemes.Git) {
const data: { path: string; ref: string } = JSON.parse(uri.query);
try {
const data: { path: string; ref: string } = JSON.parse(uri.query);
const repoPath = await Container.git.getRepoPath(data.path);
const repoPath = await Container.git.getRepoPath(data.path);
let ref;
switch (data.ref) {
case emptyStr:
case '~':
ref = GitService.uncommittedStagedSha;
break;
let ref;
switch (data.ref) {
case emptyStr:
case '~':
ref = GitService.uncommittedStagedSha;
break;
case null:
ref = undefined;
break;
case null:
ref = undefined;
break;
default:
ref = data.ref;
break;
}
default:
ref = data.ref;
break;
}
const commitish: GitCommitish = {
fileName: data.path,
repoPath: repoPath!,
sha: ref
};
return new GitUri(uri, commitish);
} catch {}
}
if (uri.scheme === DocumentSchemes.PRs) {
try {
const data: {
baseCommit: string;
headCommit: string;
isBase: boolean;
fileName: string;
prNumber: number;
status: number;
remoteName: string;
} = JSON.parse(uri.query);
let repoPath = Strings.normalizePath(uri.fsPath);
if (repoPath.endsWith(data.fileName)) {
repoPath = repoPath.substr(0, repoPath.length - data.fileName.length - 1);
} else {
repoPath = (await Container.git.getRepoPath(uri.fsPath))!;
}
const commitish: GitCommitish = {
fileName: data.path,
repoPath: repoPath!,
sha: ref
};
return new GitUri(uri, commitish);
const commitish: GitCommitish = {
fileName: data.fileName,
repoPath: repoPath,
sha: data.isBase ? data.baseCommit : data.headCommit
};
return new GitUri(uri, commitish);
} catch {}
}
return new GitUri(uri, await Container.git.getRepoPath(uri));

Loading…
Cancel
Save