Przeglądaj źródła

Fixes issues w/ dynamic PR lookup

Fixes #2177, fixes #2185, fixes #2180, fixes #2179
main
Eric Amodio 2 lat temu
rodzic
commit
a3d6b712b2
7 zmienionych plików z 89 dodań i 49 usunięć
  1. +4
    -0
      CHANGELOG.md
  2. +20
    -15
      src/views/nodes/branchNode.ts
  3. +10
    -0
      src/views/nodes/commitFileNode.ts
  4. +23
    -16
      src/views/nodes/commitNode.ts
  5. +10
    -0
      src/views/nodes/folderNode.ts
  6. +3
    -4
      src/views/nodes/pullRequestNode.ts
  7. +19
    -14
      src/views/nodes/worktreeNode.ts

+ 4
- 0
CHANGELOG.md Wyświetl plik

@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#2177](https://github.com/gitkraken/vscode-gitlens/issues/2177) - Open Changes action unresponsive in Source Control view
- Fixes [#2185](https://github.com/gitkraken/vscode-gitlens/issues/2185) - Commits view files are sometimes not shown when expanding folders
- Fixes [#2180](https://github.com/gitkraken/vscode-gitlens/issues/2180) - Tree files view of commits is broken
- Fixes [#2179](https://github.com/gitkraken/vscode-gitlens/issues/2179) - Commit Graph content not displayed
- Fixes [#2187](https://github.com/gitkraken/vscode-gitlens/issues/2187) - scm/title commands shown against non-Git SCM providers — thanks to [PR #2186](https://github.com/gitkraken/vscode-gitlens/pull/2186) by Matt Seddon ([@mattseddon](https://github.com/mattseddon))
## [12.2.1] - 2022-09-01

+ 20
- 15
src/views/nodes/branchNode.ts Wyświetl plik

@ -1,7 +1,8 @@
import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, window } from 'vscode';
import type { ViewShowBranchComparison } from '../../configuration';
import { ViewBranchesLayout } from '../../configuration';
import { Colors, GlyphChars } from '../../constants';
import { Colors, ContextKeys, GlyphChars } from '../../constants';
import { getContext } from '../../context';
import type { GitUri } from '../../git/gitUri';
import type { GitBranch } from '../../git/models/branch';
import type { GitLog } from '../../git/models/log';
@ -146,7 +147,8 @@ export class BranchNode
if (
this.view.config.pullRequests.enabled &&
this.view.config.pullRequests.showForBranches &&
(branch.upstream != null || branch.remote)
(branch.upstream != null || branch.remote) &&
getContext(ContextKeys.HasConnectedRemotes)
) {
pullRequest = this.getState('pullRequest');
if (pullRequest === undefined && this.getState('pendingPullRequest') === undefined) {
@ -157,9 +159,18 @@ export class BranchNode
);
queueMicrotask(async () => {
const [prResult] = await Promise.allSettled([prPromise, onCompleted?.promise]);
await onCompleted?.promise;
// If we are waiting too long, refresh this node to show a spinner while the pull request is loading
let spinner = false;
const timeout = setTimeout(() => {
spinner = true;
this.view.triggerNodeChange(this);
}, 250);
const pr = await prPromise;
clearTimeout(timeout);
const pr = getSettledValue(prResult);
// If we found a pull request, insert it into the children cache (if loaded) and refresh the node
if (pr != null && this._children != null) {
this._children.splice(
@ -169,17 +180,11 @@ export class BranchNode
);
}
// Refresh this node to add or remove the pull request node
this.view.triggerNodeChange(this);
// Refresh this node to add the pull request node or remove the spinner
if (spinner || pr != null) {
this.view.triggerNodeChange(this);
}
});
// // If we are showing the node, then refresh this node to show a spinner while the pull request is loading
// if (!this.splatted) {
// void onCompleted?.promise.then(
// () => this.view.triggerNodeChange(this),
// () => {},
// );
// }
}
}
@ -326,7 +331,7 @@ export class BranchNode
}
this._children = children;
onCompleted?.fulfill();
setTimeout(() => onCompleted?.fulfill(), 1);
}
return this._children;

+ 10
- 0
src/views/nodes/commitFileNode.ts Wyświetl plik

