aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/server/src/git/branch.ts12
-rw-r--r--packages/server/src/git/repository.ts6
-rw-r--r--packages/server/src/git/tag.ts12
3 files changed, 26 insertions, 4 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
diff --git a/packages/server/src/git/repository.ts b/packages/server/src/git/repository.ts
index 53245be..199985c 100644
--- a/packages/server/src/git/repository.ts
+++ b/packages/server/src/git/repository.ts
@@ -146,8 +146,7 @@ export class Repository {
* @returns An array of branch instances
*/
public async branches(): Promise<Branch[]> {
- const references = await this.ng_repository.getReferences();
- return references.filter(ref => ref.isBranch()).map(ref => new Branch(this, ref));
+ return Branch.getAll(this);
}
/**
@@ -156,8 +155,7 @@ export class Repository {
* @returns An array of tag instances
*/
public async tags(): Promise<Tag[]> {
- const references = await this.ng_repository.getReferences();
- return references.filter(ref => ref.isTag()).map(ref => new Tag(this, ref));
+ return Tag.getAll(this);
}
/**
diff --git a/packages/server/src/git/tag.ts b/packages/server/src/git/tag.ts
index 6c61a65..7d8c5dc 100644
--- a/packages/server/src/git/tag.ts
+++ b/packages/server/src/git/tag.ts
@@ -96,4 +96,16 @@ export class Tag extends Reference {
return new Tag(owner, reference);
}
+
+ /**
+ * Returns all of a repository's tags
+ *
+ * @param owner - An instance of a repository
+ * @returns An array of tag instances
+ */
+ public static async getAll(owner: Repository): Promise<Tag[]> {
+ const references = await owner.ng_repository.getReferences();
+
+ return references.filter(ref => ref.isTag()).map(ref => new Tag(owner, ref));
+ }
} \ No newline at end of file