From d1a1b7dc947063aef5f8375a6a1e03246b272c84 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 18 Aug 2021 17:29:55 +0200 Subject: Implemented caching for certain API endpoints, Added documentation & made backend-fixes --- packages/server/src/git/commit.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'packages/server/src/git/commit.ts') diff --git a/packages/server/src/git/commit.ts b/packages/server/src/git/commit.ts index 6ef02ef..7062304 100644 --- a/packages/server/src/git/commit.ts +++ b/packages/server/src/git/commit.ts @@ -207,21 +207,28 @@ export class Commit { * @returns An instance of a commit */ public static async branchCommit(owner: Repository): Promise { - return new Commit(owner, await owner.ng_repository.getBranchCommit(owner.branch_name)); + return new Commit(owner, await owner.ng_repository.getBranchCommit(owner.branch)); } /** * Returns a number of commits in a repository * * @param owner - The repository which the commits are in - * @param [count=20] - The number of commits to get + * @param [amount=20] - The number of commits to get or whether or not to get all commits * @returns An array of commit instances */ - public static async getMultiple(owner: Repository, count = 20): Promise { + public static async getMultiple(owner: Repository, amount: number | boolean = 20): Promise { const walker = NodeGitRevwalk.create(owner.ng_repository); - walker.pushRef(`refs/heads/${owner.branch_name}`); + walker.pushRef(`refs/heads/${owner.branch}`); - return Promise.all((await walker.getCommits(count)).map(commit => new Commit(owner, commit))); + if(typeof amount === "boolean") { + return Promise.all((await (amount + ? walker.getCommitsUntil(() => true) + : walker.getCommits(20) + )).map(commit => new Commit(owner, commit))); + } + + return Promise.all((await walker.getCommits(amount)).map(commit => new Commit(owner, commit))); } } \ No newline at end of file -- cgit v1.2.3-18-g5258