From 96b88e1fda3fef058d42ca73fab57f871dc62cec Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Tue, 16 Aug 2022 00:44:28 -0400 Subject: [PATCH] Fixes stashes display without a message Adds parents to stash commits Co-authored-by: Ramin Tadayon --- CHANGELOG.md | 1 + src/env/node/git/localGitProvider.ts | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac0899b..a90222b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Fixes [#2082](https://github.com/gitkraken/vscode-gitlens/issues/2082) - GitLens Home view unreadable in certain themes - Fixes [#2070](https://github.com/gitkraken/vscode-gitlens/issues/2070) - Quoted HTML / JSX syntax is not escaped correctly - Fixes [#2069](https://github.com/gitkraken/vscode-gitlens/issues/2069) - Heatmap - incorrect behavior of gitlens.heatmap.fadeLines with gitlens.heatmap.ageThreshold +- Fixes an issue where stashes without a message aren't displayed properly - Fixes an issue where the _Stashes_ view empty state isn't displayed properly when there are no stashes - Fixes typos via [PR #2086](https://github.com/gitkraken/vscode-gitlens/pull/2086) by stampyzfanz ([@stampyzfanz](https://github.com/stampyzfanz)), and [PR #2043](https://github.com/gitkraken/vscode-gitlens/pull/2043), [PR #2040](https://github.com/gitkraken/vscode-gitlens/pull/2040), [PR #2042](https://github.com/gitkraken/vscode-gitlens/pull/2042) by jogo- ([@jogo-](https://github.com/jogo-)) diff --git a/src/env/node/git/localGitProvider.ts b/src/env/node/git/localGitProvider.ts index 85bae1c..ab09d5e 100644 --- a/src/env/node/git/localGitProvider.ts +++ b/src/env/node/git/localGitProvider.ts @@ -3283,12 +3283,14 @@ export class LocalGitProvider implements GitProvider, Disposable { sha: string; date: string; committedDate: string; + parents: string; stashName: string; summary: string; }>({ sha: '%H', date: '%at', committedDate: '%ct', + parents: '%P', stashName: '%gd', summary: '%B', }); @@ -3304,19 +3306,21 @@ export class LocalGitProvider implements GitProvider, Disposable { let onRef; let summary; let message; + const match = stashSummaryRegex.exec(s.summary); if (match?.groups != null) { onRef = match.groups.onref; - if (match.groups.wip) { - message = `WIP: ${match.groups.summary.trim()}`; - summary = `WIP on ${onRef}`; + summary = match.groups.summary.trim(); + + if (summary.length === 0) { + message = 'WIP'; + } else if (match.groups.wip) { + message = `WIP: ${summary}`; } else { - message = match.groups.summary.trim(); - summary = message.split('\n', 1)[0] ?? ''; + message = summary; } } else { message = s.summary.trim(); - summary = message.split('\n', 1)[0] ?? ''; } commits.set( @@ -3327,8 +3331,8 @@ export class LocalGitProvider implements GitProvider, Disposable { s.sha, new GitCommitIdentity('You', undefined, new Date((s.date as any) * 1000)), new GitCommitIdentity('You', undefined, new Date((s.committedDate as any) * 1000)), - summary, - [], + message.split('\n', 1)[0] ?? '', + s.parents.split(' '), message, s.files?.map( f => new GitFileChange(repoPath, f.path, f.status as GitFileStatus, f.originalPath), @@ -3343,8 +3347,6 @@ export class LocalGitProvider implements GitProvider, Disposable { stash = { repoPath: repoPath, commits: commits }; - // sw.stop(); - if (this.useCaching) { this._stashesCache.set(repoPath, stash ?? null); }