mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-17 02:51:47 -05:00
Fixes issue with stashes w/ only untracked files
This commit is contained in:
@@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|||||||
- Removes `gitlens.annotations.file.recentChanges.hover.wholeLine` setting as it didn't really make sense
|
- Removes `gitlens.annotations.file.recentChanges.hover.wholeLine` setting as it didn't really make sense
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Fixes an issue where stashes with only untracked files would not show in the `Stashes` node of the GitLens custom view
|
||||||
|
|
||||||
## [5.0.0] - 2017-09-12
|
## [5.0.0] - 2017-09-12
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export class GitUri extends Uri {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const commit = commitOrRepoPath;
|
const commit = commitOrRepoPath;
|
||||||
base._fsPath = path.resolve(commit.repoPath, commit.originalFileName || commit.fileName);
|
base._fsPath = path.resolve(commit.repoPath, commit.originalFileName || commit.fileName || '');
|
||||||
|
|
||||||
if (commit.repoPath !== undefined) {
|
if (commit.repoPath !== undefined) {
|
||||||
this.repoPath = commit.repoPath;
|
this.repoPath = commit.repoPath;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export class GitCommit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get uri(): Uri {
|
get uri(): Uri {
|
||||||
return Uri.file(path.resolve(this.repoPath, this.originalFileName || this.fileName));
|
return Uri.file(path.resolve(this.repoPath, this.originalFileName || this.fileName || ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
private _dateFormatter?: Dates.IDateFormatter;
|
private _dateFormatter?: Dates.IDateFormatter;
|
||||||
|
|||||||
@@ -39,8 +39,13 @@ export class GitLogCommit extends GitCommit {
|
|||||||
this.fileName = fileStatus.fileName;
|
this.fileName = fileStatus.fileName;
|
||||||
this.status = fileStatus.status;
|
this.status = fileStatus.status;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (fileName === undefined) {
|
||||||
|
this.fileStatuses = [];
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
this.fileStatuses = [{ status: status, fileName: fileName, originalFileName: originalFileName } as IGitStatusFile];
|
this.fileStatuses = [{ status: status, fileName: fileName, originalFileName: originalFileName } as IGitStatusFile];
|
||||||
|
}
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,11 +13,33 @@ interface StashEntry {
|
|||||||
|
|
||||||
export class GitStashParser {
|
export class GitStashParser {
|
||||||
|
|
||||||
|
static parse(data: string, repoPath: string): GitStash | undefined {
|
||||||
|
const entries = this._parseEntries(data);
|
||||||
|
if (entries === undefined) return undefined;
|
||||||
|
|
||||||
|
const commits: Map<string, GitStashCommit> = new Map();
|
||||||
|
|
||||||
|
for (let i = 0, len = entries.length; i < len; i++) {
|
||||||
|
const entry = entries[i];
|
||||||
|
|
||||||
|
let commit = commits.get(entry.sha);
|
||||||
|
if (commit === undefined) {
|
||||||
|
commit = new GitStashCommit(entry.stashName, repoPath, entry.sha, entry.fileNames, new Date(entry.date! as any * 1000), entry.summary, undefined, entry.fileStatuses) as GitStashCommit;
|
||||||
|
commits.set(entry.sha, commit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
repoPath: repoPath,
|
||||||
|
commits: commits
|
||||||
|
} as GitStash;
|
||||||
|
}
|
||||||
|
|
||||||
private static _parseEntries(data: string): StashEntry[] | undefined {
|
private static _parseEntries(data: string): StashEntry[] | undefined {
|
||||||
if (!data) return undefined;
|
if (!data) return undefined;
|
||||||
|
|
||||||
const lines = data.split('\n');
|
const lines = data.split('\n');
|
||||||
if (!lines.length) return undefined;
|
if (lines.length === 0) return undefined;
|
||||||
|
|
||||||
const entries: StashEntry[] = [];
|
const entries: StashEntry[] = [];
|
||||||
|
|
||||||
@@ -65,7 +87,12 @@ export class GitStashParser {
|
|||||||
case 'filename':
|
case 'filename':
|
||||||
const nextLine = lines[position + 1];
|
const nextLine = lines[position + 1];
|
||||||
// If the next line isn't blank, make sure it isn't starting a new commit
|
// If the next line isn't blank, make sure it isn't starting a new commit
|
||||||
if (nextLine && Git.shaRegex.test(nextLine)) continue;
|
if (nextLine && Git.shaRegex.test(nextLine)) {
|
||||||
|
entries.push(entry);
|
||||||
|
entry = undefined;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
position++;
|
position++;
|
||||||
|
|
||||||
@@ -108,28 +135,6 @@ export class GitStashParser {
|
|||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
static parse(data: string, repoPath: string): GitStash | undefined {
|
|
||||||
const entries = this._parseEntries(data);
|
|
||||||
if (entries === undefined) return undefined;
|
|
||||||
|
|
||||||
const commits: Map<string, GitStashCommit> = new Map();
|
|
||||||
|
|
||||||
for (let i = 0, len = entries.length; i < len; i++) {
|
|
||||||
const entry = entries[i];
|
|
||||||
|
|
||||||
let commit = commits.get(entry.sha);
|
|
||||||
if (commit === undefined) {
|
|
||||||
commit = new GitStashCommit(entry.stashName, repoPath, entry.sha, entry.fileNames, new Date(entry.date! as any * 1000), entry.summary, undefined, entry.fileStatuses) as GitStashCommit;
|
|
||||||
commits.set(entry.sha, commit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
repoPath: repoPath,
|
|
||||||
commits: commits
|
|
||||||
} as GitStash;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static _parseFileName(entry: { fileName?: string, originalFileName?: string }) {
|
private static _parseFileName(entry: { fileName?: string, originalFileName?: string }) {
|
||||||
if (entry.fileName === undefined) return;
|
if (entry.fileName === undefined) return;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export class GitStatusParser {
|
|||||||
if (!data) return undefined;
|
if (!data) return undefined;
|
||||||
|
|
||||||
const lines = data.split('\n').filter(_ => !!_);
|
const lines = data.split('\n').filter(_ => !!_);
|
||||||
if (!lines.length) return undefined;
|
if (lines.length === 0) return undefined;
|
||||||
|
|
||||||
const status = {
|
const status = {
|
||||||
branch: '',
|
branch: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user