Skip to content

Commit e2d1139

Browse files
committed
fix: pip-compile-multi alters .in file with full path
1 parent 5c282a4 commit e2d1139

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/github.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,7 @@ class Github {
435435
}
436436

437437
async fixReqsFile(filePath) {
438-
// Somehow pip-compile-multi generates replaces the '-e file:.' with a hard-coded local path
439-
// hoping they fix it in the future. In the meantime we can fix it here.
438+
// Fixes '-e file:.' lines and strips absolute paths before 'requirements/' in '# -r' lines
440439
try {
441440
// Read the file
442441
const content = await fs.promises.readFile(filePath, { encoding: 'utf-8' });
@@ -448,10 +447,18 @@ class Github {
448447
needsUpdate = true;
449448
return '-e file:.';
450449
}
450+
if (line.trim().startsWith('# -r ')) {
451+
// Replace everything before 'requirements/' with '# -r requirements/'
452+
const fixedLine = line.replace(/# -r .*?requirements\//, '# -r requirements/');
453+
if (fixedLine !== line) {
454+
needsUpdate = true;
455+
return fixedLine;
456+
}
457+
}
451458
return line;
452459
});
453460

454-
// Join the lines back and write to the file
461+
// Join the lines back and write to the file if any changes were made
455462
if (needsUpdate) {
456463
await fs.promises.writeFile(filePath, updatedLines.join('\n'), { encoding: 'utf-8' });
457464
}

0 commit comments

Comments
 (0)