|
@ -1,20 +1,23 @@ |
|
|
'use strict'; |
|
|
'use strict'; |
|
|
|
|
|
import * as paths from 'path'; |
|
|
import { TreeItem, TreeItemCollapsibleState } from 'vscode'; |
|
|
import { TreeItem, TreeItemCollapsibleState } from 'vscode'; |
|
|
import { Container } from '../../container'; |
|
|
import { Container } from '../../container'; |
|
|
import { CommitFormatter, GitStashCommit } from '../../git/gitService'; |
|
|
import { CommitFormatter, GitStashCommit } from '../../git/gitService'; |
|
|
import { Iterables } from '../../system'; |
|
|
|
|
|
import { View } from '../viewBase'; |
|
|
|
|
|
|
|
|
import { Arrays, Iterables, Strings } from '../../system'; |
|
|
|
|
|
import { ViewWithFiles } from '../viewBase'; |
|
|
import { StashFileNode } from './stashFileNode'; |
|
|
import { StashFileNode } from './stashFileNode'; |
|
|
import { ResourceType, ViewNode, ViewRefNode } from './viewNode'; |
|
|
import { ResourceType, ViewNode, ViewRefNode } from './viewNode'; |
|
|
import { RepositoryNode } from './repositoryNode'; |
|
|
import { RepositoryNode } from './repositoryNode'; |
|
|
|
|
|
import { FileNode, FolderNode } from '../nodes'; |
|
|
|
|
|
import { ViewFilesLayout } from '../../config'; |
|
|
|
|
|
|
|
|
export class StashNode extends ViewRefNode { |
|
|
|
|
|
|
|
|
export class StashNode extends ViewRefNode<ViewWithFiles> { |
|
|
static key = ':stash'; |
|
|
static key = ':stash'; |
|
|
static getId(repoPath: string, ref: string): string { |
|
|
static getId(repoPath: string, ref: string): string { |
|
|
return `${RepositoryNode.getId(repoPath)}${this.key}(${ref})`; |
|
|
return `${RepositoryNode.getId(repoPath)}${this.key}(${ref})`; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
constructor(view: View, parent: ViewNode, public readonly commit: GitStashCommit) { |
|
|
|
|
|
|
|
|
constructor(view: ViewWithFiles, parent: ViewNode, public readonly commit: GitStashCommit) { |
|
|
super(commit.toGitUri(), view, parent); |
|
|
super(commit.toGitUri(), view, parent); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -48,8 +51,22 @@ export class StashNode extends ViewRefNode { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const children = files.map(s => new StashFileNode(this.view, this, s, this.commit.toFileCommit(s))); |
|
|
|
|
|
children.sort((a, b) => a.label.localeCompare(b.label, undefined, { numeric: true, sensitivity: 'base' })); |
|
|
|
|
|
|
|
|
let children: FileNode[] = files.map(s => new StashFileNode(this.view, this, s, this.commit.toFileCommit(s))); |
|
|
|
|
|
if (this.view.config.files.layout !== ViewFilesLayout.List) { |
|
|
|
|
|
const hierarchy = Arrays.makeHierarchical( |
|
|
|
|
|
children, |
|
|
|
|
|
n => n.uri.relativePath.split('/'), |
|
|
|
|
|
(...parts: string[]) => Strings.normalizePath(paths.join(...parts)), |
|
|
|
|
|
this.view.config.files.compact |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const root = new FolderNode(this.view, this, this.repoPath, '', hierarchy); |
|
|
|
|
|
children = root.getChildren() as FileNode[]; |
|
|
|
|
|
} else { |
|
|
|
|
|
children.sort((a, b) => |
|
|
|
|
|
a.label!.localeCompare(b.label!, undefined, { numeric: true, sensitivity: 'base' }) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
return children; |
|
|
return children; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|