Skip to main content

Module root_version

Module root_version 

Source
Expand description

Root package version: port of RootPackageLoader::load + VersionGuesser::guessGitVersion (docs/reference/RootPackageLoader.php, VersionGuesser.php, Composer 2.10.3). Order: version from composer.json, else COMPOSER_ROOT_VERSION, else git (current branch; detached HEAD -> dev-<sha> then exact tag; feature branch -> closest parent branch by git rev-list), else 1.0.0+no-version-set. hg/fossil/svn are not ported (fallback to the default, as without a VCS).

guess_version is the VersionGuesser::guessVersion used for the root and for the packages of a path repository: git is run in the directory with no GIT_DIR pin, so it walks up to the enclosing repository exactly as Composer’s git branch does (a package without a repository of its own takes the project’s branch).

Structs§

GuessedVersion
VersionGuesser::guessVersion result after postprocess: the version (the parent branch when HEAD is on a feature branch) and, on a feature branch, the feature branch itself (feature_version, feature_pretty_version) — a path repository loads both as packages.
RootVersion
UnsupportedVersionAlias

Constants§

DEFAULT_BRANCH_ALIAS
VersionParser::DEFAULT_BRANCH_ALIAS.
DEFAULT_PRETTY_VERSION

Functions§

branch_alias
Branch alias of the root: getBranchAlias on the composer.json, the version being the pretty version retained by RootPackageLoader.
branch_alias_of
ArrayLoader::getBranchAlias (Composer 2.10.3): the alias Composer attaches to a package (root or locked) whose version is a branch (dev-* or *-dev). extra.branch-alias takes priority (-dev target, normalised by normalizeBranch, source equal to the version ignoring case, compatible numeric prefix), else 9999999-dev if default-branch is true and the version has no numeric prefix. Returns (normalised alias, pretty alias); the pretty one is installed.php’s.
detect
Determines the root version like RootPackageLoader.
git
Runs git in dir like ProcessExecutor after GitUtil::cleanEnv: no GIT_DIR/GIT_WORK_TREE (git finds the repository by walking up), English output, never an interactive prompt. None when git fails.
guess_version
VersionGuesser::guessVersion (git only) + postprocess.
normalize_branch
VersionParser::normalizeBranch (composer/semver): 1.2 -> numeric 1.2.x.x-dev (x -> 9999999), else dev-<name>.
parse_numeric_alias_prefix
VersionParser::parseNumericAliasPrefix (composer/semver): 1.2.x-dev and 1.2-dev -> 1.2., else None. Case-insensitive like the PCRE pattern.
root_version_from_env
VersionGuesser::getRootVersionFromEnv: COMPOSER_ROOT_VERSION when set and non-empty, 1.2-dev spelled 1.2.x-dev.