release-cherry-pick 1.0.2 → 1.1.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.
@@ -6,11 +6,11 @@ const inquirer = require('inquirer');
6
6
  const logger = require('../utils/logger');
7
7
  const { loadConfig, saveConfig } = require('../config/loader');
8
8
  const { setupWizard, ensureAiSettings } = require('../config/setup');
9
- const { parseBranchListFile, extractTaskIdFromBranch, describeBranch, isTaskId } = require('../git/branch-parser');
10
- const { selectBranchesInteractively, getRemoteBranches, resolveBranchNameForTaskId } = require('../git/branch-selector');
9
+ const { parseBranchListFile, parseCommitSpecs, parseBranchEntries, isCommitHash, extractTaskIdFromBranch, describeBranch, isTaskId } = require('../git/branch-parser');
10
+ const { selectBranchesInteractively, getBranchCatalog, countCommitsBetween, resolveBranchNameForTaskId } = require('../git/branch-selector');
11
11
  const { buildReleaseBranchName, createReleaseBranch, pushBranch } = require('../git/release-branch');
12
12
  const { captureStartingPoint, restoreStartingPoint, runInterruptible } = require('../git/repo-state');
13
- const { cherryPickCommits, getCommitsToCherryPick, findLooseTaskCommits, orderCommitsByHistory } = require('../git/cherry-pick');
13
+ const { cherryPickCommits, getCommitsToCherryPick, findLooseTaskCommits, orderCommitsByHistory, resolveExtraCommits } = require('../git/cherry-pick');
14
14
  const gitlab = require('../gitlab/client');
15
15
  const { configureGitCredentials } = require('../git/git-auth');
16
16
  const { selectReviewer } = require('../gitlab/reviewer-selector');
@@ -19,9 +19,25 @@ const ReleaseStatus = require('../git/release-status');
19
19
  const { generateMarkdownSummary } = require('../report/summary');
20
20
  const { generateAgentsMd } = require('../doc/agents-generator');
21
21
  const { generateRpdMd } = require('../doc/rpd-generator');
22
+ const { ConfigError, GitError } = require('../utils/errors');
22
23
 
