1
1
import { Action , Step } from '../../actions' ;
2
2
import zlib from 'zlib' ;
3
- import fs from 'fs' ;
4
- import path from 'path' ;
5
3
import lod from 'lodash' ;
6
4
import { CommitContent } from '../types' ;
7
5
const BitMask = require ( 'bit-mask' ) as any ;
8
6
9
- const dir = path . resolve ( __dirname , './.tmp' ) ;
10
-
11
- if ( ! fs . existsSync ( dir ) ) {
12
- fs . mkdirSync ( dir , { recursive : true } ) ;
13
- }
14
-
15
7
/**
16
8
* Executes the parsing of a push request.
17
9
* @param {* } req - The request object containing the push data.
@@ -29,7 +21,6 @@ async function exec(req: any, action: Action): Promise<Action> {
29
21
return action ;
30
22
}
31
23
const [ packetLines , packDataOffset ] = parsePacketLines ( req . body ) ;
32
-
33
24
const refUpdates = packetLines . filter ( ( line ) => line . includes ( 'refs/heads/' ) ) ;
34
25
35
26
if ( refUpdates . length !== 1 ) {
@@ -68,15 +59,16 @@ async function exec(req: any, action: Action): Promise<Action> {
68
59
const contents = getContents ( contentBuff as any , meta . entries as number ) ;
69
60
70
61
action . commitData = getCommitData ( contents as any ) ;
71
-
72
- if ( action . commitFrom === '0000000000000000000000000000000000000000' ) {
73
- action . commitFrom = action . commitData [ action . commitData . length - 1 ] . parent ;
62
+ if ( action . commitData . length === 0 ) {
63
+ step . log ( 'No commit data found when parsing push.' )
64
+ } else {
65
+ if ( action . commitFrom === '0000000000000000000000000000000000000000' ) {
66
+ action . commitFrom = action . commitData [ action . commitData . length - 1 ] . parent ;
67
+ }
68
+ const user = action . commitData [ action . commitData . length - 1 ] . committer ;
69
+ action . user = user ;
74
70
}
75
71
76
- const user = action . commitData [ action . commitData . length - 1 ] . committer ;
77
- console . log ( `Push Request received from user ${ user } ` ) ;
78
- action . user = user ;
79
-
80
72
step . content = {
81
73
meta : meta ,
82
74
} ;
@@ -235,6 +227,7 @@ const getContents = (buffer: Buffer | CommitContent[], entries: number) => {
235
227
for ( let i = 0 ; i < entries ; i ++ ) {
236
228
try {
237
229
const [ content , nextBuffer ] = getContent ( i , buffer as Buffer ) ;
230
+ console . log ( { content, nextBuffer } ) ;
238
231
buffer = nextBuffer as Buffer ;
239
232
contents . push ( content ) ;
240
233
} catch ( e ) {
0 commit comments