Skip to content

Commit 1cab73c

Browse files
committed
chore: address requested changes
1 parent 088ffc4 commit 1cab73c

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,14 @@ const exec = async (req: any, action: Action): Promise<Action> => {
4747
const isSubset = [...packCommits].every((sha) => introducedCommits.has(sha));
4848
if (!isSubset) {
4949
// build detailed lists
50-
const unreferenced = [...packCommits].filter((sha) => !introducedCommits.has(sha));
51-
const referenced = [...packCommits].filter((sha) => introducedCommits.has(sha));
50+
const [referenced, unreferenced] = [...packCommits].reduce<[string[], string[]]>(
51+
([ref, unref], sha) =>
52+
introducedCommits.has(sha) ? [[...ref, sha], unref] : [ref, [...unref, sha]],
53+
[[], []],
54+
);
5255

53-
step.log(`Referenced commits: ${referenced.length}`);
54-
step.log(`Unreferenced commits: ${unreferenced.length}`);
56+
step.log(`Referenced commits: ${referenced.length}`);
57+
step.log(`Unreferenced commits: ${unreferenced.length}`);
5558

5659
step.setError(
5760
`Unreferenced commits in pack (${unreferenced.length}): ${unreferenced.join(', ')}`,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ const exec = async (req: any, action: Action) => {
2222
cwd: action.proxyGitPath,
2323
input: req.body,
2424
});
25-
const after = new Set(fs.readdirSync(packDir).filter((f) => f.endsWith('.idx')));
26-
27-
const newIdxFiles = [...after].filter((f) => !before.has(f));
25+
const newIdxFiles = [
26+
...new Set(fs.readdirSync(packDir).filter((f) => f.endsWith('.idx') && !before.has(f))),
27+
];
2828
action.newIdxFiles = newIdxFiles;
2929
step.log(`new idx files: ${newIdxFiles}`);
3030

test/checkHiddenCommit.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('checkHiddenCommits.exec', () => {
3232
sandbox.restore();
3333
});
3434

35-
it.only('reports all commits unreferenced and sets error=true', async () => {
35+
it('reports all commits unreferenced and sets error=true', async () => {
3636
const COMMIT_1 = 'deadbeef';
3737
const COMMIT_2 = 'cafebabe';
3838

@@ -51,15 +51,15 @@ describe('checkHiddenCommits.exec', () => {
5151
await checkHidden({ body: '' }, action);
5252

5353
const step = action.steps.find((s) => s.stepName === 'checkHiddenCommits');
54-
expect(step.logs).to.include(`checkHiddenCommits - Referenced commits: 0`);
55-
expect(step.logs).to.include(`checkHiddenCommits - Unreferenced commits: 2`);
54+
expect(step.logs).to.include(`checkHiddenCommits - Referenced commits: 0`);
55+
expect(step.logs).to.include(`checkHiddenCommits - Unreferenced commits: 2`);
5656
expect(step.logs).to.include(
5757
`checkHiddenCommits - Unreferenced commits in pack (2): ${COMMIT_1}, ${COMMIT_2}`,
5858
);
5959
expect(action.error).to.be.true;
6060
});
6161

62-
it.only('mixes referenced & unreferenced correctly', async () => {
62+
it('mixes referenced & unreferenced correctly', async () => {
6363
const COMMIT_1 = 'deadbeef';
6464
const COMMIT_2 = 'cafebabe';
6565

@@ -78,15 +78,15 @@ describe('checkHiddenCommits.exec', () => {
7878
await checkHidden({ body: '' }, action);
7979

8080
const step = action.steps.find((s) => s.stepName === 'checkHiddenCommits');
81-
expect(step.logs).to.include('checkHiddenCommits - Referenced commits: 1');
82-
expect(step.logs).to.include('checkHiddenCommits - Unreferenced commits: 1');
81+
expect(step.logs).to.include('checkHiddenCommits - Referenced commits: 1');
82+
expect(step.logs).to.include('checkHiddenCommits - Unreferenced commits: 1');
8383
expect(step.logs).to.include(
8484
`checkHiddenCommits - Unreferenced commits in pack (1): ${COMMIT_2}`,
8585
);
8686
expect(action.error).to.be.true;
8787
});
8888

89-
it.only('reports all commits referenced and sets error=false', async () => {
89+
it('reports all commits referenced and sets error=false', async () => {
9090
// 1) rev-list → introduces both commits
9191
// 2) verify-pack → the pack contains the same two commits
9292
spawnSyncStub.onFirstCall().returns({ stdout: 'deadbeef\ncafebabe\n' }).onSecondCall().returns({
@@ -106,7 +106,7 @@ describe('checkHiddenCommits.exec', () => {
106106
expect(action.error).to.be.false;
107107
});
108108

109-
it.only('throws if commitFrom or commitTo is missing', async () => {
109+
it('throws if commitFrom or commitTo is missing', async () => {
110110
delete action.commitFrom;
111111

112112
try {

0 commit comments

Comments
 (0)