Skip to content

Commit c47d6b5

Browse files
committed
Fixes #207 - stash command not working
Fixes #203 - open changed files is broken Fixes highlander repository method Adds repository picker
1 parent e2e2207 commit c47d6b5

19 files changed

+142
-51
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [Unreleased]
8+
### Fixed
9+
- Fixes [#207](https://github.com/eamodio/vscode-gitlens/issues/207) - Applying and deleting stashes suddenly stopped working
10+
- Fixes [#203](https://github.com/eamodio/vscode-gitlens/issues/203) - Open Changed Files is broken
11+
712
## [6.1.1] - 2017-11-17
813
### Fixed
914
- Fixes [#201](https://github.com/eamodio/vscode-gitlens/issues/201) - "Open in Remote" commands should check for branch upstream tracking

src/commands/copyMessageToClipboard.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
3737

3838
// If we don't have an editor then get the message of the last commit to the branch
3939
if (uri === undefined) {
40-
if (!this.git.repoPath) return undefined;
40+
const repoPath = await this.git.getActiveRepoPath(editor);
41+
if (!repoPath) return undefined;
4142

42-
const log = await this.git.getLogForRepo(this.git.repoPath, undefined, 1);
43+
const log = await this.git.getLogForRepo(repoPath, undefined, 1);
4344
if (!log) return undefined;
4445

4546
args.message = Iterables.first(log.commits.values()).message;

src/commands/copyShaToClipboard.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
3636

3737
// If we don't have an editor then get the sha of the last commit to the branch
3838
if (uri === undefined) {
39-
if (!this.git.repoPath) return undefined;
39+
const repoPath = await this.git.getActiveRepoPath(editor);
40+
if (!repoPath) return undefined;
4041

41-
const log = await this.git.getLogForRepo(this.git.repoPath, undefined, 1);
42+
const log = await this.git.getLogForRepo(repoPath, undefined, 1);
4243
if (!log) return undefined;
4344

4445
args.sha = Iterables.first(log.commits.values()).sha;

src/commands/openBranchInRemote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
3535

3636
const gitUri = uri && await GitUri.fromUri(uri, this.git);
3737

38-
const repoPath = gitUri === undefined ? this.git.repoPath : gitUri.repoPath;
38+
const repoPath = gitUri === undefined ? this.git.getHighlanderRepoPath() : gitUri.repoPath;
3939
if (!repoPath) return undefined;
4040

4141
try {

src/commands/openBranchesInRemote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class OpenBranchesInRemoteCommand extends ActiveEditorCommand {
3131

3232
const gitUri = uri && await GitUri.fromUri(uri, this.git);
3333

34-
const repoPath = gitUri === undefined ? this.git.repoPath : gitUri.repoPath;
34+
const repoPath = gitUri === undefined ? this.git.getHighlanderRepoPath() : gitUri.repoPath;
3535
if (!repoPath) return undefined;
3636

3737
try {

src/commands/openRepoInRemote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class OpenRepoInRemoteCommand extends ActiveEditorCommand {
3131

3232
const gitUri = uri && await GitUri.fromUri(uri, this.git);
3333

34-
const repoPath = gitUri === undefined ? this.git.repoPath : gitUri.repoPath;
34+
const repoPath = gitUri === undefined ? this.git.getHighlanderRepoPath() : gitUri.repoPath;
3535
if (!repoPath) return undefined;
3636

3737
try {

src/commands/showCommitSearch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
3838

3939
const gitUri = uri === undefined ? undefined : await GitUri.fromUri(uri, this.git);
4040

41-
const repoPath = gitUri === undefined ? this.git.repoPath : gitUri.repoPath;
41+
const repoPath = gitUri === undefined ? this.git.getHighlanderRepoPath() : gitUri.repoPath;
4242
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to show commit search`);
4343

4444
args = { ...args };

src/commands/showQuickBranchHistory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
3838

3939
let progressCancellation = args.branch === undefined ? undefined : BranchHistoryQuickPick.showProgress(args.branch);
4040
try {
41-
const repoPath = gitUri === undefined ? this.git.repoPath : gitUri.repoPath;
41+
const repoPath = gitUri === undefined ? this.git.getHighlanderRepoPath() : gitUri.repoPath;
4242
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to show branch history`);
4343

4444
if (args.branch === undefined) {

src/commands/stashApply.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { Command, CommandContext, Commands, isCommandViewContextWithCommit } fro
55
import { GlyphChars } from '../constants';
66
import { GitService, GitStashCommit } from '../gitService';
77
import { Logger } from '../logger';
8-
import { CommandQuickPickItem, CommitQuickPickItem, StashListQuickPick } from '../quickPicks';
8+
import { CommandQuickPickItem, RepositoriesQuickPick, StashListQuickPick } from '../quickPicks';
99

1010
export interface StashApplyCommandArgs {
1111
confirm?: boolean;
1212
deleteAfter?: boolean;
13-
stashItem?: { stashName: string, message: string };
13+
stashItem?: { stashName: string, message: string, repoPath: string };
1414

1515
goBackCommand?: CommandQuickPickItem;
1616
}
@@ -26,28 +26,43 @@ export class StashApplyCommand extends Command {
2626
protected async preExecute(context: CommandContext, args: StashApplyCommandArgs = { confirm: true, deleteAfter: false }) {
2727
if (isCommandViewContextWithCommit<GitStashCommit>(context)) {
2828
args = { ...args };
29-
args.stashItem = { stashName: context.node.commit.stashName, message: context.node.commit.message };
29+
args.stashItem = context.node.commit;
3030
return this.execute(args);
3131
}
3232

3333
return this.execute(args);
3434
}
3535

3636
async execute(args: StashApplyCommandArgs = { confirm: true, deleteAfter: false }) {
37-
if (!this.git.repoPath) return undefined;
38-
3937
args = { ...args };
4038
if (args.stashItem === undefined || args.stashItem.stashName === undefined) {
41-
const stash = await this.git.getStashList(this.git.repoPath);
39+
let goBackToRepositoriesCommand: CommandQuickPickItem | undefined;
40+
41+
let repoPath = await this.git.getActiveRepoPath();
42+
if (!repoPath) {
43+
const pick = await RepositoriesQuickPick.show(this.git, `Apply stashed changes from which repository${GlyphChars.Ellipsis}`, args.goBackCommand);
44+
if (pick instanceof CommandQuickPickItem) return pick.execute();
45+
if (pick === undefined) return args.goBackCommand === undefined ? undefined : args.goBackCommand.execute();
46+
47+
goBackToRepositoriesCommand = new CommandQuickPickItem({
48+
label: `go back ${GlyphChars.ArrowBack}`,
49+
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to pick another repository`
50+
}, Commands.StashApply, [args]);
51+
52+
repoPath = pick.repoPath;
53+
}
54+
55+
const stash = await this.git.getStashList(repoPath);
4256
if (stash === undefined) return window.showInformationMessage(`There are no stashed changes`);
4357

4458
const currentCommand = new CommandQuickPickItem({
4559
label: `go back ${GlyphChars.ArrowBack}`,
4660
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to apply stashed changes`
4761
}, Commands.StashApply, [args]);
4862

49-
const pick = await StashListQuickPick.show(this.git, stash, 'apply', args.goBackCommand, currentCommand);
50-
if (pick === undefined || !(pick instanceof CommitQuickPickItem)) return args.goBackCommand === undefined ? undefined : args.goBackCommand.execute();
63+
const pick = await StashListQuickPick.show(this.git, stash, 'apply', goBackToRepositoriesCommand || args.goBackCommand, currentCommand);
64+
if (pick instanceof CommandQuickPickItem) return pick.execute();
65+
if (pick === undefined) return args.goBackCommand === undefined ? undefined : args.goBackCommand.execute();
5166

5267
args.goBackCommand = currentCommand;
5368
args.stashItem = pick.commit as GitStashCommit;
@@ -62,7 +77,7 @@ export class StashApplyCommand extends Command {
6277
args.deleteAfter = result.title !== 'Yes';
6378
}
6479

65-
return await this.git.stashApply(this.git.repoPath, args.stashItem.stashName, args.deleteAfter);
80+
return await this.git.stashApply(args.stashItem.repoPath, args.stashItem.stashName, args.deleteAfter);
6681
}
6782
catch (ex) {
6883
Logger.error(ex, 'StashApplyCommand');

src/commands/stashDelete.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { CommandQuickPickItem } from '../quickPicks';
88

99
export interface StashDeleteCommandArgs {
1010
confirm?: boolean;
11-
stashItem?: { stashName: string, message: string };
11+
stashItem?: { stashName: string, message: string, repoPath: string };
1212

1313
goBackCommand?: CommandQuickPickItem;
1414
}
@@ -24,18 +24,16 @@ export class StashDeleteCommand extends Command {
2424
protected async preExecute(context: CommandContext, args: StashDeleteCommandArgs = { confirm: true }) {
2525
if (isCommandViewContextWithCommit<GitStashCommit>(context)) {
2626
args = { ...args };
27-
args.stashItem = { stashName: context.node.commit.stashName, message: context.node.commit.message };
27+
args.stashItem = context.node.commit;
2828
return this.execute(args);
2929
}
3030

3131
return this.execute(args);
3232
}
3333

3434
async execute(args: StashDeleteCommandArgs = { confirm: true }) {
35-
if (!this.git.repoPath) return undefined;
36-
3735
args = { ...args };
38-
if (args.stashItem === undefined || args.stashItem.stashName === undefined) return undefined;
36+
if (args.stashItem === undefined || args.stashItem.stashName === undefined || args.stashItem.repoPath === undefined) return undefined;
3937

4038
if (args.confirm === undefined) {
4139
args.confirm = true;
@@ -48,7 +46,7 @@ export class StashDeleteCommand extends Command {
4846
if (result === undefined || result.title !== 'Yes') return args.goBackCommand === undefined ? undefined : args.goBackCommand.execute();
4947
}
5048

51-
return await this.git.stashDelete(this.git.repoPath, args.stashItem.stashName);
49+
return await this.git.stashDelete(args.stashItem.repoPath, args.stashItem.stashName);
5250
}
5351
catch (ex) {
5452
Logger.error(ex, 'StashDeleteCommand');

0 commit comments

Comments
 (0)