Skip to content

Commit

Permalink
Merge branch 'main' into bump-ossf
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieSlome authored Nov 8, 2024
2 parents b798338 + 3dff666 commit 002b895
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/proxy/processors/push-action/blockForAuth.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const Step = require('../../actions').Step;
const { getServiceUIURL } = require('../../../service/urls');

const { GIT_PROXY_UI_PORT: uiPort } = require('../../../config/env').Vars;
const Step = require('../../actions').Step;

const exec = async (req, action) => {
const step = new Step('authBlock');
const url = getServiceUIURL(req);

const message =
'\n\n\n' +
`\x1B[32mGitProxy has received your push ✅\x1B[0m\n\n` +
'🔗 Shareable Link\n\n' +
`\x1B[34mhttp://localhost:${uiPort}/admin/push/${action.id}\x1B[0m` +
`\x1B[34m${url}/admin/push/${action.id}\x1B[0m` +
'\n\n\n';
step.setAsyncBlock(message);

Expand Down
2 changes: 1 addition & 1 deletion src/proxy/processors/push-action/pullRemote.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const exec = async (req, action) => {
}

if (!fs.existsSync(action.proxyGitPath)) {
fs.mkdirSync(action.proxyGitPath, '0777', true);
fs.mkdirSync(action.proxyGitPath, '0755', true);
}

const cmd = `git clone ${action.url} --bare`;
Expand Down
2 changes: 1 addition & 1 deletion src/service/routes/repo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const express = require('express');
const router = new express.Router();
const db = require('../../db');
const { getProxyURL } = require('../proxyURL');
const { getProxyURL } = require('../urls');

router.get('/', async (req, res) => {
const proxyURL = getProxyURL(req);
Expand Down
7 changes: 7 additions & 0 deletions src/service/proxyURL.js → src/service/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@ module.exports = {
);
return config.getDomains().proxy ?? defaultURL;
},
getServiceUIURL: (req) => {
const defaultURL = `${req.protocol}://${req.headers.host}`.replace(
`:${PROXY_HTTP_PORT}`,
`:${UI_PORT}`,
);
return config.getDomains().service ?? defaultURL;
},
};
2 changes: 1 addition & 1 deletion test/proxyURL.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const chai = require('chai');
const sinon = require('sinon');
const express = require('express');
const chaiHttp = require('chai-http');
const { getProxyURL } = require('../src/service/proxyURL');
const { getProxyURL } = require('../src/service/urls');
const config = require('../src/config');

chai.use(chaiHttp);
Expand Down

0 comments on commit 002b895

Please sign in to comment.