Browse Source

Polishes new add remote support

main
Eric Amodio 5 years ago
parent
commit
5d3a218f2e
6 changed files with 63 additions and 45 deletions
  1. +4
    -0
      CHANGELOG.md
  2. +1
    -0
      README.md
  3. +22
    -13
      package.json
  4. +4
    -4
      src/git/git.ts
  5. +5
    -6
      src/git/gitService.ts
  6. +27
    -22
      src/views/viewCommands.ts

+ 4
- 0
CHANGELOG.md View File

@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]
### Added
- Adds an _Add Remote_ command to the _Remotes_ node of the _Repositories_ view — closes [#694](https://github.com/eamodio/vscode-gitlens/issues/694) thanks to [PR #802](https://github.com/eamodio/vscode-gitlens/pull/802) by Zach Boyle ([@zaboyle](https://github.com/zaboyle))
### Changed
- Reverses the order of comparisons in the _Compare_ view for consistent comparisons results

+ 1
- 0
README.md View File

@ -922,6 +922,7 @@ Add [`"gitlens.insiders": true`](#general-settings- 'Jump to GitLens settings')
A big thanks to the people that have contributed to this project:
- Loris Bettazza ([@Pustur](https://github.com/Pustur)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=Pustur)
- Zach Boyle ([@zaboyle](https://github.com/zaboyle)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=zaboyle)
- Tony Brix ([@UziTech](https://github.com/UziTech)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=UziTech)
- Amanda Cameron ([@AmandaCameron](https://github.com/AmandaCameron)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=AmandaCameron)
- Brett Cannon ([@brettcannon](https://github.com/brettcannon)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=brettcannon)

+ 22
- 13
package.json View File

@ -2365,21 +2365,21 @@
}
},
{
"command": "gitlens.views.checkout",
"title": "Checkout",
"command": "gitlens.views.addRemote",
"title": "Add Remote",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-checkout.svg",
"light": "images/light/icon-checkout.svg"
"dark": "images/dark/icon-add.svg",
"light": "images/light/icon-add.svg"
}
},
{
"command": "gitlens.views.addRemote",
"title": "Add Remote",
"command": "gitlens.views.checkout",
"title": "Checkout",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-add.svg",
"light": "images/light/icon-add.svg"
"dark": "images/dark/icon-checkout.svg",
"light": "images/light/icon-checkout.svg"
}
},
{
@ -3352,6 +3352,10 @@
"when": "gitlens:hasRemotes && !gitlens:readonly"
},
{
"command": "gitlens.views.addRemote",
"when": "false"
},
{
"command": "gitlens.views.checkout",
"when": "false"
},
@ -4267,11 +4271,6 @@
"group": "inline@10"
},
{
"command": "gitlens.views.addRemote",
"when": "viewItem =~ /gitlens:remotes\\b/",
"group": "inline@10"
},
{
"command": "gitlens.views.compareWithRemote",
"when": "viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+tracking\\b)/",
"group": "inline@96"
@ -4642,6 +4641,16 @@
"group": "8_gitlens@2"
},
{
"command": "gitlens.views.addRemote",
"when": "!gitlens:readonly && viewItem =~ /gitlens:remotes\\b/",
"group": "inline@1"
},
{
"command": "gitlens.views.addRemote",
"when": "!gitlens:readonly && viewItem =~ /gitlens:remotes\\b/",
"group": "1_gitlens@1"
},
{
"command": "gitlens.views.fetch",
"when": "!gitlens:readonly && viewItem =~ /gitlens:remote\\b/",
"group": "inline@97"

+ 4
- 4
src/git/git.ts View File

@ -471,10 +471,6 @@ export class Git {
return git<string>({ cwd: repoPath }, ...params);
}
static addRemote(repoPath: string, branchName: string, remoteUrl: string) {
return git<string>({ cwd: repoPath },'remote', 'add', branchName, remoteUrl);
}
static async config__get(key: string, repoPath?: string, options: { local?: boolean } = {}) {
const data = await git<string>(
{ cwd: repoPath || emptyStr, errors: GitErrorHandling.Ignore, local: options.local },
@ -865,6 +861,10 @@ export class Git {
return git<string>({ cwd: repoPath }, 'remote', '-v');
}
static remote__add(repoPath: string, name: string, url: string) {
return git<string>({ cwd: repoPath }, 'remote', 'add', name, url);
}
static remote__get_url(repoPath: string, remote: string): Promise<string> {
return git<string>({ cwd: repoPath }, 'remote', 'get-url', remote);
}

+ 5
- 6
src/git/gitService.ts View File

@ -454,6 +454,11 @@ export class GitService implements Disposable {
}
@log()
addRemote(repoPath: string, name: string, url: string) {
return Git.remote__add(repoPath, name, url);
}
@log()
async applyChangesToWorkingFile(uri: GitUri, ref1?: string, ref2?: string) {
const cc = Logger.getCorrelationContext();
@ -522,12 +527,6 @@ export class GitService implements Disposable {
@gate()
@log()
addRemote(repoPath: string, branchName: string, remoteUrl: string) {
return Git.addRemote(repoPath, branchName, remoteUrl);
}
@gate()
@log()
fetch(repoPath: string, options: { all?: boolean; prune?: boolean; remote?: string } = {}) {
return Git.fetch(repoPath, options);
}

+ 27
- 22
src/views/viewCommands.ts View File

@ -270,10 +270,10 @@ export class ViewCommands {
}
const name = await window.showInputBox({
prompt:
"Please provide a name for the local branch (Press 'Enter' to confirm or 'Escape' to cancel)",
prompt: 'Please provide a name for the local branch',
placeHolder: 'Local branch name',
value: branch.getName()
value: branch.getName(),
ignoreFocusOut: true
});
if (name === undefined || name.length === 0) return undefined;
@ -287,23 +287,26 @@ export class ViewCommands {
}
private async addRemote(node: RemoteNode) {
const branchName = await window.showInputBox({
prompt: "Please provide a name for the remote branch (Press 'Enter' to confirm or 'Escape' to cancel)",
placeHolder: 'Remote branch name',
value: undefined
const name = await window.showInputBox({
prompt: 'Please provide a name for the remote',
placeHolder: 'Remote name',
value: undefined,
ignoreFocusOut: true
});
if (name === undefined || name.length === 0) return undefined;
if( branchName === undefined || branchName.length === 0) return undefined;
const remoteUrl = await window.showInputBox({
prompt: "Please provide a url for the remote branch (Press 'Enter' to confirm or 'Escape' to cancel)",
placeHolder: 'Remote branch url',
value: undefined
const url = await window.showInputBox({
prompt: 'Please provide the repository url for the remote',
placeHolder: 'Remote repository url',
value: undefined,
ignoreFocusOut: true
});
if (url === undefined || url.length === 0) return undefined;
if (remoteUrl === undefined || remoteUrl.length === 0) return undefined;
void (await Container.git.addRemote(node.repo.path, name, url));
void (await node.repo.fetch({ remote: name }));
return Container.git.addRemote(node.repo.path, branchName, remoteUrl);
return name;
}
private closeRepository(node: RepositoryNode) {
@ -783,9 +786,10 @@ export class ViewCommands {
}
const name = await window.showInputBox({
prompt: "Please provide a branch name (Press 'Enter' to confirm or 'Escape' to cancel)";,
prompt: 'Please provide a branch name';,
placeHolder: 'Branch name',
value: value
value: value,
ignoreFocusOut: true
});
if (name === undefined || name.length === 0) return;
@ -881,15 +885,16 @@ export class ViewCommands {
if (!(node instanceof ViewRefNode)) return;
const name = await window.showInputBox({
prompt: "Please provide a tag name (Press 'Enter' to confirm or 'Escape' to cancel)",
placeHolder: 'Tag name'
prompt: 'Please provide a tag name',
placeHolder: 'Tag name',
ignoreFocusOut: true
});
if (name === undefined || name.length === 0) return;
const message = await window.showInputBox({
prompt:
"Please provide an optional message to annotate the tag (Press 'Enter' to confirm or 'Escape' to cancel)";,
placeHolder: 'Tag message'
prompt: 'Please provide an optional message to annotate the tag',
placeHolder: 'Tag message';,
ignoreFocusOut: true
});
if (message === undefined) return;

Loading…
Cancel
Save