diff options
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 |