MCPcopy Create free account
hub / github.com/apache/solr / cmd_prepare

Function cmd_prepare

dev-tools/scripts/logchange.py:189–294  ·  view source on GitHub ↗
(args, git_root)

Source from the content-addressed store, hash-verified

187# ---------------------------------------------------------------------------
188
189def cmd_prepare(args, git_root):
190 dry_run = args.dry_run
191 do_commit = args.commit
192 version = args.version
193 release_branch = args.release_branch
194 gradle_cmd = args.gradle_cmd
195 rc_suffix = f" RC{args.rc_number}" if args.rc_number > 1 else ""
196 version_label = f"v{version}{rc_suffix}"
197
198 version_dir = git_root / "changelog" / f"v{version}"
199 unreleased_dir = git_root / "changelog" / "unreleased"
200 version_summary = f"changelog/v{version}/version-summary.md"
201
202 print(f"\n=== Changelog prepare for {version_label} on {release_branch} ===")
203 if dry_run:
204 print(" (dry-run — no changes will be made)\n")
205 else:
206 print()
207
208 print(f"[1] Checking out {release_branch}")
209 git(["checkout", release_branch], cwd=git_root, dry_run=dry_run)
210
211 if not args.skip_validation:
212 if not validate_unreleased_yamls(git_root, dry_run=dry_run):
213 sys.exit(1)
214
215 # RC1 vs RC2+ detection is done on the filesystem after checkout.
216 # In dry-run mode the checkout is skipped, so warn the user the detection
217 # may reflect the current branch rather than the release branch.
218 if dry_run and not version_dir.exists():
219 print(f" (dry-run: branch not actually checked out; RC path detection "
220 f"is based on current working tree and may be inaccurate)")
221
222 if not version_dir.exists():
223 # ------------------------------------------------------------------ #
224 # RC1 path: version folder does not yet exist #
225 # ------------------------------------------------------------------ #
226 print(f"\n[2] RC1 path — running logchangeRelease --releaseDate none --versionToRelease {version}")
227 run([gradle_cmd, "logchangeRelease", "--releaseDate", "none", "--versionToRelease", version],
228 cwd=git_root, dry_run=dry_run)
229 else:
230 # ------------------------------------------------------------------ #
231 # RC2+ path: version folder already exists, move only new entries #
232 # ------------------------------------------------------------------ #
233 print(f"\n[2] RC2+ path — copying new unreleased entries to {version_dir.name}/")
234
235 if not unreleased_dir.exists():
236 print(" changelog/unreleased/ does not exist — nothing to move.")
237 else:
238 existing = {f.name for f in version_dir.iterdir() if f.is_file()}
239 new_files = [
240 f for f in unreleased_dir.iterdir()
241 if f.is_file() and f.name not in existing
242 ]
243
244 if not new_files:
245 print(" No new entries in changelog/unreleased/ — nothing to move.")
246 else:

Callers

nothing calls this directly

Calls 9

gitFunction · 0.85
has_staged_changesFunction · 0.85
run_logchange_generateFunction · 0.85
short_shaFunction · 0.85
runFunction · 0.70
existsMethod · 0.65
exitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…