@git.zone/cli 8.3.2 → 8.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/helpers.workflow.d.ts +29 -0
  3. package/dist_ts/helpers.workflow.js +37 -2
  4. package/dist_ts/mod_config/index.js +45 -3
  5. package/dist_ts/mod_release/classes.releasejournal.d.ts +19 -3
  6. package/dist_ts/mod_release/classes.releasejournal.js +108 -13
  7. package/dist_ts/mod_release/helpers.giteaassets.d.ts +47 -1
  8. package/dist_ts/mod_release/helpers.giteaassets.js +236 -56
  9. package/dist_ts/mod_release/helpers.npmartifact.d.ts +68 -7
  10. package/dist_ts/mod_release/helpers.npmartifact.js +192 -26
  11. package/dist_ts/mod_release/helpers.releasebranch.d.ts +11 -0
  12. package/dist_ts/mod_release/helpers.releasebranch.js +88 -61
  13. package/dist_ts/mod_release/helpers.releaseline.d.ts +60 -0
  14. package/dist_ts/mod_release/helpers.releaseline.js +129 -0
  15. package/dist_ts/mod_release/helpers.releasephase.d.ts +9 -0
  16. package/dist_ts/mod_release/helpers.releasephase.js +25 -0
  17. package/dist_ts/mod_release/helpers.releasepreparation.js +6 -3
  18. package/dist_ts/mod_release/helpers.releasepublication.d.ts +12 -1
  19. package/dist_ts/mod_release/helpers.releasepublication.js +235 -52
  20. package/dist_ts/mod_release/helpers.releaseversion.d.ts +2 -0
  21. package/dist_ts/mod_release/helpers.releaseversion.js +4 -2
  22. package/dist_ts/mod_release/index.js +149 -44
  23. package/dist_ts/mod_release/interfaces.giteaassets.d.ts +16 -0
  24. package/package.json +5 -5
  25. package/readme.md +224 -17
  26. package/ts/00_commitinfo_data.ts +1 -1
  27. package/ts/helpers.workflow.ts +87 -0
  28. package/ts/mod_config/index.ts +50 -1
  29. package/ts/mod_release/classes.releasejournal.ts +165 -14
  30. package/ts/mod_release/helpers.giteaassets.ts +319 -64
  31. package/ts/mod_release/helpers.npmartifact.ts +302 -22
  32. package/ts/mod_release/helpers.releasebranch.ts +120 -45
  33. package/ts/mod_release/helpers.releaseline.ts +214 -0
  34. package/ts/mod_release/helpers.releasephase.ts +26 -0
  35. package/ts/mod_release/helpers.releasepreparation.ts +12 -3
  36. package/ts/mod_release/helpers.releasepublication.ts +425 -78
  37. package/ts/mod_release/helpers.releaseversion.ts +5 -1
  38. package/ts/mod_release/index.ts +213 -32
  39. package/ts/mod_release/interfaces.giteaassets.ts +19 -0
@@ -10,9 +10,16 @@ import {
10
10
  type IReleaseGitRemotePolicy,
11
11
  type IReleaseGitRemoteResult,
12
12
  } from "./helpers.gitremote.js";
13
+ import {
14
+ getReleaseBranch,
15
+ mainReleaseBranch,
16
+ type IReleaseLine,
17
+ } from "./helpers.releaseline.js";
13
18
 
14
- const mainBranch = "main";
15
- const mainBranchRef = `refs/heads/${mainBranch}`;
19
+ const mainBranch = mainReleaseBranch;
20
+ const branchRef = (branchArg: string): string => `refs/heads/${branchArg}`;
21
+ /** Merge mode integrates into `main` only. */
22
+ const mainBranchRef = branchRef(mainBranch);
16
23
 
