fix GitUpdater maybe

This commit is contained in:
peter
2019-08-20 21:29:39 +02:00
parent e66b86c9ae
commit 3d234b24d9
+13 -10
View File
@@ -34,29 +34,32 @@ export type RepoFolderStatus = {
remote?: string
}
export class GitUpdater{
export class GitUpdater2{
private repo: git.SimpleGit
constructor(private readonly folderPath:string){
}
async getStatus():Promise<RepoFolderStatus>{
try {
await fs.access(this.folderPath);
await fs.access(this.folderPath);
}
catch (e) {
try{
await gyt.gitDescribe(this.folderPath, { match: "*" });
}catch(e2){
return { exists: false, empty: true, isRepo: false };
}
return { exists: false, empty: true, isRepo: false };
}
const files = await fs.readdir(this.folderPath)
const empty:boolean = files.length === 0
try{
await fs.access(this.folderPath+"/.git");
}catch(e2){
return { exists: true, empty: empty, isRepo: false };
}
if(!this.repo){
this.repo = git(this.folderPath)
}
const files = await fs.readdir(this.folderPath)
const empty:boolean = files.length === 0
await this.repo.fetch("origin", "master", {
"--tags": null
@@ -108,4 +111,4 @@ export class GitUpdater{
await this.repo.checkout(tag);
return await this.getStatus();
}
}
}