add function to get commit detail

This commit is contained in:
Peter Evans 2024-08-07 15:31:21 +01:00
parent 9cd16daf06
commit 029414bc07
5 changed files with 111 additions and 2 deletions

View file

@ -0,0 +1,22 @@
import {GitCommandManager, Commit} from '../lib/git-command-manager'
const REPO_PATH = '/git/local/repos/test-base'
describe('git-command-manager integration tests', () => {
let git: GitCommandManager
beforeAll(async () => {
git = await GitCommandManager.create(REPO_PATH)
await git.checkout('main')
})
it('tests getCommit', async () => {
const parent = await git.getCommit('HEAD^')
const commit = await git.getCommit('HEAD')
expect(parent.subject).toEqual('initial commit')
expect(parent.changes).toEqual([{"mode": "100644", "status": "A", "path": "README.md"}])
expect(commit.subject).toEqual('add sparkles')
expect(commit.parents[0]).toEqual(parent.sha)
expect(commit.changes).toEqual([{"mode": "100644", "status": "M", "path": "README.md"}])
})
})