replicate: excluding/including paths in commits
This commit is contained in:
parent
65e47ff5e6
commit
640ba3616f
|
@ -28,6 +28,16 @@ export default class Replicate extends Command {
|
||||||
patchHook: flags.string({
|
patchHook: flags.string({
|
||||||
description: 'node.js file to patch the patches',
|
description: 'node.js file to patch the patches',
|
||||||
}),
|
}),
|
||||||
|
excludePath: flags.string({
|
||||||
|
description:
|
||||||
|
'files to exclude when applying a patch (as in git apply --exclude, but always after includes)',
|
||||||
|
multiple: true,
|
||||||
|
}),
|
||||||
|
includePath: flags.string({
|
||||||
|
description:
|
||||||
|
'files to include when applying a patch (as in git apply --include, but always before excludes)',
|
||||||
|
multiple: true,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
static args = [
|
static args = [
|
||||||
|
@ -49,7 +59,15 @@ export default class Replicate extends Command {
|
||||||
|
|
||||||
const proj = getProjectConfig();
|
const proj = getProjectConfig();
|
||||||
|
|
||||||
const { destBranch, doNotCommit, remote, targetBranch, patchHook } = { ...proj, ...flags };
|
const {
|
||||||
|
destBranch,
|
||||||
|
doNotCommit,
|
||||||
|
remote,
|
||||||
|
targetBranch,
|
||||||
|
patchHook,
|
||||||
|
includePath: includePaths,
|
||||||
|
excludePath: excludePaths,
|
||||||
|
} = { ...proj, ...flags };
|
||||||
|
|
||||||
const { source, dest } = {
|
const { source, dest } = {
|
||||||
...proj,
|
...proj,
|
||||||
|
@ -97,6 +115,8 @@ export default class Replicate extends Command {
|
||||||
patchHook,
|
patchHook,
|
||||||
remote,
|
remote,
|
||||||
targetBranch,
|
targetBranch,
|
||||||
|
includePaths,
|
||||||
|
excludePaths,
|
||||||
});
|
});
|
||||||
if (repl === true) {
|
if (repl === true) {
|
||||||
// patches got applied to the branch, without pushing and creating a MR (due to --doNotCommit)
|
// patches got applied to the branch, without pushing and creating a MR (due to --doNotCommit)
|
||||||
|
|
|
@ -65,16 +65,28 @@ export default class Copykitku {
|
||||||
patchHook?: string | null;
|
patchHook?: string | null;
|
||||||
remote: string;
|
remote: string;
|
||||||
targetBranch: string;
|
targetBranch: string;
|
||||||
|
includePaths?: string[];
|
||||||
|
excludePaths?: string[];
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const destBranch =
|
const destBranch =
|
||||||
opts.destBranch || `${sourceMR.repo.owner.username}/${sourceMR.repo.name}/mr-${sourceMR.id}`;
|
opts.destBranch || `${sourceMR.repo.owner.username}/${sourceMR.repo.name}/mr-${sourceMR.id}`;
|
||||||
const { doNotCommit, doNotPush, remote, targetBranch, patchHook } = opts;
|
const {
|
||||||
|
doNotCommit,
|
||||||
|
doNotPush,
|
||||||
|
remote,
|
||||||
|
targetBranch,
|
||||||
|
patchHook,
|
||||||
|
includePaths,
|
||||||
|
excludePaths,
|
||||||
|
} = opts;
|
||||||
|
|
||||||
await this.replicateCommits(sourceMR.commits, destination, {
|
await this.replicateCommits(sourceMR.commits, destination, {
|
||||||
destBranch,
|
destBranch,
|
||||||
doNotCommit,
|
doNotCommit,
|
||||||
patchHook,
|
patchHook,
|
||||||
|
includePaths,
|
||||||
|
excludePaths,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (doNotCommit !== true && doNotPush !== true) {
|
if (doNotCommit !== true && doNotPush !== true) {
|
||||||
|
@ -100,9 +112,11 @@ export default class Copykitku {
|
||||||
destBranch: string;
|
destBranch: string;
|
||||||
doNotCommit?: boolean | null;
|
doNotCommit?: boolean | null;
|
||||||
patchHook?: string | null;
|
patchHook?: string | null;
|
||||||
|
includePaths?: string[];
|
||||||
|
excludePaths?: string[];
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const { destBranch, doNotCommit, patchHook } = opts;
|
const { destBranch, doNotCommit, patchHook, includePaths, excludePaths } = opts;
|
||||||
const commits = Array.isArray(sourceCommit) ? sourceCommit : [sourceCommit];
|
const commits = Array.isArray(sourceCommit) ? sourceCommit : [sourceCommit];
|
||||||
|
|
||||||
const patchHookCall = patchHook
|
const patchHookCall = patchHook
|
||||||
|
@ -152,7 +166,13 @@ export default class Copykitku {
|
||||||
|
|
||||||
for (let i = 0; i < patchFiles.length; i += 1) {
|
for (let i = 0; i < patchFiles.length; i += 1) {
|
||||||
const patch = patchFiles[i];
|
const patch = patchFiles[i];
|
||||||
await git.applyPatch(patch.patchFile, ['--index']);
|
await git.applyPatch(
|
||||||
|
patch.patchFile,
|
||||||
|
['--index'].concat(
|
||||||
|
...(includePaths || []).map((inc) => ['--include', inc]),
|
||||||
|
...(excludePaths || []).map((inc) => ['--exclude', inc]),
|
||||||
|
),
|
||||||
|
);
|
||||||
if (doNotCommit !== true) {
|
if (doNotCommit !== true) {
|
||||||
await git.commit(patch.title + (patch.content ? '\n\n' + patch.content : ''), {
|
await git.commit(patch.title + (patch.content ? '\n\n' + patch.content : ''), {
|
||||||
'--author': patch.from,
|
'--author': patch.from,
|
||||||
|
|
Loading…
Reference in a new issue