if not value:
return old
- if len(value) == 40 and all(c.isalnum() for c in value):
+ if hash := startswith(value, "commit:"):
if not in_sandbox():
gitdir = Path(__file__).parent.parent
if not (gitdir / ".git").exists():
- die("Cannot check mkosi git version, not running from a git repository")
+ die("Cannot check mkosi git version, not running mkosi from a git repository")
- result = run(["git", "-C", gitdir, "merge-base", "--is-ancestor", value, "HEAD"], check=False)
+ current = run(["git", "-C", gitdir, "rev-parse", "HEAD"], stdout=subprocess.PIPE).stdout.strip()
+
+ result = run(["git", "-C", gitdir, "merge-base", "--is-ancestor", hash, current], check=False)
if result.returncode == 1:
- die(f"mkosi commit {value} or newer is required by this configuration")
+ die(
+ f"mkosi commit {hash} or newer is required by this configuration",
+ hint=f"Currently checked out commit is {current}"
+ )
elif result.returncode != 0:
- die(f"Failed to check if mkosi git checkout is newer than commit {value}")
+ die(f"Failed to check if mkosi git checkout is newer than commit {hash}")
return value
: The minimum **mkosi** version required to build this configuration. If
specified multiple times, the highest specified version is used.
- The minimum version can also be specified as a unabbreviated git
- commit hash, in which case mkosi must be executed from a git
- checkout and the specified git commit hash must be an ancestor of
- the currently checked out git commit in the repository that mkosi is
- being executed from.
+ The minimum version can also be specified as a git commit hash when
+ prefixed with `commit:`, in which case mkosi must be executed from a
+ git checkout and the specified git commit hash must be an ancestor
+ of the currently checked out git commit in the repository that mkosi
+ is being executed from.
`ConfigureScripts=`, `--configure-script=`
: Takes a comma-separated list of paths to executables that are used as