Merge pull request #27540 from backstage/rugvip/patchfix
repo-tools: new file and resolution fallback fix for generate-patch
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/repo-tools': patch
|
||||
---
|
||||
|
||||
The `generate-patch` command now properly includes newly created files in the patch.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/repo-tools': patch
|
||||
---
|
||||
|
||||
The `generate-patch` command will now fall back to always adding a `resolutions` entry, even if no matching descriptors are found.
|
||||
@@ -217,8 +217,12 @@ async function loadTrimmedRootPkg(ctx: PatchContext, query?: string) {
|
||||
}
|
||||
|
||||
return async (patchEntry?: string) => {
|
||||
for (const descriptor of descriptors) {
|
||||
resolutionsObj[descriptor] = patchEntry;
|
||||
if (descriptors.length > 0) {
|
||||
for (const descriptor of descriptors) {
|
||||
resolutionsObj[descriptor] = patchEntry;
|
||||
}
|
||||
} else {
|
||||
resolutionsObj[ctx.packageName] = patchEntry;
|
||||
}
|
||||
// We use the same patch for all versions of the package, if they don't
|
||||
// apply it might require manual intervention using the --query option
|
||||
@@ -409,6 +413,23 @@ async function generatePatchForArchives(
|
||||
cwd: patchDir,
|
||||
env: { ...process.env, ...GIT_ENV },
|
||||
});
|
||||
// Commit the base archive contents, so that we can later add all files and diff against the index
|
||||
await exec(
|
||||
'git',
|
||||
[
|
||||
'-c',
|
||||
'user.name="patcher"',
|
||||
'-c',
|
||||
'user.email="patcher@acme.org"',
|
||||
'commit',
|
||||
'-m',
|
||||
'base',
|
||||
],
|
||||
{
|
||||
cwd: patchDir,
|
||||
env: { ...process.env, ...GIT_ENV },
|
||||
},
|
||||
);
|
||||
|
||||
// Remove all existing files
|
||||
for (const path of await fs.readdir(patchDir)) {
|
||||
@@ -424,12 +445,18 @@ async function generatePatchForArchives(
|
||||
// Extract the target archive to use a target for the patch
|
||||
await tar.extract({ file: headPath, cwd: patchDir, strip: 1 });
|
||||
|
||||
// Add and diff against index, to make sure we include untracked files
|
||||
await exec('git', ['add', '.'], {
|
||||
cwd: patchDir,
|
||||
env: { ...process.env, ...GIT_ENV },
|
||||
});
|
||||
const { stdout: patch } = await exec(
|
||||
'git',
|
||||
[
|
||||
'-c',
|
||||
'core.safecrlf=false',
|
||||
'diff',
|
||||
'--cached',
|
||||
'--src-prefix=a/',
|
||||
'--dst-prefix=b/',
|
||||
'--ignore-cr-at-eol',
|
||||
|
||||
Reference in New Issue
Block a user