aboutsummaryrefslogtreecommitdiff
path: root/packages/server/src/git/branch.ts
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-08-19 15:18:03 +0200
committerHampusM <hampus@hampusmat.com>2021-08-19 15:18:03 +0200
commit70c8c22c52ae0d429321f58b8a787ef4b157af3f (patch)
treefa17b01eb03e7c04486d33436d4e40985fe04201 /packages/server/src/git/branch.ts
parent1e5309e7f842491a24e4c7a61ce1f69b695dfe17 (diff)
Moved the implementations of getting all branches or tags to their respective classes
Diffstat (limited to 'packages/server/src/git/branch.ts')
-rw-r--r--packages/server/src/git/branch.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/server/src/git/branch.ts b/packages/server/src/git/branch.ts
index 85f83be..0819f3c 100644
--- a/packages/server/src/git/branch.ts
+++ b/packages/server/src/git/branch.ts
@@ -61,4 +61,16 @@ export class Branch extends Reference {
.then(() => true)
.catch(() => false);
}
+
+ /**
+ * Returns all of a repository's branches
+ *
+ * @param owner - An instance of a repository
+ * @returns An array of branch instances
+ */
+ public static async getAll(owner: Repository): Promise<Branch[]> {
+ const references = await owner.ng_repository.getReferences();
+
+ return references.filter(ref => ref.isBranch()).map(ref => new Branch(owner, ref));
+ }
} \ No newline at end of file