Browse Source

Adds add new remote support

main
zboyle 5 years ago
committed by Eric Amodio
parent
commit
e28db743ec
4 changed files with 45 additions and 0 deletions
  1. +14
    -0
      package.json
  2. +4
    -0
      src/git/git.ts
  3. +6
    -0
      src/git/gitService.ts
  4. +21
    -0
      src/views/viewCommands.ts

+ 14
- 0
package.json View File

@ -2374,6 +2374,15 @@
}
},
{
"command": "gitlens.views.addRemote",
"title": "Add Remote",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-add.svg",
"light": "images/light/icon-add.svg"
}
},
{
"command": "gitlens.views.fetch",
"title": "Fetch",
"category": "GitLens",
@ -4258,6 +4267,11 @@
"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"

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

@ -471,6 +471,10 @@ 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 },

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

@ -522,6 +522,12 @@ 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);
}

+ 21
- 0
src/views/viewCommands.ts View File

@ -114,6 +114,7 @@ export class ViewCommands {
commands.registerCommand('gitlens.views.openChangedFileRevisions', this.openChangedFileRevisions, this);
commands.registerCommand('gitlens.views.applyChanges', this.applyChanges, this);
commands.registerCommand('gitlens.views.checkout', this.checkout, this);
commands.registerCommand('gitlens.views.addRemote', this.addRemote, this);
commands.registerCommand('gitlens.views.stageDirectory', this.stageDirectory, this);
commands.registerCommand('gitlens.views.stageFile', this.stageFile, this);
@ -285,6 +286,26 @@ export class ViewCommands {
return Container.git.checkout(node.repoPath, node.ref);
}
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
});
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
});
if (remoteUrl === undefined || remoteUrl.length === 0) return undefined;
return Container.git.addRemote(node.repo.path, branchName, remoteUrl);
}
private closeRepository(node: RepositoryNode) {
if (!(node instanceof RepositoryNode)) return;

Loading…
Cancel
Save