Skip to content

Commit 2c9a26e

Browse files
committed
Fixes untracked files not showing in stash list
1 parent 1c7785f commit 2c9a26e

File tree

7 files changed

+39
-6
lines changed

7 files changed

+39
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1818

1919
### Fixed
2020
- Fixes an issue where stashes with only untracked files would not show in the `Stashes` node of the GitLens custom view
21+
- Fixes an issue where stashes with untracked files would not show its untracked files in the GitLens custom view
2122

2223
## [5.0.0] - 2017-09-12
2324
### Added
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 6 additions & 0 deletions
Loading

src/git/models/status.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface GitStatus {
1919
files: GitStatusFile[];
2020
}
2121

22-
export declare type GitStatusFileStatus = '!' | '?' | 'A' | 'C' | 'D' | 'M' | 'R' | 'U';
22+
export declare type GitStatusFileStatus = '!' | '?' | 'A' | 'C' | 'D' | 'M' | 'R' | 'T' | 'U' | 'X' | 'B';
2323

2424
export interface IGitStatusFile {
2525
status: GitStatusFileStatus;
@@ -71,7 +71,10 @@ const statusOcticonsMap = {
7171
D: '$(diff-removed)',
7272
M: '$(diff-modified)',
7373
R: '$(diff-renamed)',
74-
U: '$(question)'
74+
T: '$(diff-modified)',
75+
U: '$(alert)',
76+
X: '$(question)',
77+
B: '$(question)'
7578
};
7679

7780
export function getGitStatusOcticon(status: GitStatusFileStatus, missing: string = GlyphChars.Space.repeat(4)): string {
@@ -86,7 +89,10 @@ const statusIconsMap = {
8689
D: 'icon-status-deleted.svg',
8790
M: 'icon-status-modified.svg',
8891
R: 'icon-status-renamed.svg',
89-
U: 'icon-status-conflict.svg'
92+
T: 'icon-status-modified.svg',
93+
U: 'icon-status-conflict.svg',
94+
X: 'icon-status-unknown.svg',
95+
B: 'icon-status-unknown.svg'
9096
};
9197

9298
export function getGitStatusIcon(status: GitStatusFileStatus): string {

src/views/stashNode.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
import { Iterables } from '../system';
23
import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
34
import { ExplorerNode, ResourceType } from './explorerNode';
45
import { CommitFormatter, GitService, GitStashCommit, GitUri, ICommitFormatOptions } from '../gitService';
@@ -13,7 +14,20 @@ export class StashNode extends ExplorerNode {
1314
}
1415

1516
async getChildren(): Promise<ExplorerNode[]> {
16-
return Promise.resolve((this.commit as GitStashCommit).fileStatuses.map(s => new StashFileNode(s, this.commit, this.context, this.git)));
17+
const statuses = (this.commit as GitStashCommit).fileStatuses;
18+
19+
// Check for any untracked files -- since git doesn't return them via `git stash list` :(
20+
const log = await this.git.getLogForRepo(this.commit.repoPath, `${(this.commit as GitStashCommit).stashName}^3`, 1);
21+
if (log !== undefined) {
22+
const commit = Iterables.first(log.commits.values());
23+
if (commit !== undefined && commit.fileStatuses.length !== 0) {
24+
// Since these files are untracked -- make them look that way
25+
commit.fileStatuses.forEach(s => s.status = '?');
26+
statuses.splice(statuses.length, 0, ...commit.fileStatuses);
27+
}
28+
}
29+
30+
return Promise.resolve(statuses.map(s => new StashFileNode(s, this.commit, this.context, this.git)));
1731
}
1832

1933
getTreeItem(): TreeItem {

0 commit comments

Comments
 (0)