11import { Action , Step } from '../../actions' ;
22import zlib from 'zlib' ;
3- import fs from 'fs' ;
4- import path from 'path' ;
53import lod from 'lodash' ;
64import { CommitContent } from '../types' ;
75const BitMask = require ( 'bit-mask' ) as any ;
86
9- const dir = path . resolve ( __dirname , './.tmp' ) ;
10-
11- if ( ! fs . existsSync ( dir ) ) {
12- fs . mkdirSync ( dir , { recursive : true } ) ;
13- }
14-
157/**
168 * Executes the parsing of a push request.
179 * @param {* } req - The request object containing the push data.
@@ -29,7 +21,6 @@ async function exec(req: any, action: Action): Promise<Action> {
2921 return action ;
3022 }
3123 const [ packetLines , packDataOffset ] = parsePacketLines ( req . body ) ;
32-
3324 const refUpdates = packetLines . filter ( ( line ) => line . includes ( 'refs/heads/' ) ) ;
3425
3526 if ( refUpdates . length !== 1 ) {
@@ -68,15 +59,16 @@ async function exec(req: any, action: Action): Promise<Action> {
6859 const contents = getContents ( contentBuff as any , meta . entries as number ) ;
6960
7061 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 ;
7470 }
7571
76- const user = action . commitData [ action . commitData . length - 1 ] . committer ;
77- console . log ( `Push Request received from user ${ user } ` ) ;
78- action . user = user ;
79-
8072 step . content = {
8173 meta : meta ,
8274 } ;
@@ -235,6 +227,7 @@ const getContents = (buffer: Buffer | CommitContent[], entries: number) => {
235227 for ( let i = 0 ; i < entries ; i ++ ) {
236228 try {
237229 const [ content , nextBuffer ] = getContent ( i , buffer as Buffer ) ;
230+ console . log ( { content, nextBuffer } ) ;
238231 buffer = nextBuffer as Buffer ;
239232 contents . push ( content ) ;
240233 } catch ( e ) {
0 commit comments