Compare commits

..

2 Commits

Author SHA1 Message Date
6cc245ae7e 1.0.11 2019-06-20 14:19:54 +02:00
1377fb6eb7 fix(core): update 2019-06-20 14:19:54 +02:00
3 changed files with 18 additions and 4 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartgit", "name": "@pushrocks/smartgit",
"version": "1.0.10", "version": "1.0.11",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartgit", "name": "@pushrocks/smartgit",
"version": "1.0.10", "version": "1.0.11",
"description": "smart wrapper for nodegit", "description": "smart wrapper for nodegit",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",

View File

@ -42,13 +42,27 @@ export class GitRepo {
public async listRemotes(): Promise<string[]> { public async listRemotes(): Promise<string[]> {
return this.nodegitRepo.getRemotes(); return this.nodegitRepo.getRemotes();
} }
public async ensureRemote(remoteNameArg: string, remoteUrlArg: string): Promise<void> {
const existingUrl = await this.getUrlForRemote(remoteNameArg);
if (existingUrl === remoteUrlArg) {
return;
}
if (existingUrl) {
await plugins.nodegit.Remote.delete(this.nodegitRepo, remoteNameArg);
}
await plugins.nodegit.Remote.create(this.nodegitRepo, remoteNameArg, remoteUrlArg);
}
/** /**
* gets the url for a specific remote * gets the url for a specific remote
*/ */
public async getUrlForRemote(remoteName: string) { public async getUrlForRemote(remoteName: string): Promise<string> {
const ngRemote = await this.nodegitRepo.getRemote(remoteName); const ngRemote = await this.nodegitRepo.getRemote(remoteName);
return ngRemote.url; if (ngRemote) {
return ngRemote.url();
} else {
return null;
}
} }
public async pushBranchToRemote(branchName: string, remoteName: string) { public async pushBranchToRemote(branchName: string, remoteName: string) {