fix(core): update

This commit is contained in:
2022-07-31 15:18:04 +02:00
parent b46d1e19a7
commit f5617d9d45
9 changed files with 42 additions and 65 deletions

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/smartgit',
version: '2.0.3',
version: '2.0.4',
description: 'smart wrapper for nodegit'
}

View File

@@ -74,24 +74,23 @@ export class GitRepo {
*/
public async ensureRemote(remoteNameArg: string, remoteUrlArg: string): Promise<void> {
const remotes = await this.listRemotes();
const existingRemote =
remotes.find((itemArg) => itemArg.remote === remoteNameArg);
const existingRemote = remotes.find((itemArg) => itemArg.remote === remoteNameArg);
if (existingRemote) {
if (existingRemote.url !== remoteUrlArg) {
await plugins.isomorphicGit.deleteRemote({
remote: remoteNameArg,
fs: this.smartgitRef.envDeps.fs,
dir: this.repoDir
})
dir: this.repoDir,
});
} else {
return;
};
}
}
await plugins.isomorphicGit.addRemote({
remote: remoteNameArg,
fs: this.smartgitRef.envDeps.fs,
url: remoteUrlArg
})
url: remoteUrlArg,
});
}
/**
@@ -99,7 +98,7 @@ export class GitRepo {
*/
public async getUrlForRemote(remoteName: string): Promise<string> {
const remotes = await this.listRemotes();
const existingRemote = remotes.find(remoteArg => remoteArg.remote === remoteName);
const existingRemote = remotes.find((remoteArg) => remoteArg.remote === remoteName);
return existingRemote?.url;
}
@@ -108,7 +107,7 @@ export class GitRepo {
fs: this.smartgitRef.envDeps.fs,
http: this.smartgitRef.envDeps.http,
ref: branchName,
remote: remoteName
})
remote: remoteName,
});
}
}

View File

@@ -8,31 +8,33 @@ export class Smartgit {
http: any;
} = {
fs: null,
http: null
}
http: null,
};
constructor() {};
constructor() {}
public async init() {
if (this.smartenvInstance.isNode) {
this.envDeps.fs = await this.smartenvInstance.getSafeNodeModule('fs');
this.envDeps.http = await this.smartenvInstance.getSafeNodeModule('isomorphic-git/http/node/index.js');
this.envDeps.http = await this.smartenvInstance.getSafeNodeModule(
'isomorphic-git/http/node/index.js'
);
} else {
throw new Error('currently only node.js is supported.')
throw new Error('currently only node.js is supported.');
}
};
}
public async createRepoByClone(fromUrlArg: string, toDirArg: string) {
const repo = await GitRepo.fromCloningIntoDir(this, fromUrlArg, toDirArg)
};
const repo = await GitRepo.fromCloningIntoDir(this, fromUrlArg, toDirArg);
}
public async createRepoByInit(dirArg: string) {
const repo = await GitRepo.fromCreatingRepoInDir(this, dirArg);
return repo;
};
}
public async createRepoByOpen(dirArg: string) {
const repo = await GitRepo.fromOpeningRepoDir(this, dirArg);
return repo;
}
}
}