mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
Git - add "Stashes" node to the repositories view (#279400)
* WIP - Initial implementation * Get author and committer date for a stash * Add drop stash command * More cleanup
This commit is contained in:
@@ -44,6 +44,8 @@ export interface Stash {
|
||||
readonly index: number;
|
||||
readonly description: string;
|
||||
readonly branchName?: string;
|
||||
readonly authorDate?: Date;
|
||||
readonly commitDate?: Date;
|
||||
}
|
||||
|
||||
interface MutableRemote extends Remote {
|
||||
@@ -370,7 +372,7 @@ function sanitizeRelativePath(path: string): string {
|
||||
}
|
||||
|
||||
const COMMIT_FORMAT = '%H%n%aN%n%aE%n%at%n%ct%n%P%n%D%n%B';
|
||||
const STASH_FORMAT = '%H%n%P%n%gd%n%gs';
|
||||
const STASH_FORMAT = '%H%n%P%n%gd%n%gs%n%at%n%ct';
|
||||
|
||||
export interface ICloneOptions {
|
||||
readonly parentPath: string;
|
||||
@@ -999,12 +1001,12 @@ export function parseLsFiles(raw: string): LsFilesElement[] {
|
||||
.map(([, mode, object, stage, file]) => ({ mode, object, stage, file }));
|
||||
}
|
||||
|
||||
const stashRegex = /([0-9a-f]{40})\n(.*)\nstash@{(\d+)}\n(WIP\s)*on([^:]+):(.*)(?:\x00)/gmi;
|
||||
const stashRegex = /([0-9a-f]{40})\n(.*)\nstash@{(\d+)}\n(WIP\s)?on\s([^:]+):\s(.*)\n(\d+)\n(\d+)(?:\x00)/gmi;
|
||||
|
||||
function parseGitStashes(raw: string): Stash[] {
|
||||
const result: Stash[] = [];
|
||||
|
||||
let match, hash, parents, index, wip, branchName, description;
|
||||
let match, hash, parents, index, wip, branchName, description, authorDate, commitDate;
|
||||
|
||||
do {
|
||||
match = stashRegex.exec(raw);
|
||||
@@ -1012,13 +1014,15 @@ function parseGitStashes(raw: string): Stash[] {
|
||||
break;
|
||||
}
|
||||
|
||||
[, hash, parents, index, wip, branchName, description] = match;
|
||||
[, hash, parents, index, wip, branchName, description, authorDate, commitDate] = match;
|
||||
result.push({
|
||||
hash,
|
||||
parents: parents.split(' '),
|
||||
index: parseInt(index),
|
||||
branchName: branchName.trim(),
|
||||
description: wip ? `WIP (${description.trim()})` : description.trim()
|
||||
description: wip ? `WIP (${description.trim()})` : description.trim(),
|
||||
authorDate: authorDate ? new Date(Number(authorDate) * 1000) : undefined,
|
||||
commitDate: commitDate ? new Date(Number(commitDate) * 1000) : undefined,
|
||||
});
|
||||
} while (true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user