Skip to content
2 changes: 0 additions & 2 deletions src/proxy/processors/push-action/checkAuthorEmails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ const isEmailAllowed = (email: string): boolean => {
};

const exec = async (req: any, action: Action): Promise<Action> => {
console.log({ req, action });

const step = new Step('checkAuthorEmails');

const uniqueAuthorEmails = [
Expand Down
2 changes: 0 additions & 2 deletions src/proxy/processors/push-action/checkCommitMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ const isMessageAllowed = (commitMessage: string): boolean => {

// Execute if the repo is approved
const exec = async (req: any, action: Action): Promise<Action> => {
console.log({ req, action });

const step = new Step('checkCommitMessages');

const uniqueCommitMessages = [...new Set(action.commitData?.map((commit) => commit.message))];
Expand Down
14 changes: 5 additions & 9 deletions src/proxy/processors/push-action/pullRemote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ const exec = async (req: any, action: Action): Promise<Action> => {
const step = new Step('pullRemote');

try {
action.proxyGitPath = `${dir}/${action.timestamp}`;

step.log(`Creating folder ${action.proxyGitPath}`);
action.proxyGitPath = `${dir}/${action.id}`;

if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}

if (!fs.existsSync(action.proxyGitPath)) {
step.log(`Creating folder ${action.proxyGitPath}`);
fs.mkdirSync(action.proxyGitPath, 0o755);
}

Expand All @@ -33,15 +32,12 @@ const exec = async (req: any, action: Action): Promise<Action> => {
fs,
http: gitHttpClient,
url: action.url,
onAuth: () => ({
username,
password,
}),
dir: `${action.proxyGitPath}/${action.repoName}`,
onAuth: () => ({ username, password }),
singleBranch: true,
depth: 1,
});

console.log('Clone Success: ', action.url);

step.log(`Completed ${cmd}`);
step.setContent(`Completed ${cmd}`);
} catch (e: any) {
Expand Down
6 changes: 4 additions & 2 deletions src/proxy/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ const getRouter = async () => {
proxyReqOptDecorator: proxyReqOptDecorator,
proxyReqBodyDecorator: proxyReqBodyDecorator,
proxyErrorHandler: proxyErrorHandler,
}),
stream: true,
} as any),
);
});

Expand All @@ -229,7 +230,8 @@ const getRouter = async () => {
proxyReqOptDecorator: proxyReqOptDecorator,
proxyReqBodyDecorator: proxyReqBodyDecorator,
proxyErrorHandler: proxyErrorHandler,
});
stream: true,
} as any);

console.log('proxy keys registered: ', JSON.stringify(proxyKeys));

Expand Down
2 changes: 0 additions & 2 deletions src/service/routes/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ router.post('/:id/reject', async (req, res) => {
});

router.post('/:id/authorise', async (req, res) => {
console.log({ req });

const questions = req.body.params?.attestation;
console.log({ questions });

Expand Down
10 changes: 6 additions & 4 deletions test/processors/clearBareClone.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ const { Action } = require('../../src/proxy/actions/Action');
chai.should();

const expect = chai.expect;

const actionId = '123__456';
const timestamp = Date.now();

describe('clear bare and local clones', async () => {
it('pull remote generates a local .remote folder', async () => {
const action = new Action('123', 'type', 'get', timestamp, 'finos/git-proxy.git');
const action = new Action(actionId, 'type', 'get', timestamp, 'finos/git-proxy.git');
action.url = 'https://github.com/finos/git-proxy.git';

const authorization = `Basic ${Buffer.from('JamieSlome:test').toString('base64')}`;
Expand All @@ -24,14 +26,14 @@ describe('clear bare and local clones', async () => {
action,
);

expect(fs.existsSync(`./.remote/${timestamp}`)).to.be.true;
expect(fs.existsSync(`./.remote/${actionId}`)).to.be.true;
}).timeout(20000);

it('clear bare clone function purges .remote folder and specific clone folder', async () => {
const action = new Action('123', 'type', 'get', timestamp, 'finos/git-proxy.git');
const action = new Action(actionId, 'type', 'get', timestamp, 'finos/git-proxy.git');
await clearBareClone(null, action);
expect(fs.existsSync(`./.remote`)).to.throw;
expect(fs.existsSync(`./.remote/${timestamp}`)).to.throw;
expect(fs.existsSync(`./.remote/${actionId}`)).to.throw;
});

afterEach(() => {
Expand Down
Loading