configureRepo method
Asks the publish questions for the single repository repoDir and
returns the answers plus the registry baseline the increment preview was
calculated from.
The baseline travels with the answers so the caller can predict the version this repo will publish — without a second registry lookup.
No repository header is logged here; the caller owns it, because it alone knows whether it has something to say about this repo at all.
Implementation
Future<RepoPublishPlan> configureRepo({
required Directory repoDir,
required String seedMessage,
gg.RepoPublishConfig? existing,
bool mergeOnly = false,
}) async {
final repoName = path.basename(repoDir.path);
final baseline = await _baselineVersion(repoDir);
// A merge-only run releases nothing — no version bump, no changelog
// heading, no tag. Asking for an increment would offer a version that
// is never created, so the prompt is skipped and none is stored.
final increment = mergeOnly
? null
: await _versionSelector.selectIncrement(
currentVersion: baseline,
preselect: existing?.versionIncrement,
);
// The seed pre-fills the editor. The caller resolved it — an explicit
// `-m` beats a recorded answer, which beats the ticket description — so
// only a caller that supplies none falls back to the recorded answer
// here. A merge message must never be empty, so an empty edit falls back
// to the same seed and finally to a generic default.
final seed = seedMessage.isEmpty
? (existing?.mergeMessage ?? '')
: seedMessage;
var message = (await _editMessage(seed) ?? '').trim();
if (message.isEmpty) {
message = seed;
}
if (message.isEmpty) {
message = 'Publish $repoName';
}
return RepoPublishPlan(
// Built explicitly rather than via copyWith: a merge-only run must
// clear a recorded increment, not inherit it. The AI-maintained halves
// (nextCommitMessage, commits) are carried over untouched.
config: gg.RepoPublishConfig(
mergeMessage: message,
versionIncrement: increment,
nextCommitMessage: existing?.nextCommitMessage,
commits: existing?.commits,
),
baseline: baseline,
);
}