From df806dda764ff722742301042ab88b3d91f472c5 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 26 May 2021 18:50:23 +0200 Subject: Switched web framework from Express.js to Fastify & improved the backend --- src/api/git.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/api/git.js') diff --git a/src/api/git.js b/src/api/git.js index dad7cc6..756136b 100644 --- a/src/api/git.js +++ b/src/api/git.js @@ -231,7 +231,21 @@ async function getCommit(base_dir, repo_name, commit_oid) }; } +async function doesCommitExist(base_dir, repo_name, commit_oid) +{ + const repo = await git.Repository.openBare(`${base_dir}/${repo_name}`) + + try { + await repo.getCommit(commit_oid); + return true; + } + catch { + return false; + } +} + module.exports.getLog = getLog; module.exports.getRepos = getRepos; module.exports.getRepoFile = getRepoFile; -module.exports.getCommit = getCommit; \ No newline at end of file +module.exports.getCommit = getCommit; +module.exports.doesCommitExist = doesCommitExist; \ No newline at end of file -- cgit v1.2.3-18-g5258