Replaces "recent incoming changes" nodemain
@ -0,0 +1,4 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 22"> | |||
<path fill="#C5C5C5" d="M12 10.005c-.73 0-1.38.41-1.73 1.02v-.02c-1.05-.02-2.27-.36-3.13-1.02-.75-.58-1.5-1.61-1.89-2.44 1.199-.958.911-2.854-.518-3.413A2.002 2.002 0 0 0 2 6.005a2 2 0 0 0 1 1.72v6.56c-.59.35-1 .99-1 1.72 0 1.11.89 2 2 2 1.534.004 2.497-1.654 1.734-2.985A1.99 1.99 0 0 0 5 14.285v-3.61c.67.7 1.44 1.27 2.3 1.69.86.42 2.03.63 2.97.64v-.02c.36.61 1 1.02 1.73 1.02 1.11 0 2-.89 2-2 0-1.11-.89-2-2-2zm-6.8 6c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM4 7.205c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm8 6c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"/> | |||
</svg> |
@ -0,0 +1,4 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 22"> | |||
<path fill="#424242" d="M12 10.005c-.73 0-1.38.41-1.73 1.02v-.02c-1.05-.02-2.27-.36-3.13-1.02-.75-.58-1.5-1.61-1.89-2.44 1.199-.958.911-2.854-.518-3.413A2.002 2.002 0 0 0 2 6.005a2 2 0 0 0 1 1.72v6.56c-.59.35-1 .99-1 1.72 0 1.11.89 2 2 2 1.534.004 2.497-1.654 1.734-2.985A1.99 1.99 0 0 0 5 14.285v-3.61c.67.7 1.44 1.27 2.3 1.69.86.42 2.03.63 2.97.64v-.02c.36.61 1 1.02 1.73 1.02 1.11 0 2-.89 2-2 0-1.11-.89-2-2-2zm-6.8 6c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM4 7.205c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm8 6c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"/> | |||
</svg> |
@ -1,61 +0,0 @@ | |||
'use strict'; | |||
import { TreeItem, TreeItemCollapsibleState } from 'vscode'; | |||
import { GlyphChars } from '../../constants'; | |||
import { Container } from '../../container'; | |||
import { GitReflog, GitUri } from '../../git/gitService'; | |||
import { Iterables } from '../../system'; | |||
import { ViewWithFiles } from '../viewBase'; | |||
import { CommitNode } from './commitNode'; | |||
import { MessageNode, ShowMoreNode } from './common'; | |||
import { insertDateMarkers } from './helpers'; | |||
import { PageableViewNode, ResourceType, ViewNode } from './viewNode'; | |||
export class RecentIncomingChangesNode extends ViewNode<ViewWithFiles> implements PageableViewNode { | |||
readonly supportsPaging: boolean = true; | |||
maxCount: number | undefined; | |||
constructor(view: ViewWithFiles, parent: ViewNode, public readonly reflog: GitReflog) { | |||
super(GitUri.fromRepoPath(reflog.repoPath), view, parent); | |||
} | |||
get id(): string { | |||
return `${this._instanceId}:gitlens:repository(${this.uri.repoPath}):recent-incoming-changes`; | |||
} | |||
async getChildren(): Promise<ViewNode[]> { | |||
const range = `${this.reflog.previousRef}..${this.reflog.ref}`; | |||
const log = await Container.git.getLog(this.uri.repoPath!, { | |||
maxCount: this.maxCount !== undefined ? this.maxCount : this.view.config.defaultItemLimit, | |||
ref: range | |||
}); | |||
if (log === undefined) return [new MessageNode(this.view, this, 'No changes')]; | |||
const children = [ | |||
...insertDateMarkers(Iterables.map(log.commits.values(), c => new CommitNode(this.view, this, c)), this, 1) | |||
]; | |||
if (log.truncated) { | |||
children.push(new ShowMoreNode(this.view, this, 'Commits', children[children.length - 1])); | |||
} | |||
return children; | |||
} | |||
getTreeItem(): TreeItem { | |||
const item = new TreeItem('Recent incoming changes', TreeItemCollapsibleState.Collapsed); | |||
item.id = this.id; | |||
item.description = `via ${this.reflog.command} ${GlyphChars.Space}${GlyphChars.Dot}${GlyphChars.Space} ${ | |||
this.reflog.formattedDate | |||
}`; | |||
item.contextValue = ResourceType.RecentIncomingChanges; | |||
item.tooltip = `Recent incoming changes via ${this.reflog.command}\n${this.reflog.formatDate()}`; | |||
// const iconSuffix = ahead ? 'upload' : 'download'; | |||
// item.iconPath = { | |||
// dark: Container.context.asAbsolutePath(`images/dark/icon-${iconSuffix}.svg`), | |||
// light: Container.context.asAbsolutePath(`images/light/icon-${iconSuffix}.svg`) | |||
// }; | |||
return item; | |||
} | |||
} |
@ -0,0 +1,66 @@ | |||
'use strict'; | |||
import { TreeItem, TreeItemCollapsibleState } from 'vscode'; | |||
import { Container } from '../../container'; | |||
import { GitUri, Repository } from '../../git/gitService'; | |||
import { PageableViewNode, ResourceType, ViewNode } from './viewNode'; | |||
import { RepositoriesView } from '../repositoriesView'; | |||
import { ReflogRecordNode } from './reflogRecordNode'; | |||
import { debug, gate } from '../../system'; | |||
import { MessageNode, ShowMoreNode } from './common'; | |||
export class ReflogNode extends ViewNode<RepositoriesView> implements PageableViewNode { | |||
readonly supportsPaging: boolean = true; | |||
maxCount: number | undefined; | |||
private _children: ViewNode[] | undefined; | |||
constructor(uri: GitUri, view: RepositoriesView, parent: ViewNode, public readonly repo: Repository) { | |||
super(uri, view, parent); | |||
} | |||
get id(): string { | |||
return `${this._instanceId}:gitlens:repository(${this.repo.path}):reflog`; | |||
} | |||
async getChildren(): Promise<ViewNode[]> { | |||
if (this._children === undefined) { | |||
const children = []; | |||
const reflog = await Container.git.getIncomingActivity(this.repo.path, { | |||
all: true, | |||
maxCount: this.maxCount !== undefined ? this.maxCount : this.view.config.defaultItemLimit | |||
}); | |||
if (reflog === undefined || reflog.records.length === 0) { | |||
return [new MessageNode(this.view, this, 'No activity could be found.')]; | |||
} | |||
children.push(...reflog.records.map(r => new ReflogRecordNode(this.view, this, r))); | |||
if (reflog.truncated) { | |||
children.push(new ShowMoreNode(this.view, this, 'Activity', children[children.length - 1])); | |||
} | |||
this._children = children; | |||
} | |||
return this._children; | |||
} | |||
getTreeItem(): TreeItem { | |||
const item = new TreeItem('Incoming Activity', TreeItemCollapsibleState.Collapsed); | |||
item.id = this.id; | |||
item.contextValue = ResourceType.Reflog; | |||
item.description = 'experimental'; | |||
item.iconPath = { | |||
dark: Container.context.asAbsolutePath('images/dark/icon-merge.svg'), | |||
light: Container.context.asAbsolutePath('images/light/icon-merge.svg') | |||
}; | |||
return item; | |||
} | |||
@gate() | |||
@debug() | |||
refresh() { | |||
this._children = undefined; | |||
} | |||
} |
@ -0,0 +1,67 @@ | |||
'use strict'; | |||
import { TreeItem, TreeItemCollapsibleState } from 'vscode'; | |||
import { GlyphChars } from '../../constants'; | |||
import { Container } from '../../container'; | |||
import { GitReflogRecord, GitUri } from '../../git/gitService'; | |||
import { Iterables } from '../../system'; | |||
import { ViewWithFiles } from '../viewBase'; | |||
import { CommitNode } from './commitNode'; | |||
import { MessageNode, ShowMoreNode } from './common'; | |||
import { PageableViewNode, ResourceType, ViewNode } from './viewNode'; | |||
export class ReflogRecordNode extends ViewNode<ViewWithFiles> implements PageableViewNode { | |||
readonly supportsPaging: boolean = true; | |||
maxCount: number | undefined; | |||
constructor(view: ViewWithFiles, parent: ViewNode, public readonly record: GitReflogRecord) { | |||
super(GitUri.fromRepoPath(record.repoPath), view, parent); | |||
} | |||
get id(): string { | |||
return `${this._instanceId}:gitlens:repository(${this.uri.repoPath}):reflog-record(${this.record.sha}|${ | |||
this.record.selector | |||
}|${this.record.command}|${this.record.commandArgs || ''}|${this.record.date.getTime()})`; | |||
} | |||
async getChildren(): Promise<ViewNode[]> { | |||
const range = `${this.record.previousSha}..${this.record.sha}`; | |||
const log = await Container.git.getLog(this.uri.repoPath!, { | |||
maxCount: this.maxCount !== undefined ? this.maxCount : this.view.config.defaultItemLimit, | |||
ref: range | |||
}); | |||
if (log === undefined) return [new MessageNode(this.view, this, 'No commits')]; | |||
const children: (CommitNode | ShowMoreNode)[] = [ | |||
...Iterables.map(log.commits.values(), c => new CommitNode(this.view, this, c)) | |||
]; | |||
if (log.truncated) { | |||
children.push(new ShowMoreNode(this.view, this, 'Commits', children[children.length - 1])); | |||
} | |||
return children; | |||
} | |||
getTreeItem(): TreeItem { | |||
const item = new TreeItem( | |||
`${this.record.command}${this.record.commandArgs ? ` ${this.record.commandArgs}` : ''}`, | |||
TreeItemCollapsibleState.Collapsed | |||
); | |||
item.id = this.id; | |||
item.description = `${ | |||
this.record.HEAD.length === 0 | |||
? '' | |||
: `${this.record.HEAD} ${GlyphChars.Space}${GlyphChars.Dot}${GlyphChars.Space} ` | |||
}${this.record.formattedDate}`; | |||
item.contextValue = ResourceType.ReflogRecord; | |||
item.tooltip = `${this.record.HEAD.length === 0 ? '' : `${this.record.HEAD}\n`}${this.record.command}${ | |||
this.record.commandArgs ? ` ${this.record.commandArgs}` : '' | |||
}${ | |||
this.record.details ? ` (${this.record.details})` : '' | |||
}\n${this.record.formatDateFromNow()} (${this.record.formatDate()})\n${this.record.previousShortSha} ${ | |||
GlyphChars.Space | |||
}${GlyphChars.ArrowRight}${GlyphChars.Space} ${this.record.shortSha}`; | |||
return item; | |||
} | |||
} |