Skip to content

Commit 6b21c1c

Browse files
committed
chore: add constants and replace in code
1 parent 95d1d90 commit 6b21c1c

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/proxy/processors/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const BRANCH_PREFIX = 'refs/heads/';
2+
export const EMPTY_COMMIT_HASH = '0000000000000000000000000000000000000000';
3+
export const FLUSH_PACKET = '0000';
4+
export const PACK_SIGNATURE = 'PACK';
5+
export const PACKET_SIZE = 4;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Action, Step } from '../../actions';
22
import simpleGit from 'simple-git';
33

4+
import { EMPTY_COMMIT_HASH } from '../constants';
5+
46
const exec = async (req: any, action: Action): Promise<Action> => {
57
const step = new Step('diff');
68

@@ -18,8 +20,8 @@ const exec = async (req: any, action: Action): Promise<Action> => {
1820
return action;
1921
}
2022

21-
if (action.commitFrom === '0000000000000000000000000000000000000000') {
22-
if (action.commitData[0].parent !== '0000000000000000000000000000000000000000') {
23+
if (action.commitFrom === EMPTY_COMMIT_HASH) {
24+
if (action.commitData[0].parent !== EMPTY_COMMIT_HASH) {
2325
commitFrom = `${action.commitData[action.commitData.length - 1].parent}`;
2426
}
2527
} else {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Action, Step } from '../../actions';
22
import { validateUser } from './checkUserPushPermission';
33
import simpleGit from 'simple-git';
44

5+
import { EMPTY_COMMIT_HASH } from '../constants';
6+
57
const exec = async (req: any, action: Action): Promise<Action> => {
68
const step = new Step('getMissingData');
79

@@ -31,7 +33,7 @@ const exec = async (req: any, action: Action): Promise<Action> => {
3133
});
3234
console.log(`Updated commitData:`, { commitData: action.commitData });
3335

34-
if (action.commitFrom === '0000000000000000000000000000000000000000') {
36+
if (action.commitFrom === EMPTY_COMMIT_HASH) {
3537
action.commitFrom = action.commitData[action.commitData.length - 1].parent;
3638
}
3739
const user = action.commitData[action.commitData.length - 1].committer;

0 commit comments

Comments
 (0)