fix GitUpdater maybe
This commit is contained in:
+13
-10
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user