23
24
  async function runRelease(options = {}) {
25
+ if (options.local && options.remote) {
26
+ throw new ConfigError('--local and --remote cannot be used together');
27
+ }
28
+ if (options.local && options.listBranches) {
29
+ throw new ConfigError('--local cannot be combined with --list-branches: that mode opens the MR straight from the source branch, which must exist on origin');
30
+ }
31
+ // --commits PB-123=abc1234,... : extra commits to cherry-pick per task (malformed values fail here)
32
+ const commitsByTask = parseCommitSpecs(options.commits);
33
+ // -b "PB-123[abc1234,def5678],PB-124": task IDs / branch names, each with optional extra commits
34
+ const branchEntries = options.branches && !options.file ? parseBranchEntries(options.branches) : null;
35
+
24
36
  logger.header('Release Cherry-Pick');
37
+ const hasExtraCommits = commitsByTask.size > 0 || (branchEntries || []).some(e => e.extraCommits.length > 0);
38
+ if (options.listBranches && hasExtraCommits) {
39
+ logger.warn('Extra commits (--commits or [hash] in -b) are ignored with --list-branches, which doesn\'t cherry-pick anything');
40
+ }
25
41
 
26
42
  // Fail fast (before any prompt) on uncommitted changes / a cherry-pick in progress, and remember
27
43
  // where HEAD is so it can be restored once all branches are processed
@@ -65,35 +81,45 @@ async function runRelease(options = {}) {
65
81
  // on every git operation for the rest of this run.
66
82
  await configureGitCredentials(config);
67
83
 
68
- // Get branches to process
84
+ // Get branches to process. Every source branch is listed once up front: local ones (by default)
85
+ // plus origin's, the fallback for branches that don't exist locally.
69
86
  let branches = [];
87
+ const sourceMode = resolveSourceMode(options, config);
88
+ const catalog = await getBranchCatalog(config.git.branchPrefix, sourceMode);
89
+ const branchNames = [...catalog.keys()].sort();
70
90
 
71
91
  if (options.file) {
72
92
  // Parse branches from file
73
93
  try {
74
94
  const branchList = parseBranchListFile(options.file);
75
95
  logger.info(`Loaded ${branchList.length} task(s) from file, resolving real branch names...`);
76
- branches = await resolveTasksToBranches(branchList, config.git.branchPrefix);
96
+ branches = await resolveTasksToBranches(branchList, config.git.branchPrefix, branchNames, sourceMode);
77
97
  } catch (error) {
78
98
  logger.error(error.message);
79
99
  return;
80
100
  }
81
- } else if (options.branches) {
101
+ } else if (branchEntries) {
82
102
  // Comma-separated list: each entry may be a bare task ID ("PB-123", resolved to its real
83
- // remote branch) or a full branch name ("feature/PB-123-list-user")
84
- const entries = options.branches.split(',').map(b => b.trim()).filter(Boolean);
85
- const taskIds = entries.filter(isTaskId);
103
+ // branch) or a full branch name ("feature/PB-123-list-user"), optionally with "[hash,...]"
86
104
  const resolved = await resolveTasksToBranches(
87
- taskIds.map(taskId => ({ taskId })),
88
- config.git.branchPrefix
105
+ branchEntries.filter(e => isTaskId(e.name)).map(e => ({ taskId: e.name, extraCommits: e.extraCommits })),
106
+ config.git.branchPrefix,
107
+ branchNames,
108
+ sourceMode
89
109
  );
90
110
 
91
- for (const entry of entries) {
92
- if (isTaskId(entry)) {
93
- branches.push(resolved.find(b => b.taskId === entry.toUpperCase()));
111
+ for (const entry of branchEntries) {
112
+ if (isTaskId(entry.name)) {
113
+ branches.push(resolved.find(b => b.taskId === entry.name.toUpperCase()));
94
114
  } else {
95
- const info = branchInfoFromName(entry, config);
115
+ const info = branchInfoFromName(entry.name, config);
96
116
  if (info) {
117
+ if (!catalog.has(info.branchName)) {
118
+ info.missingReason = await describeMissingBranch(info, branchNames, config.git.branchPrefix, sourceMode);
119
+ }
120
+ if (entry.extraCommits.length > 0) {
121
+ info.extraHashes = [...entry.extraCommits];
122
+ }
97
123
  branches.push(info);
98
124
  }
99
125
  }
@@ -117,17 +143,16 @@ async function runRelease(options = {}) {
117
143
  ]);
118
144
 
119
145
  if (useSaved) {
120
- const remoteBranches = await getRemoteBranches(config.git.branchPrefix);
121
146
  for (const saved of savedBranches) {
122
- if (remoteBranches.includes(saved)) {
147
+ if (catalog.has(saved)) {
123
148
  selectedBranches.push(saved);
124
149
  } else {
125
- logger.warn(`Saved branch no longer exists on remote: ${saved} (skipped)`);
150
+ logger.warn(`Saved branch no longer exists ${describeLocation(sourceMode)}: ${saved} (skipped)`);
126
151
  }
127
152
  }
128
153
 
129
154
  if (selectedBranches.length === 0) {
130
- logger.warn('No saved branches still exist on the remote; falling back to interactive selection');
155
+ logger.warn(`No saved branches still exist ${describeLocation(sourceMode)}; falling back to interactive selection`);
131
156
  }
132
157
  }
133
158
  } else {
@@ -135,7 +160,7 @@ async function runRelease(options = {}) {
135
160
  }
136
161
 
137
162
  if (selectedBranches.length === 0) {
138
- selectedBranches = await selectBranchesInteractively(config.git.branchPrefix);
163
+ selectedBranches = await selectBranchesInteractively(config.git.branchPrefix, branchNames);
139
164
  if (selectedBranches.length === 0) {
140
165
  logger.warn('No branches selected');
141
166
  return;
@@ -163,6 +188,10 @@ async function runRelease(options = {}) {
163
188
  branches = selectedBranches.map(branch => branchInfoFromName(branch, config)).filter(Boolean);
164
189
  }
165
190
 
191
+ // Decide which ref each branch is released from: the local branch or origin's copy
192
+ await attachSourceRefs(branches, catalog, sourceMode);
193
+ attachExtraHashes(branches, commitsByTask);
194
+
166
195
  // Process each branch
167
196
  const releaseStatus = new ReleaseStatus();
168
197
  let projectMembers = null;
@@ -181,7 +210,24 @@ async function runRelease(options = {}) {
181
210
  logger.header(`Processing ${branchInfo.taskId}`);
182
211
  let createdBranch = null;
183
212
 
213
+ if (branchInfo.missingReason) {
214
+ logger.error(branchInfo.missingReason);
215
+ releaseStatus.markNoProcede(
216
+ branchInfo.taskId,
217
+ buildReleaseBranchName(branchInfo.branchName, config.git.branchPrefix),
218
+ [branchInfo.missingReason]
219
+ );
220
+ continue;
221
+ }
222
+
184
223
  try {
224
+ // Pick the commits first: it may prompt, and an invalid commit hash should fail before
225
+ // any release branch is created. Only commits tagged "[taskId]" that aren't on staging,
226
+ // plus — if the user agrees — the ones mentioning the task without following the
227
+ // convention, plus any given by hash.
228
+ const commits = options.listBranches ? null : await selectTaskCommits(branchInfo, config, releaseStatus);
229
+ if (signal.interrupted) break;
230
+
185
231
  // Create release branch
186
232
  const releaseBranch = await createReleaseBranch(
187
233
  branchInfo.branchName,
@@ -217,7 +263,10 @@ async function runRelease(options = {}) {
217
263
  // Commits are only read to build the MR description text, nothing is cherry-picked
218
264
  // here — so merge commits are kept in the list instead of being excluded/warned
219
265
  // about as "can't cherry-pick a merge", which wouldn't apply in this mode.
220
- const commits = await getCommitsToCherryPick(branchInfo.branchName, branchInfo.taskId, config.git.stagingBranch, { excludeMerges: false });
266
+ const commits = await getCommitsToCherryPick(branchInfo.branchName, branchInfo.taskId, config.git.stagingBranch, {
267
+ excludeMerges: false,
268
+ sourceRef: branchInfo.sourceRef
269
+ });
221
270
 
222
271
  const mr = await createMR(config, {
223
272
  sourceBranch: branchInfo.branchName,
@@ -241,10 +290,6 @@ async function runRelease(options = {}) {
241
290
  continue;
242
291
  }
243
292
 
244
- // Cherry-pick only commits tagged "[taskId]" on this branch that aren't already on staging,
245
- // plus — if the user agrees — the ones mentioning the task without following the convention
246
- const commits = await selectTaskCommits(branchInfo, config, releaseStatus);
247
- if (signal.interrupted) break;
248
293
  const cherryPickResult = await cherryPickCommits(branchInfo.branchName, branchInfo.taskId, config.git.stagingBranch, commits);
249
294
  if (signal.interrupted) break;
250
295
 
@@ -376,26 +421,22 @@ async function runRelease(options = {}) {
376
421
  logger.success('Release process completed');
377
422
  }
378
423
 
379
- // Resolves each { taskId, description? } to its real remote branch; prompts when several match.
380
- // Tasks without a description (bare IDs from -b) get one derived from the resolved branch name.
381
- async function resolveTasksToBranches(tasks, branchPrefix = {}) {
382
- if (tasks.length === 0) {
383
- return [];
384
- }
385
-
386
- const remoteBranches = await getRemoteBranches(branchPrefix);
424
+ // Resolves each { taskId, description? } to its real branch among `branchNames`; prompts when
425
+ // several match. Tasks without a description (bare IDs from -b) get one derived from the branch name.
426
+ async function resolveTasksToBranches(tasks, branchPrefix = {}, branchNames = [], source = 'local') {
387
427
  const branches = [];
388
428
 
389
429
  for (const task of tasks) {
390
430
  const taskId = task.taskId.toUpperCase();
391
- const matches = await resolveBranchNameForTaskId(taskId, remoteBranches, branchPrefix);
431
+ const matches = await resolveBranchNameForTaskId(taskId, branchNames, branchPrefix);
392
432
  let branchName;
433
+ let missingReason = null;
393
434
 
394
435
  if (matches.length === 1) {
395
436
  branchName = matches[0];
396
437
  logger.info(`${taskId} -> ${branchName}`);
397
438
  } else if (matches.length > 1) {
398
- logger.warn(`Multiple remote branches match ${taskId}: ${matches.join(', ')}`);
439
+ logger.warn(`Multiple branches match ${taskId}: ${matches.join(', ')}`);
399
440
  const { chosen } = await inquirer.prompt([
400
441
  {
401
442
  type: 'list',
@@ -406,17 +447,92 @@ async function resolveTasksToBranches(tasks, branchPrefix = {}) {
406
447
  ]);
407
448
  branchName = chosen;
408
449
  } else {
450
+ // Only labels the task in the summary; it's reported as not processed
409
451
  branchName = `${branchPrefix.feature || 'feature/'}${taskId.toLowerCase()}`;
410
- logger.warn(`No remote branch found matching ${taskId}; guessing ${branchName} (may not exist)`);
452
+ missingReason = `No branch found ${describeLocation(source)} matching ${taskId}`;
411
453
  }
412
454
 
413
455
  const description = task.description || describeBranch(branchName, branchPrefix);
414
- branches.push({ taskId, description, branchName });
456
+ const branchInfo = { taskId, description, branchName };
457
+ if (task.extraCommits && task.extraCommits.length > 0) {
458
+ branchInfo.extraHashes = [...task.extraCommits];
459
+ }
460
+ if (missingReason) {
461
+ branchInfo.missingReason = missingReason;
462
+ }
463
+ branches.push(branchInfo);
415
464
  }
416
465
 
417
466
  return branches;
418
467
  }
419
468
 
469
+ // 'local' (the default, from config.git.branchSource) or 'remote', overridden by --local/--remote.
470
+ // --list-branches opens each MR straight from the source branch, so that branch must be on origin.
471
+ function resolveSourceMode(options, config) {
472
+ if (options.remote) return 'remote';
473
+ if (options.local) return 'local';
474
+ const configured = config.git.branchSource || 'local';
475
+ if (options.listBranches) {
476
+ if (configured === 'local') {
477
+ logger.info('--list-branches opens each MR from the source branch, so branches are resolved on origin');
478
+ }
479
+ return 'remote';
480
+ }
481
+ return configured;
482
+ }
483
+
484
+ function describeLocation(source) {
485
+ return source === 'local' ? 'locally or on origin' : 'on origin';
486
+ }
487
+
488
+ // Sets branchInfo.sourceRef: the local branch when it exists locally (in local mode), origin's copy
489
+ // otherwise. A local branch missing commits that are on origin would silently leave them out of the
490
+ // release, so in that case the user picks which version to release (default: origin's).
491
+ async function attachSourceRefs(branches, catalog, source) {
492
+ for (const branchInfo of branches) {
493
+ if (branchInfo.missingReason) continue;
494
+ const { branchName, taskId } = branchInfo;
495
+ const where = catalog.get(branchName);
496
+ const remoteRef = `origin/${branchName}`;
497
+
498
+ if (!where) {
499
+ branchInfo.missingReason = `Branch ${branchName} not found ${describeLocation(source)}`;
500
+ continue;
501
+ }
502
+
503
+ if (source !== 'local' || !where.local) {
504
+ branchInfo.sourceRef = remoteRef;
505
+ if (source === 'local') {
506
+ logger.info(`${taskId}: ${branchName} doesn't exist locally, using ${remoteRef}`);
507
+ }
508
+ continue;
509
+ }
510
+
511
+ branchInfo.sourceRef = branchName;
512
+ if (!where.remote) continue;
513
+
514
+ const behind = await countCommitsBetween(branchName, remoteRef);
515
+ if (behind === 0) continue;
516
+
517
+ const ahead = await countCommitsBetween(remoteRef, branchName);
518
+ logger.warn(`${taskId}: local ${branchName} is missing ${behind} commit(s) that are on ${remoteRef}` +
519
+ (ahead > 0 ? `, and has ${ahead} commit(s) not pushed` : ''));
520
+ const { chosen } = await inquirer.prompt([
521
+ {
522
+ type: 'list',
523
+ name: 'chosen',
524
+ message: `Which version of ${branchName} should be released?`,
525
+ choices: [
526
+ { name: `${remoteRef} (includes the ${behind} commit(s) from origin)`, value: remoteRef },
527
+ { name: `Local ${branchName} as it is${ahead > 0 ? ` (includes the ${ahead} unpushed commit(s))` : ''}`, value: branchName }
528
+ ],
529
+ default: remoteRef
530
+ }
531
+ ]);
532
+ branchInfo.sourceRef = chosen;
533
+ }
534
+ }
535
+
420
536
  // The commits to release for a task: the ones tagged "[TASK-ID] ..." and, when some commits mention
421
537
  // the task ID without following that convention (e.g. "PB-700: fix"), the user decides whether to
422
538
  // include them too (default: no). Either way it's recorded as a note in the release summary, so a
@@ -424,31 +540,159 @@ async function resolveTasksToBranches(tasks, branchPrefix = {}) {
424
540
  async function selectTaskCommits(branchInfo, config, releaseStatus) {
425
541
  const { branchName, taskId } = branchInfo;
426
542
  const base = config.git.stagingBranch;
427
- const tagged = await getCommitsToCherryPick(branchName, taskId, base);
428
- const loose = await findLooseTaskCommits(branchName, taskId, base);
429
- if (loose.length === 0) {
430
- return tagged;
543
+ const sourceOptions = { sourceRef: branchInfo.sourceRef };
544
+ const tagged = await getCommitsToCherryPick(branchName, taskId, base, sourceOptions);
545
+ const loose = await findLooseTaskCommits(branchName, taskId, base, sourceOptions);
546
+ let commits = tagged;
547
+
548
+ if (loose.length > 0) {
549
+ const list = loose.map(describeCommit);
550
+ logger.warn(`${loose.length} commit(s) on ${branchName} mention ${taskId} but don't follow the "[${taskId}] ..." convention:`);
551
+ for (const line of list) {
552
+ logger.warn(` ${line}`);
553
+ }
554
+
555
+ const { includeLoose } = await inquirer.prompt([
556
+ {
557
+ type: 'confirm',
558
+ name: 'includeLoose',
559
+ message: `Include ${loose.length === 1 ? 'it' : 'them'} in the ${taskId} release too?`,
560
+ default: false
561
+ }
562
+ ]);
563
+
564
+ const outcome = includeLoose ? 'included at your request' : 'NOT included';
565
+ releaseStatus.addNote(taskId, `${loose.length} commit(s) mention ${taskId} without the "[${taskId}] ..." convention and were ${outcome}: ${list.join('; ')}`);
566
+ if (includeLoose) {
567
+ commits = [...tagged, ...loose];
568
+ }
569
+ }
570
+
571
+ // Commits given by hash (task file "[+hash]" or --commits); with none given and nothing found,
572
+ // offer to type them, as a commit with no task ID at all can't be found any other way
573
+ let hashes = branchInfo.extraHashes || [];
574
+ if (hashes.length === 0 && commits.length === 0) {
575
+ hashes = await askForCommitHashes(branchInfo);
576
+ }
577
+ if (hashes.length > 0) {
578
+ const added = await addCommitsByHash(hashes, commits, branchInfo, base, releaseStatus);
579
+ if (added.length > 0) {
580
+ commits = [...commits, ...added];
581
+ }
582
+ }
583
+
584
+ return commits.length > tagged.length
585
+ ? orderCommitsByHistory(branchName, commits, base, sourceOptions)
586
+ : commits;
587
+ }
588
+
589
+ // Validates commit hashes given for a task and returns the ones to cherry-pick on top of `current`.
590
+ // Unknown/ambiguous hashes and merge commits fail the task (nothing has been created yet); commits
591
+ // already on staging are skipped with a note; commits not on the source branch need confirmation.
592
+ async function addCommitsByHash(hashes, current, branchInfo, base, releaseStatus) {
593
+ const { taskId, branchName } = branchInfo;
594
+ const resolved = await resolveExtraCommits(hashes, { sourceRef: branchInfo.sourceRef, baseBranch: base });
595
+
596
+ if (resolved.errors.length > 0) {
597
+ throw new GitError(`Invalid commit(s) for ${taskId}: ${resolved.errors.join('; ')}`);
598
+ }
599
+
600
+ if (resolved.alreadyOnBase.length > 0) {
601
+ const list = resolved.alreadyOnBase.map(describeCommit);
602
+ logger.warn(`${taskId}: ${list.length} commit(s) given by hash are already on ${base} — skipped: ${list.join('; ')}`);
603
+ releaseStatus.addNote(taskId, `${list.length} commit(s) given by hash were already on ${base} and were skipped: ${list.join('; ')}`);
604
+ }
605
+
606
+ let candidates = resolved.commits;
607
+ if (resolved.offBranch.length > 0) {
608
+ const list = resolved.offBranch.map(describeCommit);
609
+ logger.warn(`${taskId}: ${list.length} commit(s) given by hash are not on ${branchName}:`);
610
+ for (const line of list) {
611
+ logger.warn(` ${line}`);
612
+ }
613
+ const { includeOffBranch } = await inquirer.prompt([
614
+ {
615
+ type: 'confirm',
616
+ name: 'includeOffBranch',
617
+ message: `Include ${list.length === 1 ? 'it' : 'them'} in the ${taskId} release anyway?`,
618
+ default: false
619
+ }
620
+ ]);
621
+ if (!includeOffBranch) {
622
+ const off = new Set(resolved.offBranch.map(c => c.hash));
623
+ candidates = candidates.filter(c => !off.has(c.hash));
624
+ releaseStatus.addNote(taskId, `${list.length} commit(s) given by hash are not on ${branchName} and were NOT included: ${list.join('; ')}`);
625
+ }
431
626
  }
432
627
 
433
- const list = loose.map(c => `${c.hash.slice(0, 8)} ${c.message}`);
434
- logger.warn(`${loose.length} commit(s) on ${branchName} mention ${taskId} but don't follow the "[${taskId}] ..." convention:`);
435
- for (const line of list) {
436
- logger.warn(` ${line}`);
628
+ const present = new Set(current.map(c => c.hash));
629
+ const added = candidates.filter(c => !present.has(c.hash));
630
+ if (added.length > 0) {
631
+ const list = added.map(describeCommit);
632
+ logger.info(`${taskId}: adding ${added.length} commit(s) given by hash: ${list.join('; ')}`);
633
+ releaseStatus.addNote(taskId, `${added.length} commit(s) added by hash: ${list.join('; ')}`);
437
634
  }
635
+ return added;
636
+ }
438
637
 
439
- const { includeLoose } = await inquirer.prompt([
638
+ // Asked when a task has no commits to release: the commit may just be missing its "[TASK-ID]" tag
639
+ async function askForCommitHashes({ taskId, branchName }) {
640
+ const { enterHashes } = await inquirer.prompt([
440
641
  {
441
642
  type: 'confirm',
442
- name: 'includeLoose',
443
- message: `Include ${loose.length === 1 ? 'it' : 'them'} in the ${taskId} release too?`,
643
+ name: 'enterHashes',
644
+ message: `No commits tagged "[${taskId}] ..." found on ${branchName}. Enter the hash(es) of the commit(s) to release?`,
444
645
  default: false
445
646
  }
446
647
  ]);
648
+ if (!enterHashes) {
649
+ return [];
650
+ }
651
+
652
+ const { commitHashes } = await inquirer.prompt([
653
+ {
654
+ type: 'input',
655
+ name: 'commitHashes',
656
+ message: 'Commit hash(es), comma-separated (blank to skip):',
657
+ filter: (value) => String(value || '').split(',').map(hash => hash.trim()).filter(Boolean),
658
+ validate: (value) => {
659
+ const list = Array.isArray(value) ? value : String(value || '').split(',').map(h => h.trim()).filter(Boolean);
660
+ const bad = list.filter(hash => !isCommitHash(hash));
661
+ return bad.length === 0 || `Not commit hashes: ${bad.join(', ')}`;
662
+ }
663
+ }
664
+ ]);
665
+ return commitHashes;
666
+ }
667
+
668
+ // Adds the --commits hashes to each task's own (from the task file); warns about task IDs in
669
+ // --commits that aren't part of this release.
670
+ function attachExtraHashes(branches, commitsByTask) {
671
+ for (const [taskId, hashes] of commitsByTask) {
672
+ const targets = branches.filter(b => b && b.taskId === taskId);
673
+ if (targets.length === 0) {
674
+ logger.warn(`--commits ${taskId}=... ignored: ${taskId} is not part of this release`);
675
+ continue;
676
+ }
677
+ for (const branchInfo of targets) {
678
+ branchInfo.extraHashes = [...new Set([...(branchInfo.extraHashes || []), ...hashes])];
679
+ }
680
+ }
681
+ }
447
682
 
448
- const outcome = includeLoose ? 'included at your request' : 'NOT included';
449
- releaseStatus.addNote(taskId, `${loose.length} commit(s) mention ${taskId} without the "[${taskId}] ..." convention and were ${outcome}: ${list.join('; ')}`);
683
+ function describeCommit(commit) {
684
+ return `${commit.hash.slice(0, 8)} ${commit.message}`;
685
+ }
450
686
 
451
- return includeLoose ? orderCommitsByHistory(branchName, [...tagged, ...loose], base) : tagged;
687
+ // Why a branch given by full name can't be released: it doesn't exist (typo, other name, already
688
+ // deleted). Lists the branches of the same task so the user can spot the right name.
689
+ async function describeMissingBranch({ branchName, taskId }, branchNames, branchPrefix, source = 'local') {
690
+ const similar = await resolveBranchNameForTaskId(taskId, branchNames, branchPrefix);
691
+ const location = describeLocation(source);
692
+ const hint = similar.length > 0
693
+ ? ` Branches ${location} for ${taskId}: ${similar.join(', ')}`
694
+ : ` No branch ${location} matches ${taskId}.`;
695
+ return `Branch ${branchName} not found ${location}.${hint}`;
452
696
  }
453
697
 
454
698
  // Builds branch info from a full branch name, extracting its task ID; null (with a warning) if none.