fix GitUpdater maybe
This commit is contained in:
+13
-10
@@ -34,29 +34,32 @@ export type RepoFolderStatus = {
|
|||||||
remote?: string
|
remote?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GitUpdater{
|
export class GitUpdater2{
|
||||||
private repo: git.SimpleGit
|
private repo: git.SimpleGit
|
||||||
constructor(private readonly folderPath:string){
|
constructor(private readonly folderPath:string){
|
||||||
}
|
}
|
||||||
|
|
||||||
async getStatus():Promise<RepoFolderStatus>{
|
async getStatus():Promise<RepoFolderStatus>{
|
||||||
try {
|
try {
|
||||||
await fs.access(this.folderPath);
|
await fs.access(this.folderPath);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
try{
|
return { exists: false, empty: true, isRepo: false };
|
||||||
await gyt.gitDescribe(this.folderPath, { match: "*" });
|
}
|
||||||
}catch(e2){
|
|
||||||
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){
|
if(!this.repo){
|
||||||
this.repo = git(this.folderPath)
|
this.repo = git(this.folderPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = await fs.readdir(this.folderPath)
|
|
||||||
const empty:boolean = files.length === 0
|
|
||||||
|
|
||||||
await this.repo.fetch("origin", "master", {
|
await this.repo.fetch("origin", "master", {
|
||||||
"--tags": null
|
"--tags": null
|
||||||
@@ -108,4 +111,4 @@ export class GitUpdater{
|
|||||||
await this.repo.checkout(tag);
|
await this.repo.checkout(tag);
|
||||||
return await this.getStatus();
|
return await this.getStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user