readCommit
Read a commit object directly
param | type [= default] | description |
---|---|---|
fs | FsClient | a file system client |
dir | string | The working tree directory path |
gitdir | string = join(dir,'.git') | The git directory path |
oid | string | The SHA-1 object id to get. Annotated tags are peeled. |
cache | object | a cache object |
return | Promise<ReadCommitResult> | Resolves successfully with a git commit object |
type ReadCommitResult = {
oid: string; // SHA-1 object id of this commit
commit: CommitObject; // the parsed commit object
payload: string; // PGP signing payload
}
A git commit object.
type CommitObject = {
message: string; // Commit message
tree: string; // SHA-1 object id of corresponding file tree
parent: Array<string>; // an array of zero or more SHA-1 object ids
author: {
name: string; // The author's name
email: string; // The author's email
timestamp: number; // UTC Unix timestamp in seconds
timezoneOffset: number; // Timezone difference from UTC in minutes
};
committer: {
name: string; // The committer's name
email: string; // The committer's email
timestamp: number; // UTC Unix timestamp in seconds
timezoneOffset: number; // Timezone difference from UTC in minutes
};
gpgsig?: string; // PGP signature (if present)
}
Example Code:
// Read a commit objectlet sha = await git.resolveRef({ fs, dir: '/tutorial', ref: 'main' })console.log(sha)let commit = await git.readCommit({ fs, dir: '/tutorial', oid: sha })console.log(commit)