Skip to content

Commit 1fd86ac

Browse files
committed
feat: track new pack .idx files via before/after snapshots
1 parent 334c967 commit 1fd86ac

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
1+
import path from 'path';
12
import { Action, Step } from '../../actions';
23
import { spawnSync } from 'child_process';
4+
import fs from 'fs';
35

46
const exec = async (req: any, action: Action) => {
57
const step = new Step('writePack');
68
try {
79
const cmd = `git receive-pack ${action.repoName}`;
810
step.log(`executing ${cmd}`);
11+
if (!action.proxyGitPath || !action.repoName) {
12+
throw new Error('proxyGitPath and repoName must be defined');
13+
}
14+
const repoPath = path.join(action.proxyGitPath, action.repoName);
915

16+
const packDir = path.join(repoPath, '.git', 'objects', 'pack');
17+
18+
spawnSync('git', ['config', 'receive.unpackLimit', '0'], {
19+
cwd: repoPath,
20+
encoding: 'utf-8',
21+
});
22+
const before = new Set(fs.readdirSync(packDir).filter((f) => f.endsWith('.idx')));
1023
const content = spawnSync('git', ['receive-pack', action.repoName], {
1124
cwd: action.proxyGitPath,
1225
input: req.body,
13-
encoding: 'utf-8',
14-
}).stdout;
26+
});
27+
const after = new Set(fs.readdirSync(packDir).filter((f) => f.endsWith('.idx')));
28+
29+
const newIdxFiles = [...after].filter((f) => !before.has(f));
30+
action.newIdxFiles = newIdxFiles;
31+
step.log(`.idx generati da questo push: ${newIdxFiles.join(', ') || '(nessuno)'}`);
1532

16-
step.log(content);
1733
step.setContent(content);
1834
} catch (e: any) {
1935
step.setError(e.toString('utf-8'));

0 commit comments

Comments
 (0)