feat: allow switching branches on local dbseeds

This commit is contained in:
zkldi
2022-12-09 20:39:26 +00:00
parent e0c68bff40
commit 33825e39fe
+13 -1
View File
@@ -42,6 +42,14 @@ export class DatabaseSeedsRepo {
this.shouldDestroy = shouldDestroy;
}
/**
* Switch this repository to a new branch. This operation may
* fail if there are uncommitted changes.
*/
switchBranch(newBranch: string) {
return asyncExec(`git switch '${newBranch}'`, this.baseDir);
}
private CollectionNameToPath(collectionName: SeedsCollections) {
return path.join(this.baseDir, `${collectionName}.json`);
}
@@ -224,7 +232,11 @@ export async function PullDatabaseSeeds(
: "staging"
) {
if (fetchFromLocalPath) {
return new DatabaseSeedsRepo(fetchFromLocalPath);
const local = new DatabaseSeedsRepo(fetchFromLocalPath);
await local.switchBranch(branch);
return local;
}
if (!ServerConfig.SEEDS_CONFIG) {