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({
|
||||
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 = [
|
||||
|
@ -49,7 +59,15 @@ export default class Replicate extends Command {
|
|||
|
||||
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 } = {
|
||||
...proj,
|
||||
|
@ -97,6 +115,8 @@ export default class Replicate extends Command {
|
|||
patchHook,
|
||||
remote,
|
||||
targetBranch,
|
||||
includePaths,
|
||||
excludePaths,
|
||||
});
|
||||
if (repl === true) {
|
||||
// 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;
|
||||
remote: string;
|
||||
targetBranch: string;
|
||||
includePaths?: string[];
|
||||
excludePaths?: string[];
|
||||
},
|
||||
) {
|
||||
const destBranch =
|
||||
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, {
|
||||
destBranch,
|
||||
doNotCommit,
|
||||
patchHook,
|
||||
includePaths,
|
||||
excludePaths,
|
||||
});
|
||||
|
||||
if (doNotCommit !== true && doNotPush !== true) {
|
||||
|
@ -100,9 +112,11 @@ export default class Copykitku {
|
|||
destBranch: string;
|
||||
doNotCommit?: boolean | 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 patchHookCall = patchHook
|
||||
|
@ -152,7 +166,13 @@ export default class Copykitku {
|
|||
|
||||
for (let i = 0; i < patchFiles.length; i += 1) {
|
||||
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) {
|
||||
await git.commit(patch.title + (patch.content ? '\n\n' + patch.content : ''), {
|
||||
'--author': patch.from,
|
||||
|
|
Loading…
Reference in a new issue