@@ -12,6 +12,12 @@ if (!fs.existsSync(dir)) {
12
12
fs . mkdirSync ( dir , { recursive : true } ) ;
13
13
}
14
14
15
+ /**
16
+ * Executes the parsing of a push request.
17
+ * @param {* } req - The request object containing the push data.
18
+ * @param {Action } action - The action object to be modified.
19
+ * @return {Promise<Action> } The modified action object.
20
+ */
15
21
async function exec ( req : any , action : Action ) : Promise < Action > {
16
22
const step = new Step ( 'parsePackFile' ) ;
17
23
@@ -67,6 +73,11 @@ async function exec(req: any, action: Action): Promise<Action> {
67
73
return action ;
68
74
} ;
69
75
76
+ /**
77
+ * Parses the commit data from the contents of a pack file.
78
+ * @param {CommitContent[] } contents - The contents of the pack file.
79
+ * @return {* } An array of commit data objects.
80
+ */
70
81
const getCommitData = ( contents : CommitContent [ ] ) => {
71
82
console . log ( { contents } ) ;
72
83
return lod
@@ -167,6 +178,11 @@ const getCommitData = (contents: CommitContent[]) => {
167
178
. value ( ) ;
168
179
} ;
169
180
181
+ /**
182
+ * Gets the metadata from a pack file.
183
+ * @param {Buffer } buffer - The buffer containing the pack file data.
184
+ * @return {Array } An array containing the metadata and the remaining buffer.
185
+ */
170
186
const getPackMeta = ( buffer : Buffer ) => {
171
187
const sig = buffer . slice ( 0 , 4 ) . toString ( 'utf-8' ) ;
172
188
const version = buffer . readUIntBE ( 4 , 4 ) ;
@@ -181,6 +197,12 @@ const getPackMeta = (buffer: Buffer) => {
181
197
return [ meta , buffer . slice ( 12 ) ] ;
182
198
} ;
183
199
200
+ /**
201
+ * Gets the contents of a pack file.
202
+ * @param {Buffer } buffer - The buffer containing the pack file data.
203
+ * @param {number } entries - The number of entries in the pack file.
204
+ * @return {CommitContent[] } An array of commit content objects.
205
+ */
184
206
const getContents = ( buffer : Buffer | CommitContent [ ] , entries : number ) => {
185
207
const contents = [ ] ;
186
208
@@ -196,6 +218,11 @@ const getContents = (buffer: Buffer | CommitContent[], entries: number) => {
196
218
return contents ;
197
219
} ;
198
220
221
+ /**
222
+ * Converts an array of bits to an integer.
223
+ * @param {boolean[] } bits - The array of bits.
224
+ * @return {number } The integer value.
225
+ */
199
226
const getInt = ( bits : boolean [ ] ) => {
200
227
let strBits = '' ;
201
228
@@ -207,6 +234,12 @@ const getInt = (bits: boolean[]) => {
207
234
return parseInt ( strBits , 2 ) ;
208
235
} ;
209
236
237
+ /**
238
+ * Gets the content of a pack file entry.
239
+ * @param {number } item - The index of the entry.
240
+ * @param {Buffer } buffer - The buffer containing the pack file data.
241
+ * @return {Array } An array containing the content object and the next buffer.
242
+ */
210
243
const getContent = ( item : number , buffer : Buffer ) => {
211
244
// FIRST byte contains the type and some of the size of the file
212
245
// a MORE flag -8th byte tells us if there is a subsequent byte
@@ -273,6 +306,11 @@ const getContent = (item: number, buffer: Buffer) => {
273
306
return [ result , nextBuffer ] ;
274
307
} ;
275
308
309
+ /**
310
+ * Unzips the content of a buffer.
311
+ * @param {Buffer } buf - The buffer containing the zipped content.
312
+ * @return {Array } An array containing the unzipped content and the size of the deflated content.
313
+ */
276
314
const unpack = ( buf : Buffer ) => {
277
315
// Unzip the content
278
316
const inflated = zlib . inflateSync ( buf ) ;
@@ -284,6 +322,11 @@ const unpack = (buf: Buffer) => {
284
322
return [ inflated . toString ( 'utf8' ) , deflated . length ] ;
285
323
} ;
286
324
325
+ /**
326
+ * Parses the packet lines from a buffer into an array of strings.
327
+ * @param {Buffer } buffer - The buffer containing the packet data.
328
+ * @return {string[] } An array of parsed lines.
329
+ */
287
330
const parsePacketLines = ( buffer : Buffer ) : string [ ] => {
288
331
const lines : string [ ] = [ ] ;
289
332
let offset = 0 ;
0 commit comments