UNPKG

4.42 kBTypeScriptView Raw
1import { EventEmitter } from 'events';
2
3import { Repository } from './repository';
4import { Signature } from './signature';
5import { Oid } from './oid';
6import { Buf } from './buf';
7import { Object } from './object';
8import { Tree } from './tree';
9import { TreeEntry } from './tree-entry';
10import { Diff } from './diff';
11import { Error } from './error';
12
13export interface HistoryEventEmitter extends EventEmitter {
14 start(): void;
15}
16
17export class Commit {
18 static create(
19 repo: Repository,
20 updateRef: string,
21 author: Signature,
22 committer: Signature,
23 messageEncoding: string,
24 message: string,
25 tree: Tree,
26 parentCount: number,
27 parents: any[],
28 ): Oid;
29 static createV(
30 id: Oid,
31 repo: Repository,
32 updateRef: string,
33 author: Signature,
34 committer: Signature,
35 messageEncoding: string,
36 message: string,
37 tree: Tree,
38 parentCount: number,
39 ): number;
40 /**
41 * Retrieves the commit pointed to by the oid
42 *
43 *
44 */
45 static lookup(repo: Repository, id: string | Oid | Commit): Promise<Commit>;
46 static lookupPrefix(repo: Repository, id: Oid, len: number): Promise<Commit>;
47 static createWithSignature(
48 repo: Repository,
49 commitContent: string,
50 signature: string,
51 signatureField: string,
52 ): Promise<Oid>;
53
54 amend(
55 updateRef: string,
56 author: Signature,
57 committer: Signature,
58 messageEncoding: string,
59 message: string,
60 tree: Tree | Oid,
61 ): Promise<Oid>;
62 amendWithSignature(
63 updateRef: string,
64 author: Signature,
65 committer: Signature,
66 messageEncoding: string,
67 message: string,
68 tree: Tree | Oid,
69 onSignature: (
70 data: string,
71 ) =>
72 | Promise<{ code: Error.CODE; field?: string | undefined; signedData: string }>
73 | { code: Error.CODE; field?: string | undefined; signedData: string },
74 ): Promise<Oid>;
75 author(): Signature;
76 committer(): Signature;
77
78 free(): void;
79 headerField(field: string): Promise<Buf>;
80 id(): Oid;
81 message(): string;
82 messageEncoding(): string;
83 messageRaw(): string;
84 nthGenAncestor(n: number): Promise<Commit>;
85 owner(): Repository;
86 parent(n: number): Promise<Commit>;
87 parentId(n: number): Oid;
88 parentcount(): number;
89 rawHeader(): string;
90 summary(): string;
91 time(): number;
92 timeOffset(): number;
93 tree(treeOut: Tree): number;
94 treeId(): Oid;
95 /**
96 * Retrieve the SHA.
97 *
98 *
99 */
100 sha(): string;
101 /**
102 * Retrieve the commit time as a unix timestamp.
103 *
104 *
105 */
106 timeMs(): number;
107 /**
108 * Retrieve the commit time as a Date object.
109 *
110 *
111 */
112 date(): Date;
113 /**
114 * Get the tree associated with this commit.
115 *
116 *
117 */
118 getTree(): Promise<Tree>;
119 /**
120 * Retrieve the entry represented by path for this commit. Path must be relative to repository root.
121 *
122 *
123 */
124 getEntry(path: string): Promise<TreeEntry>;
125 /**
126 * Walk the history from this commit backwards.
127 * An EventEmitter is returned that will emit a "commit" event for each commit in the history, and one "end"
128 * event when the walk is completed. Don't forget to call start() on the returned EventEmitter.
129 *
130 *
131 */
132 history(): HistoryEventEmitter;
133 /**
134 * Retrieve the commit's parents as commit objects.
135 *
136 *
137 */
138 getParents(limit: number, callback?: Function): Promise<Commit[]>;
139 /**
140 * Retrieve the commit's parent shas.
141 *
142 *
143 */
144 parents(): Oid[];
145 /**
146 * Generate an array of diff trees showing changes between this commit and its parent(s).
147 *
148 *
149 */
150 getDiff(callback?: Function): Promise<Diff[]>;
151 /**
152 * Generate an array of diff trees showing changes between this commit and its parent(s).
153 *
154 *
155 */
156 getDiffWithOptions(options: Object, callback?: Function): Promise<Diff[]>;
157 /**
158 * The sha of this commit
159 *
160 *
161 */
162 toString(): string;
163 dup(): Promise<Commit>;
164 /**
165 * consists of a summary
166 *
167 *
168 */
169 body(): string;
170
171 getSignature(field?: string): Promise<{
172 signature: string;
173 signedData: string;
174 }>;
175}