17
24
  interface IGitWorktree {
18
25
  path: string;
@@ -21,11 +28,19 @@ interface IGitWorktree {
21
28
  prunable: boolean;
22
29
  }
23
30
 
31
+ /**
32
+ * The `main*` fields describe the release branch: `main`, or the branch of
33
+ * the configured release line, which then also is the source branch.
34
+ */
24
35
  export interface IReleaseBranchContext {
25
36
  sourceCwd: string;
26
37
  sourceBranch: string;
27
38
  sourceRef: string;
28
39
  sourceOid: string;
40
+ /** The branch the release commit is created on and pushed to. */
41
+ releaseBranch: string;
42
+ /** Present when the release publishes a maintenance line. */
43
+ releaseLine?: IReleaseLine;
29
44
  gitRemote: string;
30
45
  localMainOid?: string;
31
46
  remoteMainOid?: string;
@@ -53,6 +68,8 @@ export interface IInspectReleaseBranchOptions {
53
68
  pushTags?: boolean;
54
69
  mergeRequested: boolean;
55
70
  planMode: boolean;
71
+ /** The configured or journaled release line; absent releases `main`. */
72
+ releaseLine?: IReleaseLine;
56
73
  /** Defaults to `release.targets.git.remoteTimeoutSeconds`' default. */
57
74
  gitRemotePolicy?: IReleaseGitRemotePolicy;
58
75
  }
@@ -492,11 +509,16 @@ export const isAbsentGitOid = (valueArg: string): boolean =>
492
509
  */
493
510
  const resolveRemoteMainOid = async (
494
511
  smartshellArg: TSmartshell,
495
- contextArg: Pick<IReleaseBranchContext, "sourceCwd" | "gitRemotePolicy">,
512
+ contextArg: Pick<
513
+ IReleaseBranchContext,
514
+ "sourceCwd" | "gitRemotePolicy" | "releaseBranch"
515
+ >,
496
516
  pushUrlArg: string,
497
517
  stepArg: string,
498
518
  readOnlyArg = false,
499
519
  ): Promise<string> => {
520
+ const releaseBranch = contextArg.releaseBranch;
521
+ const releaseBranchRef = branchRef(releaseBranch);
500
522
  const inspect = (argsArg: string[]) =>
501
523
  runGitRemoteInspection({
502
524
  smartshell: smartshellArg,
@@ -519,8 +541,17 @@ const resolveRemoteMainOid = async (
519
541
  "ls-remote",
520
542
  "--exit-code",
521
543
  pushUrlArg,
522
- mainBranchRef,
544
+ releaseBranchRef,
523
545
  ]);
546
+ if (
547
+ result.exitCode === 2 &&
548
+ !result.stdout.trim() &&
549
+ releaseBranch !== mainBranch
550
+ ) {
551
+ throw new Error(
552
+ `The release line branch ${releaseBranch} does not exist at the Git push destination. A line releases an existing maintenance branch; push it before releasing.`,
553
+ );
554
+ }
524
555
  if (result.exitCode === 2 && !result.stdout.trim()) {
525
556
  const allRefs = await inspect(["ls-remote", pushUrlArg]);
526
557
  if (allRefs.exitCode !== 0) {
@@ -551,15 +582,13 @@ const resolveRemoteMainOid = async (
551
582
  if (result.exitCode !== 0) {
552
583
  throw remoteFailure(
553
584
  result,
554
- "Unable to inspect main at the configured Git push destination.",
585
+ `Unable to inspect ${releaseBranch} at the configured Git push destination.`,
555
586
  );
556
587
  }
557
- const match = result.stdout
558
- .trim()
559
- .match(/^([0-9a-f]{40}|[0-9a-f]{64})\s+refs\/heads\/main$/i);
560
- if (!match || isAbsentGitOid(match[1])) {
588
+ const match = result.stdout.trim().match(/^([0-9a-f]{40}|[0-9a-f]{64})\s+(\S+)$/i);
589
+ if (!match || match[2] !== releaseBranchRef || isAbsentGitOid(match[1])) {
561
590
  throw new Error(
562
- "The configured Git push destination returned an invalid main commit ID.",
591
+ `The configured Git push destination returned an invalid ${releaseBranch} commit ID.`,
563
592
  );
564
593
  }
565
594
  return match[1];
@@ -645,6 +674,7 @@ const verifyLinearAncestry = async (
645
674
 
646
675
  const verifyMainWorktree = async (
647
676
  smartshellArg: TSmartshell,
677
+ releaseBranchArg: string,
648
678
  pathArg: string,
649
679
  expectedOidArg: string,
650
680
  expectedGitDirArg?: string,
@@ -655,21 +685,23 @@ const verifyMainWorktree = async (
655
685
  pathArg,
656
686
  readOnlyArg,
657
687
  );
658
- if (symbolic.ref !== mainBranchRef) {
688
+ if (symbolic.ref !== branchRef(releaseBranchArg)) {
659
689
  throw new Error(
660
- "The destination worktree is no longer checked out on main. Retry after restoring a clean main worktree.",
690
+ `The destination worktree is no longer checked out on ${releaseBranchArg}. Retry after restoring a clean ${releaseBranchArg} worktree.`,
661
691
  );
662
692
  }
663
693
  const head = await resolveCommit(
664
694
  smartshellArg,
665
695
  pathArg,
666
696
  "HEAD",
667
- "Unable to resolve the destination main commit.",
697
+ `Unable to resolve the destination ${releaseBranchArg} commit.`,
668
698
  readOnlyArg,
669
699
  );
670
700
  if (head !== expectedOidArg) {
671
701
  throw new Error(
672
- "Local main changed during release preparation. Rebase the feature branch onto current main and retry.",
702
+ releaseBranchArg === mainBranch
703
+ ? "Local main changed during release preparation. Rebase the feature branch onto current main and retry."
704
+ : `Local ${releaseBranchArg} changed during release preparation. Restart the release from its new tip.`,
673
705
  );
674
706
  }
675
707
  const gitDir = await resolveAbsoluteGitDir(
@@ -682,39 +714,46 @@ const verifyMainWorktree = async (
682
714
  "The destination main worktree identity changed during release preparation. Retry from a stable worktree.",
683
715
  );
684
716
  }
685
- await verifyCleanTree(smartshellArg, pathArg, "main", readOnlyArg);
686
- await verifyNoGitOperation(smartshellArg, pathArg, "main", readOnlyArg);
717
+ await verifyCleanTree(smartshellArg, pathArg, releaseBranchArg, readOnlyArg);
718
+ await verifyNoGitOperation(
719
+ smartshellArg,
720
+ pathArg,
721
+ releaseBranchArg,
722
+ readOnlyArg,
723
+ );
687
724
  return gitDir;
688
725
  };
689
726
 
690
727
  const resolveMainWorktree = async (
691
728
  smartshellArg: TSmartshell,
729
+ releaseBranchArg: string,
692
730
  cwdArg: string,
693
731
  localMainOidArg: string,
694
732
  readOnlyArg = false,
695
733
  ): Promise<{ path: string; gitDir: string }> => {
696
734
  const records = await listWorktrees(smartshellArg, cwdArg, readOnlyArg);
697
735
  const mainRecords = records.filter(
698
- (record) => record.branch === mainBranchRef,
736
+ (record) => record.branch === branchRef(releaseBranchArg),
699
737
  );
700
738
  if (mainRecords.length > 1) {
701
739
  throw new Error(
702
- "Multiple worktrees claim main. Repair the Git worktree registry before releasing.",
740
+ `Multiple worktrees claim ${releaseBranchArg}. Repair the Git worktree registry before releasing.`,
703
741
  );
704
742
  }
705
743
  const mainRecord = mainRecords[0];
706
744
  if (!mainRecord) {
707
745
  throw new Error(
708
- "Release merge mode requires exactly one existing worktree checked out on main.",
746
+ `Release merge mode requires exactly one existing worktree checked out on ${releaseBranchArg}.`,
709
747
  );
710
748
  }
711
749
  if (mainRecord.prunable) {
712
750
  throw new Error(
713
- "The registered main worktree is stale. Repair it explicitly before releasing.",
751
+ `The registered ${releaseBranchArg} worktree is stale. Repair it explicitly before releasing.`,
714
752
  );
715
753
  }
716
754
  const gitDir = await verifyMainWorktree(
717
755
  smartshellArg,
756
+ releaseBranchArg,
718
757
  mainRecord.path,
719
758
  localMainOidArg,
720
759
  undefined,
@@ -802,11 +841,14 @@ export async function inspectReleaseBranch(
802
841
  "Unable to resolve the release source commit.",
803
842
  optionsArg.planMode,
804
843
  );
844
+ const releaseBranch = getReleaseBranch(optionsArg.releaseLine);
805
845
  const context: IReleaseBranchContext = {
806
846
  sourceCwd: optionsArg.cwd,
807
847
  sourceBranch: symbolic.branch,
808
848
  sourceRef: symbolic.ref,
809
849
  sourceOid,
850
+ releaseBranch,
851
+ ...(optionsArg.releaseLine ? { releaseLine: optionsArg.releaseLine } : {}),
810
852
  gitRemote: optionsArg.gitRemote,
811
853
  mergeRequested: optionsArg.mergeRequested,
812
854
  planAncestryVerified: false,
@@ -821,17 +863,31 @@ export async function inspectReleaseBranch(
821
863
  optionsArg.planMode,
822
864
  );
823
865
 
866
+ if (optionsArg.releaseLine) {
867
+ // A line releases its own branch in place: it never integrates another
868
+ // branch, and only the branch the line names may release it.
869
+ if (optionsArg.mergeRequested) {
870
+ throw new Error(
871
+ `\`gitzone release --merge\` cannot release the ${optionsArg.releaseLine.distTag} line: a maintenance line releases its branch ${releaseBranch} in place.`,
872
+ );
873
+ }
874
+ if (symbolic.branch !== releaseBranch) {
875
+ throw new Error(
876
+ `release.line names branch ${releaseBranch}, but the source branch is ${symbolic.branch}. Release the ${optionsArg.releaseLine.distTag} line from ${releaseBranch}, or remove release.line from this branch's .smartconfig.json.`,
877
+ );
878
+ }
879
+ }
824
880
  if (symbolic.branch === mainBranch && optionsArg.mergeRequested) {
825
881
  throw new Error(
826
882
  "`gitzone release --merge` is only valid when releasing from a non-main branch.",
827
883
  );
828
884
  }
829
- if (symbolic.branch !== mainBranch && !optionsArg.mergeRequested) {
885
+ if (symbolic.branch !== releaseBranch && !optionsArg.mergeRequested) {
830
886
  throw new Error(
831
- `Releases must run from main. Current branch: ${symbolic.branch}. Re-run with \`gitzone release --merge\` after rebasing cleanly onto main.`,
887
+ `Releases must run from main. Current branch: ${symbolic.branch}. Re-run with \`gitzone release --merge\` after rebasing cleanly onto main, or configure release.line on a maintenance branch.`,
832
888
  );
833
889
  }
834
- if (symbolic.branch !== mainBranch && !optionsArg.gitTargetActive) {
890
+ if (symbolic.branch !== releaseBranch && !optionsArg.gitTargetActive) {
835
891
  throw new Error(
836
892
  "`gitzone release --merge` requires the active Git target.",
837
893
  );
@@ -854,11 +910,11 @@ export async function inspectReleaseBranch(
854
910
  context.localMainOid = await resolveCommit(
855
911
  optionsArg.smartshell,
856
912
  optionsArg.cwd,
857
- mainBranchRef,
858
- "A local main branch is required for release merge mode.",
913
+ branchRef(releaseBranch),
914
+ `A local ${releaseBranch} branch is required for release merge mode.`,
859
915
  optionsArg.planMode,
860
916
  );
861
- if (symbolic.branch !== mainBranch) {
917
+ if (symbolic.branch !== releaseBranch) {
862
918
  await verifyLinearAncestry(
863
919
  optionsArg.smartshell,
864
920
  optionsArg.cwd,
@@ -870,6 +926,7 @@ export async function inspectReleaseBranch(
870
926
 
871
927
  const mainWorktree = await resolveMainWorktree(
872
928
  optionsArg.smartshell,
929
+ releaseBranch,
873
930
  optionsArg.cwd,
874
931
  context.localMainOid,
875
932
  optionsArg.planMode,
@@ -877,12 +934,12 @@ export async function inspectReleaseBranch(
877
934
  context.mainWorktreePath = mainWorktree.path;
878
935
  context.mainWorktreeGitDir = mainWorktree.gitDir;
879
936
  if (
880
- symbolic.branch === mainBranch &&
937
+ symbolic.branch === releaseBranch &&
881
938
  plugins.path.resolve(mainWorktree.path) !==
882
939
  plugins.path.resolve(optionsArg.cwd)
883
940
  ) {
884
941
  throw new Error(
885
- "The current main worktree does not match Git worktree ownership.",
942
+ `The current ${releaseBranch} worktree does not match Git worktree ownership.`,
886
943
  );
887
944
  }
888
945
 
@@ -901,7 +958,7 @@ export async function inspectReleaseBranch(
901
958
  true,
902
959
  );
903
960
  if (isAbsentGitOid(context.remoteMainOid)) {
904
- if (symbolic.branch !== mainBranch) {
961
+ if (symbolic.branch !== mainBranch || releaseBranch !== mainBranch) {
905
962
  throw new Error(
906
963
  "First release into an empty Git remote must run directly from main.",
907
964
  );
@@ -944,6 +1001,7 @@ export async function prepareReleaseIntegration(
944
1001
  await verifySourceState(smartshellArg, contextArg);
945
1002
  await verifyMainWorktree(
946
1003
  smartshellArg,
1004
+ contextArg.releaseBranch,
947
1005
  contextArg.mainWorktreePath,
948
1006
  contextArg.localMainOid,
949
1007
  contextArg.mainWorktreeGitDir,
@@ -969,12 +1027,13 @@ export async function prepareReleaseIntegration(
969
1027
  );
970
1028
  if (contextArg.remoteMainOid && remoteMainOid !== contextArg.remoteMainOid) {
971
1029
  throw new Error(
972
- "Remote main changed during release preparation. Fetch, rebase cleanly, and retry.",
1030
+ `Remote ${contextArg.releaseBranch} changed during release preparation. Fetch, rebase cleanly, and retry.`,
973
1031
  );
974
1032
  }
975
1033
  if (isAbsentGitOid(remoteMainOid)) {
976
1034
  if (
977
1035
  contextArg.sourceBranch !== mainBranch ||
1036
+ contextArg.releaseBranch !== mainBranch ||
978
1037
  contextArg.remoteMainOid !== remoteMainOid
979
1038
  ) {
980
1039
  throw new Error(
@@ -984,6 +1043,7 @@ export async function prepareReleaseIntegration(
984
1043
  await verifySourceState(smartshellArg, contextArg);
985
1044
  await verifyMainWorktree(
986
1045
  smartshellArg,
1046
+ contextArg.releaseBranch,
987
1047
  contextArg.mainWorktreePath,
988
1048
  contextArg.localMainOid,
989
1049
  contextArg.mainWorktreeGitDir,
@@ -997,9 +1057,9 @@ export async function prepareReleaseIntegration(
997
1057
  "--no-recurse-submodules",
998
1058
  "--no-write-fetch-head",
999
1059
  contextArg.pushUrl,
1000
- mainBranchRef,
1060
+ branchRef(contextArg.releaseBranch),
1001
1061
  ]),
1002
- "Unable to fetch current main from the configured Git push destination.",
1062
+ `Unable to fetch current ${contextArg.releaseBranch} from the configured Git push destination.`,
1003
1063
  );
1004
1064
  const verifiedRemoteMainOid = await resolveRemoteMainOid(
1005
1065
  smartshellArg,
@@ -1009,14 +1069,14 @@ export async function prepareReleaseIntegration(
1009
1069
  );
1010
1070
  if (verifiedRemoteMainOid !== remoteMainOid) {
1011
1071
  throw new Error(
1012
- "Remote main changed during release preparation. Fetch, rebase the feature branch cleanly, and retry.",
1072
+ `Remote ${contextArg.releaseBranch} changed during release preparation. Fetch, rebase the feature branch cleanly, and retry.`,
1013
1073
  );
1014
1074
  }
1015
1075
  if (
1016
1076
  !(await hasCommitObject(smartshellArg, contextArg.sourceCwd, remoteMainOid))
1017
1077
  ) {
1018
1078
  throw new Error(
1019
- "Current remote main could not be loaded locally. Fetch complete history and retry.",
1079
+ `Current remote ${contextArg.releaseBranch} could not be loaded locally. Fetch complete history and retry.`,
1020
1080
  );
1021
1081
  }
1022
1082
  await verifyLinearAncestry(
@@ -1028,6 +1088,7 @@ export async function prepareReleaseIntegration(
1028
1088
  await verifySourceState(smartshellArg, contextArg);
1029
1089
  await verifyMainWorktree(
1030
1090
  smartshellArg,
1091
+ contextArg.releaseBranch,
1031
1092
  contextArg.mainWorktreePath,
1032
1093
  contextArg.localMainOid,
1033
1094
  contextArg.mainWorktreeGitDir,
@@ -1055,6 +1116,7 @@ export async function revalidatePreparedReleaseBranch(
1055
1116
  await verifySourceState(smartshellArg, contextArg);
1056
1117
  await verifyMainWorktree(
1057
1118
  smartshellArg,
1119
+ contextArg.releaseBranch,
1058
1120
  contextArg.mainWorktreePath,
1059
1121
  contextArg.localMainOid,
1060
1122
  contextArg.mainWorktreeGitDir,
@@ -1078,7 +1140,7 @@ export async function revalidatePreparedReleaseBranch(
1078
1140
  );
1079
1141
  if (currentRemoteMainOid !== contextArg.remoteMainOid) {
1080
1142
  throw new Error(
1081
- "Remote main changed after release preflight. Fetch, rebase cleanly, and retry.",
1143
+ `Remote ${contextArg.releaseBranch} changed after release preflight. Fetch, rebase cleanly, and retry.`,
1082
1144
  );
1083
1145
  }
1084
1146
  }
@@ -1114,13 +1176,14 @@ const ensureRemoteCommitObject = async (
1114
1176
  smartshellArg: TSmartshell,
1115
1177
  cwdArg: string,
1116
1178
  pushUrlArg: string,
1179
+ releaseBranchArg: string,
1117
1180
  remoteMainOidArg: string,
1118
1181
  ): Promise<void> => {
1119
1182
  if (await hasCommitObject(smartshellArg, cwdArg, remoteMainOidArg, true)) {
1120
1183
  return;
1121
1184
  }
1122
1185
  let lastFetchFailure: IReleaseGitResult | undefined;
1123
- for (const fetchTargetArg of [mainBranchRef, remoteMainOidArg]) {
1186
+ for (const fetchTargetArg of [branchRef(releaseBranchArg), remoteMainOidArg]) {
1124
1187
  const fetchResult = await runGit(smartshellArg, cwdArg, [
1125
1188
  "fetch",
1126
1189
  "--no-tags",
@@ -1134,7 +1197,7 @@ const ensureRemoteCommitObject = async (
1134
1197
  return;
1135
1198
  }
1136
1199
  }
1137
- const message = `Remote main ${remoteMainOidArg} could not be fetched; remote containment unverified.`;
1200
+ const message = `Remote ${releaseBranchArg} ${remoteMainOidArg} could not be fetched; remote containment unverified.`;
1138
1201
  throw lastFetchFailure
1139
1202
  ? gitFailure(lastFetchFailure, message)
1140
1203
  : new Error(message);
@@ -1154,8 +1217,8 @@ export async function verifyReleaseHistoryRetained(
1154
1217
  const localMainOid = await resolveCommit(
1155
1218
  smartshellArg,
1156
1219
  contextArg.sourceCwd,
1157
- mainBranchRef,
1158
- "A local main branch is required to resume a release.",
1220
+ branchRef(contextArg.releaseBranch),
1221
+ `A local ${contextArg.releaseBranch} branch is required to resume a release.`,
1159
1222
  true,
1160
1223
  );
1161
1224
  await verifyCommitContained(
@@ -1163,7 +1226,7 @@ export async function verifyReleaseHistoryRetained(
1163
1226
  contextArg.sourceCwd,
1164
1227
  releaseCommitOidArg,
1165
1228
  localMainOid,
1166
- "Local main no longer contains the journaled release commit. Restore that history before resuming.",
1229
+ `Local ${contextArg.releaseBranch} no longer contains the journaled release commit. Restore that history before resuming.`,
1167
1230
  );
1168
1231
  if (!contextArg.pushUrl) return;
1169
1232
  const currentPushUrl = await resolvePushUrl(
@@ -1186,13 +1249,14 @@ export async function verifyReleaseHistoryRetained(
1186
1249
  );
1187
1250
  if (isAbsentGitOid(remoteMainOid)) {
1188
1251
  throw new Error(
1189
- "Remote main no longer exists, so the journaled release history cannot be confirmed.",
1252
+ `Remote ${contextArg.releaseBranch} no longer exists, so the journaled release history cannot be confirmed.`,
1190
1253
  );
1191
1254
  }
1192
1255
  await ensureRemoteCommitObject(
1193
1256
  smartshellArg,
1194
1257
  contextArg.sourceCwd,
1195
1258
  contextArg.pushUrl,
1259
+ contextArg.releaseBranch,
1196
1260
  remoteMainOid,
1197
1261
  );
1198
1262
  await verifyCommitContained(
@@ -1200,7 +1264,7 @@ export async function verifyReleaseHistoryRetained(
1200
1264
  contextArg.sourceCwd,
1201
1265
  releaseCommitOidArg,
1202
1266
  remoteMainOid,
1203
- "Remote main no longer contains the journaled release commit. Inspect the remote before resuming.",
1267
+ `Remote ${contextArg.releaseBranch} no longer contains the journaled release commit. Inspect the remote before resuming.`,
1204
1268
  );
1205
1269
  }
1206
1270
 
@@ -1218,6 +1282,7 @@ export async function revalidateReleasePublicationState(
1218
1282
  await verifyNoHistoryOverrides(smartshellArg, contextArg.sourceCwd);
1219
1283
  const currentMainWorktree = await resolveMainWorktree(
1220
1284
  smartshellArg,
1285
+ contextArg.releaseBranch,
1221
1286
  contextArg.sourceCwd,
1222
1287
  expectedMainOidArg,
1223
1288
  );
@@ -1229,13 +1294,13 @@ export async function revalidateReleasePublicationState(
1229
1294
  "Main worktree ownership changed before release publication. Inspect the worktree layout before retrying.",
1230
1295
  );
1231
1296
  }
1232
- if (contextArg.sourceBranch !== mainBranch) {
1297
+ if (contextArg.sourceBranch !== contextArg.releaseBranch) {
1233
1298
  await verifySourceState(smartshellArg, contextArg);
1234
1299
  }
1235
1300
  if (contextArg.pushUrl) {
1236
1301
  if (!expectedRemoteMainOidArg) {
1237
1302
  throw new Error(
1238
- "Expected remote main state is unavailable. Restart the release.",
1303
+ `Expected remote ${contextArg.releaseBranch} state is unavailable. Restart the release.`,
1239
1304
  );
1240
1305
  }
1241
1306
  const currentPushUrl = await resolvePushUrl(
@@ -1256,7 +1321,7 @@ export async function revalidateReleasePublicationState(
1256
1321
  );
1257
1322
  if (currentRemoteMainOid !== expectedRemoteMainOidArg) {
1258
1323
  throw new Error(
1259
- "Remote main changed before release publication. Inspect the remote state before retrying.",
1324
+ `Remote ${contextArg.releaseBranch} changed before release publication. Inspect the remote state before retrying.`,
1260
1325
  );
1261
1326
  }
1262
1327
  }
@@ -1282,6 +1347,7 @@ const describeLocalMainState = async (
1282
1347
  try {
1283
1348
  await verifyMainWorktree(
1284
1349
  smartshellArg,
1350
+ mainBranch,
1285
1351
  releaseCwdArg,
1286
1352
  mainOid,
1287
1353
  destinationGitDirArg,
@@ -1338,6 +1404,7 @@ const rollbackLocalMain = async (
1338
1404
  try {
1339
1405
  await verifyMainWorktree(
1340
1406
  smartshellArg,
1407
+ mainBranch,
1341
1408
  releaseCwdArg,
1342
1409
  contextArg.sourceOid,
1343
1410
  destinationGitDirArg,
@@ -1364,6 +1431,7 @@ const rollbackLocalMain = async (
1364
1431
  );
1365
1432
  await verifyMainWorktree(
1366
1433
  smartshellArg,
1434
+ mainBranch,
1367
1435
  releaseCwdArg,
1368
1436
  contextArg.localMainOid,
1369
1437
  destinationGitDirArg,
@@ -1396,6 +1464,9 @@ export async function integrateReleaseBranch(
1396
1464
  "The release branch is already main and does not require integration.",
1397
1465
  );
1398
1466
  }
1467
+ if (contextArg.releaseBranch !== mainBranch) {
1468
+ throw new Error("Release merge mode integrates into main only.");
1469
+ }
1399
1470
  if (
1400
1471
  !contextArg.pushUrl ||
1401
1472
  !contextArg.localMainOid ||
@@ -1442,6 +1513,7 @@ export async function integrateReleaseBranch(
1442
1513
 
1443
1514
  const currentMainWorktree = await resolveMainWorktree(
1444
1515
  smartshellArg,
1516
+ mainBranch,
1445
1517
  contextArg.sourceCwd,
1446
1518
  contextArg.localMainOid,
1447
1519
  );
@@ -1462,6 +1534,7 @@ export async function integrateReleaseBranch(
1462
1534
  }
1463
1535
  const destinationGitDir = await verifyMainWorktree(
1464
1536
  smartshellArg,
1537
+ mainBranch,
1465
1538
  releaseCwd,
1466
1539
  contextArg.localMainOid,
1467
1540
  contextArg.mainWorktreeGitDir,
@@ -1504,6 +1577,7 @@ export async function integrateReleaseBranch(
1504
1577
  try {
1505
1578
  await verifyMainWorktree(
1506
1579
  smartshellArg,
1580
+ mainBranch,
1507
1581
  releaseCwd,
1508
1582
  contextArg.sourceOid,
1509
1583
  destinationGitDir,
@@ -1578,6 +1652,7 @@ export async function integrateReleaseBranch(
1578
1652
  }
1579
1653
  await verifyMainWorktree(
1580
1654
  smartshellArg,
1655
+ mainBranch,
1581
1656
  releaseCwd,
1582
1657
  contextArg.sourceOid,
1583
1658
  destinationGitDir,