Consistent version/branch info, fix gitorigin

- Dev dist: mntm-(branch)-(commit)
- Dev version: mntm-dev
- Dev gitbranch: (branch)
- Tag dist: mntm-(ver)
- Tag version: mntm-(ver)
- Tag gitbranch: mntm-(ver)
- Consistent between CI and local
- Gitorigin falls back based on context
- MNTM settings header won't clip with custom branch names
- About fw info page shows dirty flag and branch when custom, in same layout as OFW
This commit is contained in:
Willy-JL
2024-06-01 08:31:53 +01:00
parent 4be9768e10
commit cb2714ebe5
6 changed files with 65 additions and 38 deletions

View File

@@ -31,13 +31,17 @@ if not os.environ.get("DIST_SUFFIX"):
)
try:
local_branch = git("symbolic-ref", "HEAD", "--short")
ref = git("config", "--get", f"branch.{local_branch}.merge")
# For tags, dist name is just the tag name: mntm-(ver)
DIST_SUFFIX = git("describe", "--tags", "--abbrev=0", "--exact-match")
except Exception:
ref = "refs/heads/detached"
branch_name = re.sub("refs/\w+/", "", ref)
commit_sha = git("rev-parse", "HEAD")[:8]
DIST_SUFFIX = "mntm-" + branch_name.replace("/", "_") + "-" + commit_sha
# If not a tag, dist name is: mntm-(branch)-(commmit)
branch_name = git("rev-parse", "--abbrev-ref", "HEAD").removeprefix("mntm-")
commit_sha = git("rev-parse", "HEAD")[:8]
DIST_SUFFIX = f"mntm-{branch_name}-{commit_sha}"
# Dist name is only for naming of output files
DIST_SUFFIX = DIST_SUFFIX.replace("/", "-")
# Instead, FW version uses tag name (mntm-xxx), or "mntm-dev" if not a tag (see scripts/version.py)
# You can get commit and branch info in firmware with appropriate version_get_*() calls
# Skip external apps by default
SKIP_EXTERNAL = False