Browse Source

Changes pr id be a string to be more flexible

Renames pr.number to pr.id
main
Eric Amodio 4 years ago
parent
commit
511894aaf7
5 changed files with 15 additions and 37 deletions
  1. +5
    -5
      src/git/formatters/commitFormatter.ts
  2. +1
    -1
      src/git/models/pullRequest.ts
  3. +2
    -21
      src/github/github.ts
  4. +6
    -9
      src/views/nodes/pullRequestNode.ts
  5. +1
    -1
      src/webviews/webviewBase.ts

+ 5
- 5
src/git/formatters/commitFormatter.ts View File

@ -302,7 +302,7 @@ export class CommitFormatter extends Formatter {
const { pullRequestOrRemote: pr } = this._options;
if (pr != null) {
if (PullRequest.is(pr)) {
commands += `[$(git-pull-request) PR #${pr.number}](${pr.url} "Open Pull Request \\#${pr.number} on ${
commands += `[$(git-pull-request) PR #${pr.id}](${pr.url} "Open Pull Request \\#${pr.id} on ${
pr.provider
}\n${GlyphChars.Dash.repeat(2)}\n${pr.title}\n${pr.state}, ${pr.formatDateFromNow()}")${separator}`;
} else if (pr instanceof Promises.CancellationError) {
@ -456,19 +456,19 @@ export class CommitFormatter extends Formatter {
let text;
if (PullRequest.is(pr)) {
if (this._options.markdown) {
text = `[PR #${pr.number}](${pr.url} "Open Pull Request \\#${pr.number} on ${
text = `[PR #${pr.id}](${pr.url} "Open Pull Request \\#${pr.id} on ${
pr.provider
}\n${GlyphChars.Dash.repeat(2)}\n${pr.title}\n${pr.state}, ${pr.formatDateFromNow()}")`;
} else if (this._options.footnotes != null) {
const index = this._options.footnotes.size + 1;
this._options.footnotes.set(
index,
`PR #${pr.number}: ${pr.title} ${GlyphChars.Dot} ${pr.state}, ${pr.formatDateFromNow()}`,
`PR #${pr.id}: ${pr.title} ${GlyphChars.Dot} ${pr.state}, ${pr.formatDateFromNow()}`,
);
text = `PR #${pr.number}${Strings.getSuperscript(index)}`;
text = `PR #${pr.id}${Strings.getSuperscript(index)}`;
} else {
text = `PR #${pr.number}`;
text = `PR #${pr.id}`;
}
} else if (pr instanceof Promises.CancellationError) {
text = this._options.markdown

+ 1
- 1
src/git/models/pullRequest.ts View File

@ -30,7 +30,7 @@ export class PullRequest {
readonly avatarUrl: string;
readonly url: string;
},
public readonly number: number,
public readonly id: string,
public readonly title: string,
public readonly url: string,
public readonly state: PullRequestState,

+ 2
- 21
src/github/github.ts View File

@ -1,7 +1,7 @@
'use strict';
import { graphql } from '@octokit/graphql';
import { Logger } from '../logger';
import { debug, Functions } from '../system';
import { debug } from '../system';
import { AuthenticationError, ClientError, IssueOrPullRequest, PullRequest, PullRequestState } from '../git/git';
import { Account } from '../git/models/author';
@ -340,25 +340,6 @@ export class GitHubApi {
avatarSize?: number;
},
): Promise<PullRequest | undefined> {
if (ref === 'b44296e7c45a9e83530feb976f9f293a78457161') {
await Functions.wait(5000);
return new PullRequest(
provider,
{
name: 'Eric Amodio',
avatarUrl: `https://avatars1.githubusercontent.com/u/641685?s=${options?.avatarSize ?? 32}&v=4`,
url: 'https://github.com/eamodio',
},
1,
'Supercharged',
'https://github.com/eamodio/vscode-gitlens/pulls/1',
PullRequestState.Merged,
new Date('Sat, 12 Nov 2016 19:41:00 GMT'),
undefined,
new Date('Sat, 12 Nov 2016 20:41:00 GMT'),
);
}
const cc = Logger.getCorrelationContext();
try {
@ -478,7 +459,7 @@ export namespace GitHubPullRequest {
avatarUrl: pr.author.avatarUrl,
url: pr.author.url,
},
pr.number,
String(pr.number),
pr.title,
pr.permalink,
fromState(pr.state),

+ 6
- 9
src/views/nodes/pullRequestNode.ts View File

@ -15,8 +15,8 @@ export class PullRequestNode extends ViewNode<
BranchesView | CommitsView | ContributorsView | RemotesView | RepositoriesView | SearchAndCompareView
> {
static key = ':pullrequest';
static getId(repoPath: string, number: number, ref: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${number}):${ref}`;
static getId(repoPath: string, id: string, ref: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${id}):${ref}`;
}
constructor(
@ -33,7 +33,7 @@ export class PullRequestNode extends ViewNode<
}
get id(): string {
return PullRequestNode.getId(this.branchOrCommit.repoPath, this.pullRequest.number, this.branchOrCommit.ref);
return PullRequestNode.getId(this.branchOrCommit.repoPath, this.pullRequest.id, this.branchOrCommit.ref);
}
getChildren(): ViewNode[] {
@ -41,20 +41,17 @@ export class PullRequestNode extends ViewNode<
}
getTreeItem(): TreeItem {
const item = new TreeItem(
`#${this.pullRequest.number}: ${this.pullRequest.title}`,
TreeItemCollapsibleState.None,
);
const item = new TreeItem(`#${this.pullRequest.id}: ${this.pullRequest.title}`, TreeItemCollapsibleState.None);
item.contextValue = ContextValues.PullRequest;
item.description = `${this.pullRequest.state}, ${this.pullRequest.formatDateFromNow()}`;
item.iconPath = new ThemeIcon('git-pull-request');
item.id = this.id;
item.tooltip = `${this.pullRequest.title}\n#${this.pullRequest.number} by ${this.pullRequest.author.name} was ${
item.tooltip = `${this.pullRequest.title}\n#${this.pullRequest.id} by ${this.pullRequest.author.name} was ${
this.pullRequest.state === PullRequestState.Open ? 'opened' : this.pullRequest.state.toLowerCase()
} ${this.pullRequest.formatDateFromNow()}`;
if (this.branchOrCommit instanceof GitCommit) {
item.tooltip = `Commit ${this.branchOrCommit.shortSha} was introduced by PR #${this.pullRequest.number}\n${item.tooltip}`;
item.tooltip = `Commit ${this.branchOrCommit.shortSha} was introduced by PR #${this.pullRequest.id}\n${item.tooltip}`;
}
// item.tooltip = `Open Pull Request #${this.pullRequest.number} on ${this.pullRequest.provider}`;

+ 1
- 1
src/webviews/webviewBase.ts View File

@ -229,7 +229,7 @@ export abstract class WebviewBase implements Disposable {
avatarUrl: 'https://avatars1.githubusercontent.com/u/641685?s=32&v=4',
url: 'https://github.com/eamodio',
},
1,
'1',
'Supercharged',
'https://github.com/eamodio/vscode-gitlens/pulls/1',
PullRequestState.Merged,

Loading…
Cancel
Save