Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Replaces starting tilde with home directory when entered in git clone prompt
  • Loading branch information
Fong Kye Pascal committed Dec 8, 2017
1 parent d1c1116 commit 641e287
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ export class CommandCenter {
return '';
}

private handlePathTilde(path: string): string {
return path.replace(/^~/, os.homedir());
}

private static cloneId = 0;

@command('git.clone')
Expand All @@ -330,11 +334,10 @@ export class CommandCenter {

const config = workspace.getConfiguration('git');
let value = config.get<string>('defaultCloneDirectory') || os.homedir();
value = value.replace(/^~/, os.homedir());

const parentPath = await window.showInputBox({
prompt: localize('parent', "Parent Directory"),
value,
value: this.handlePathTilde(value),
ignoreFocusOut: true
});

Expand All @@ -358,7 +361,7 @@ export class CommandCenter {
statusBarItem.command = cancelCommandId;
statusBarItem.show();

const clonePromise = this.git.clone(url, parentPath, tokenSource.token);
const clonePromise = this.git.clone(url, this.handlePathTilde(parentPath), tokenSource.token);

try {
window.withProgress({ location: ProgressLocation.SourceControl, title: localize('cloning', "Cloning git repository...") }, () => clonePromise);
Expand Down

0 comments on commit 641e287

Please sign in to comment.