tiny-commit-walker
Version:
tiny commit walker
57 lines (56 loc) • 1.73 kB
TypeScript
import { Packs } from './pack';
export interface Author {
readonly name: string;
readonly email: string;
readonly date: Date;
readonly timezoneOffset: number;
}
export interface Committer extends Author {
}
export declare class Commit {
readonly gitDir: string;
readonly hash: string;
readonly data: string;
private _packs;
readonly parentHashes: string[];
readonly type: string;
readonly size: number;
readonly body: string;
private _author;
private _committer;
readonly message: string;
constructor(gitDir: string, hash: string, data: string, _packs?: Packs | undefined);
private _parseAuthorOrCommitter(type);
readonly author: Author;
readonly committer: Author;
readonly hasParents: boolean;
readonly isMergeCommit: boolean;
readonly baseParentHash: string;
readonly mergedParentHashes: string[];
/**
* Get parent commit by a parent hash.
*
* ```ts
* // default is the baseParentHash.
* let parentCommit = await commit.walk();
*
* // or set a parent hash manually.
* parentCommit = await commit.walk(commit.parentHash[1]);
*
* // same mean
* parentCommit = await commit.walk(1);
* ```
*/
walk(parentHash?: number | string): Promise<Commit>;
/**
* Get parent commit by a parent hash sync.
*
* ```ts
* let parentCommit = commit.walkSync();
* parentCommit = commit.walkSync(commit.parentHash[1]);
* ```
*/
walkSync(parentHash?: number | string): Commit;
static readCommit(gitDir: string, hash: string, packs?: Packs): Promise<Commit>;
static readCommitSync(gitDir: string, hash: string, packs?: Packs): Commit;
}