diff options
| author | HampusM <hampus@hampusmat.com> | 2021-05-26 18:50:23 +0200 | 
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2021-05-26 18:50:23 +0200 | 
| commit | df806dda764ff722742301042ab88b3d91f472c5 (patch) | |
| tree | 4fc53caa4dc6a3acc3e61ebff664da56af9a464d /src/api/git.js | |
| parent | 446b4d8ccc50555a3d9d47237b5511986ad16fe6 (diff) | |
Switched web framework from Express.js to Fastify & improved the backend
Diffstat (limited to 'src/api/git.js')
| -rw-r--r-- | src/api/git.js | 16 | 
1 files changed, 15 insertions, 1 deletions
| 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 | 
