Skip to content

Commit 160b441

Browse files
committed
chore: add GIT_OBJECT_TYPE_COMMIT constant
1 parent 21caa5b commit 160b441

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/proxy/processors/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export const EMPTY_COMMIT_HASH = '0000000000000000000000000000000000000000';
33
export const FLUSH_PACKET = '0000';
44
export const PACK_SIGNATURE = 'PACK';
55
export const PACKET_SIZE = 4;
6+
export const GIT_OBJECT_TYPE_COMMIT = 1;

src/proxy/processors/push-action/parsePush.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
EMPTY_COMMIT_HASH,
1717
PACK_SIGNATURE,
1818
PACKET_SIZE,
19+
GIT_OBJECT_TYPE_COMMIT,
1920
} from '../constants';
2021

2122
const BitMask = require('bit-mask') as any;
@@ -217,14 +218,17 @@ const isBlankPersonLine = (personLine: PersonLine): boolean => {
217218

218219
/**
219220
* Parses the commit data from the contents of a pack file.
221+
*
222+
* Filters out all objects except for commits.
220223
* @param {CommitContent[]} contents - The contents of the pack file.
221224
* @return {CommitData[]} An array of commit data objects.
225+
* @see https://git-scm.com/docs/pack-format#_object_types
222226
*/
223227
const getCommitData = (contents: CommitContent[]): CommitData[] => {
224228
console.log({ contents });
225229
return lod
226230
.chain(contents)
227-
.filter({ type: 1 })
231+
.filter({ type: GIT_OBJECT_TYPE_COMMIT })
228232
.map((x: CommitContent) => {
229233
console.log({ x });
230234

0 commit comments

Comments
 (0)