merging commits to main branch

This commit is contained in:
Laura Liberda 2021-02-26 14:01:58 +01:00
parent c71309c9e8
commit cf3fdb17dc
2 changed files with 23 additions and 1 deletions

View file

@ -17,6 +17,9 @@ export default class Replicate extends Command {
description: 'do not commit the applied changes (for MRs)',
allowNo: false,
}),
mergeToMainBranch: flags.boolean({
description: 'merge the replicated commit into main branch as well (for MRs and commits)',
}),
remote: flags.string({
description: 'git remote where the commits are pushed (for MRs)',
default: 'origin',
@ -62,6 +65,7 @@ export default class Replicate extends Command {
const {
destBranch,
doNotCommit,
mergeToMainBranch,
remote,
targetBranch,
patchHook,
@ -112,6 +116,7 @@ export default class Replicate extends Command {
const repl = await kitku.replicateMergeRequest(sourceMR, destRepo, {
destBranch,
doNotCommit,
mergeToMainBranch,
patchHook,
remote,
targetBranch,
@ -134,6 +139,7 @@ export default class Replicate extends Command {
destBranch ||
`${sourceRepo.repo.owner.username}/${sourceRepo.repo.name}/commit-${sourceCommit.id}`,
doNotCommit,
mergeToMainBranch,
patchHook,
includePaths,
excludePaths,

View file

@ -62,6 +62,7 @@ export default class Copykitku {
destBranch?: string;
doNotCommit?: boolean | null;
doNotPush?: boolean | null;
mergeToMainBranch?: boolean | null;
patchHook?: string | null;
remote: string;
targetBranch: string;
@ -74,6 +75,7 @@ export default class Copykitku {
const {
doNotCommit,
doNotPush,
mergeToMainBranch,
remote,
targetBranch,
patchHook,
@ -84,6 +86,7 @@ export default class Copykitku {
await this.replicateCommits(sourceMR.commits, destination, {
destBranch,
doNotCommit,
mergeToMainBranch,
patchHook,
includePaths,
excludePaths,
@ -111,12 +114,20 @@ export default class Copykitku {
opts: {
destBranch: string;
doNotCommit?: boolean | null;
mergeToMainBranch?: boolean | null;
patchHook?: string | null;
includePaths?: string[];
excludePaths?: string[];
},
) {
const { destBranch, doNotCommit, patchHook, includePaths, excludePaths } = opts;
const {
destBranch,
doNotCommit,
mergeToMainBranch,
patchHook,
includePaths,
excludePaths,
} = opts;
const commits = Array.isArray(sourceCommit) ? sourceCommit : [sourceCommit];
const patchHookCall = patchHook
@ -179,6 +190,11 @@ export default class Copykitku {
});
}
}
if (doNotCommit !== true && mergeToMainBranch === true) {
// TODO: check the main branch name (T32)
await git.checkout('master');
await git.merge([destBranch]);
}
return true;
}