From 54c226c89e371d6a85a0f61e754df3212d573d8b Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 11 Apr 2018 04:20:20 -0400 Subject: [PATCH] Fixes #320 - stash parser now handles single untracked files --- CHANGELOG.md | 1 + src/git/parsers/stashParser.ts | 52 +++++++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70689cf..e48adc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Marks temporary files (used when showing comparisions with previous revisions) as read-only to help avoid accidental edits/saving ### Fixed +- Fixes [#320](https://github.com/eamodio/vscode-gitlens/issues/320) - Stashes with a single untracked file created with "stash push" aren't shown in the GitLens explorer - Fixes [#331](https://github.com/eamodio/vscode-gitlens/issues/331) - Code lens shows on every import in Python - Fixes issues where quick pick menu progress indicators will get stuck in some cases because of a vscode api change in [Microsoft/vscode#46102](https://github.com/Microsoft/vscode/pull/46102) diff --git a/src/git/parsers/stashParser.ts b/src/git/parsers/stashParser.ts index efac085..82a9bc1 100644 --- a/src/git/parsers/stashParser.ts +++ b/src/git/parsers/stashParser.ts @@ -84,35 +84,35 @@ export class GitStashParser { case 102: // 'f': // files // Skip the blank line git adds before the files next = lines.next(); - if (next.done || next.value === '') break; - - while (true) { - next = lines.next(); - if (next.done) break; - - line = next.value; - if (line === '') break; - - if (line.startsWith('warning:')) continue; - - const status = { - status: line[0] as GitStatusFileStatus, - fileName: line.substring(1), - originalFileName: undefined - } as IGitStatusFile; - GitLogParser.parseFileName(status); - - if (status.fileName) { - if (entry.fileStatuses === undefined) { - entry.fileStatuses = []; + if (!next.done && next.value !== '') { + while (true) { + next = lines.next(); + if (next.done) break; + + line = next.value; + if (line === '') break; + + if (line.startsWith('warning:')) continue; + + const status = { + status: line[0] as GitStatusFileStatus, + fileName: line.substring(1), + originalFileName: undefined + } as IGitStatusFile; + GitLogParser.parseFileName(status); + + if (status.fileName) { + if (entry.fileStatuses === undefined) { + entry.fileStatuses = []; + } + entry.fileStatuses.push(status); } - entry.fileStatuses.push(status); } - } - if (entry.fileStatuses !== undefined) { - entry.fileNames = Arrays.filterMap(entry.fileStatuses, - f => !!f.fileName ? f.fileName : undefined).join(', '); + if (entry.fileStatuses !== undefined) { + entry.fileNames = Arrays.filterMap(entry.fileStatuses, + f => !!f.fileName ? f.fileName : undefined).join(', '); + } } let commit = commits.get(entry.ref!);