@ -15,6 +15,11 @@ import type { ViewNode } from './viewNode';
import { ContextValues, ViewRefFileNode } from './viewNode';
export class CommitFileNode<TView extends View = ViewsWithCommits | FileHistoryView> extends ViewRefFileNode<TView> {
static key = ':file';
static getId(parent: ViewNode, path: string): string {
return `${parent.id}${this.key}(${path})`;
}
constructor(
view: TView,
parent: ViewNode,
@ -33,6 +38,10 @@ export class CommitFileNode
return this.file.path;
}
override get id(): string {
return CommitFileNode.getId(this.parent, this.file.path);
}
get priority(): number {
return 0;
}
@ -63,6 +72,7 @@ export class CommitFileNode
}
const item = new TreeItem(this.label, TreeItemCollapsibleState.None);
item.id = this.id;
item.contextValue = this.contextValue;
item.description = this.description;
item.resourceUri = Uri.parse(`gitlens-view://commit-file/status/${this.file.status}`);

+ 23
- 16
src/views/nodes/commitNode.ts Wyświetl plik

@ -2,7 +2,8 @@ import type { Command } from 'vscode';
import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
import type { DiffWithPreviousCommandArgs } from '../../commands';
import { configuration, ViewFilesLayout } from '../../configuration';
import { Colors, Commands } from '../../constants';
import { Colors, Commands, ContextKeys } from '../../constants';
import { getContext } from '../../context';
import { CommitFormatter } from '../../git/formatters/commitFormatter';
import type { GitBranch } from '../../git/models/branch';
import type { GitCommit } from '../../git/models/commit';
@ -23,7 +24,6 @@ import { CommitFileNode } from './commitFileNode';
import type { FileNode } from './folderNode';
import { FolderNode } from './folderNode';
import { PullRequestNode } from './pullRequestNode';
import { RepositoryNode } from './repositoryNode';
import type { ViewNode } from './viewNode';
import { ContextValues, ViewRefNode } from './viewNode';
@ -34,8 +34,8 @@ type State = {
export class CommitNode extends ViewRefNode<ViewsWithCommits | FileHistoryView, GitRevisionReference, State> {
static key = ':commit';
static getId(parent: ViewNode, repoPath: string, sha: string): string {
return `${parent.id}|${RepositoryNode.getId(repoPath)}${this.key}(${sha})`;
static getId(parent: ViewNode, sha: string): string {
return `${parent.id}${this.key}(${sha})`;
}
constructor(
@ -55,7 +55,7 @@ export class CommitNode extends ViewRefNode
}
override get id(): string {
return CommitNode.getId(this.parent, this.commit.repoPath, this.commit.sha);
return CommitNode.getId(this.parent, this.commit.sha);
}
get isTip(): boolean {
@ -79,6 +79,8 @@ export class CommitNode extends ViewRefNode
if (
!(this.view instanceof TagsView) &&
!(this.view instanceof FileHistoryView) &&
!this.unpublished &&
getContext(ContextKeys.HasConnectedRemotes) &&
this.view.config.pullRequests.enabled &&
this.view.config.pullRequests.showForCommits
) {
@ -88,9 +90,18 @@ export class CommitNode extends ViewRefNode
const prPromise = this.getAssociatedPullRequest(commit);
queueMicrotask(async () => {
const [prResult] = await Promise.allSettled([prPromise, onCompleted?.promise]);
await onCompleted?.promise;
// If we are waiting too long, refresh this node to show a spinner while the pull request is loading
let spinner = false;
const timeout = setTimeout(() => {
spinner = true;
this.view.triggerNodeChange(this);
}, 250);
const pr = await prPromise;
clearTimeout(timeout);
const pr = getSettledValue(prResult);
// If we found a pull request, insert it into the children cache (if loaded) and refresh the node
if (pr != null && this._children != null) {
this._children.splice(
@ -100,15 +111,11 @@ export class CommitNode extends ViewRefNode
);
}
// Refresh this node to add or remove the pull request node
this.view.triggerNodeChange(this);
// Refresh this node to add the pull request node or remove the spinner
if (spinner || pr != null) {
this.view.triggerNodeChange(this);
}
});
// // Refresh this node to show a spinner while the pull request is loading
// void onCompleted?.promise.then(
// () => this.view.triggerNodeChange(this),
// () => {},
// );
}
}
@ -136,7 +143,7 @@ export class CommitNode extends ViewRefNode
}
this._children = children;
onCompleted?.fulfill();
setTimeout(() => onCompleted?.fulfill(), 1);
}
return this._children;

+ 10
- 0
src/views/nodes/folderNode.ts Wyświetl plik

@ -21,6 +21,11 @@ export interface FileNode extends ViewFileNode {
}
export class FolderNode extends ViewNode<ViewsWithCommits | FileHistoryView | StashesView> {
static key = ':folder';
static getId(parent: ViewNode, path: string): string {
return `${parent.id}${this.key}(${path})`;
}
readonly priority: number = 1;
constructor(
@ -39,6 +44,10 @@ export class FolderNode extends ViewNode
return this.folderName;
}
override get id(): string {
return FolderNode.getId(this.parent, this.folderName);
}
getChildren(): (FolderNode | FileNode)[] {
if (this.root.descendants === undefined || this.root.children === undefined) return [];
@ -90,6 +99,7 @@ export class FolderNode extends ViewNode
getTreeItem(): TreeItem {
const item = new TreeItem(this.label, TreeItemCollapsibleState.Expanded);
item.id = this.id;
item.contextValue = ContextValues.Folder;
if (this.containsWorkingFiles) {
item.contextValue += '+working';

+ 3
- 4
src/views/nodes/pullRequestNode.ts Wyświetl plik

@ -5,13 +5,12 @@ import type { GitCommit } from '../../git/models/commit';
import { isCommit } from '../../git/models/commit';
import { PullRequest, PullRequestState } from '../../git/models/pullRequest';
import type { ViewsWithCommits } from '../viewBase';
import { RepositoryNode } from './repositoryNode';
import { ContextValues, ViewNode } from './viewNode';
export class PullRequestNode extends ViewNode<ViewsWithCommits> {
static key = ':pullrequest';
static getId(parent: ViewNode, repoPath: string, id: string, ref?: string): string {
return `${parent.id}|${RepositoryNode.getId(repoPath)}${this.key}(${id}):${ref}`;
static getId(parent: ViewNode, id: string, ref?: string): string {
return `${parent.id}${this.key}(${id}):${ref}`;
}
public readonly pullRequest: PullRequest;
@ -45,7 +44,7 @@ export class PullRequestNode extends ViewNode {
}
override get id(): string {
return PullRequestNode.getId(this.parent, this.repoPath, this.pullRequest.id, this.branchOrCommit?.ref);
return PullRequestNode.getId(this.parent, this.pullRequest.id, this.branchOrCommit?.ref);
}
getChildren(): ViewNode[] {

+ 19
- 14
src/views/nodes/worktreeNode.ts Wyświetl plik

@ -1,5 +1,6 @@
import { MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, window } from 'vscode';
import { GlyphChars } from '../../constants';
import { ContextKeys, GlyphChars } from '../../constants';
import { getContext } from '../../context';
import type { GitUri } from '../../git/gitUri';
import type { GitBranch } from '../../git/models/branch';
import type { GitLog } from '../../git/models/log';
@ -72,7 +73,8 @@ export class WorktreeNode extends ViewNode
branch != null &&
this.view.config.pullRequests.enabled &&
this.view.config.pullRequests.showForBranches &&
(branch.upstream != null || branch.remote)
(branch.upstream != null || branch.remote) &&
getContext(ContextKeys.HasConnectedRemotes)
) {
pullRequest = this.getState('pullRequest');
if (pullRequest === undefined && this.getState('pendingPullRequest') === undefined) {
@ -82,9 +84,18 @@ export class WorktreeNode extends ViewNode
});
queueMicrotask(async () => {
const [prResult] = await Promise.allSettled([prPromise, onCompleted?.promise]);
await onCompleted?.promise;
// If we are waiting too long, refresh this node to show a spinner while the pull request is loading
let spinner = false;
const timeout = setTimeout(() => {
spinner = true;
this.view.triggerNodeChange(this);
}, 250);
const pr = await prPromise;
clearTimeout(timeout);
const pr = getSettledValue(prResult);
// If we found a pull request, insert it into the children cache (if loaded) and refresh the node
if (pr != null && this._children != null) {
this._children.splice(
@ -94,17 +105,11 @@ export class WorktreeNode extends ViewNode
);
}
// Refresh this node to add or remove the pull request node
this.view.triggerNodeChange(this);
// Refresh this node to add the pull request node or remove the spinner
if (spinner || pr != null) {
this.view.triggerNodeChange(this);
}
});
// // If we are showing the node, then refresh this node to show a spinner while the pull request is loading
// if (!this.splatted) {
// void onCompleted?.promise.then(
// () => this.view.triggerNodeChange(this),
// () => {},
// );
// }
}
}

Ładowanie…
Anuluj
Zapisz