]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
script: sanitize git branch names for OCI tag compliance 66404/head
authorKefu Chai <k.chai@proxmox.com>
Tue, 25 Nov 2025 11:02:32 +0000 (19:02 +0800)
committerKefu Chai <k.chai@proxmox.com>
Mon, 8 Dec 2025 07:50:30 +0000 (15:50 +0800)
commit832d2836b17962f13fbe48a81ba20570ea7e2a16
tree158706ad5d1f1e40b0c1c8f888496da17ea2715c
parenta0519047d7e2c749a4cc9deb7a5490b064a7fe4c
script: sanitize git branch names for OCI tag compliance

Git branch names commonly use forward slashes for hierarchy
(e.g., feature/my-branch), but OCI container image tags cannot
contain slashes. This causes build-with-container.py to fail when
building images from branches with slashes in their names.

Add _sanitize_for_oci_tag() function to convert branch names into
OCI-compliant tags by:
- Replacing '/' with '-'
- Replacing other invalid characters with '_'
- Stripping leading invalid characters
- Truncating to 128 characters (OCI tag max length)

Apply sanitization consistently to both auto-detected branches
and manually specified --current-branch arguments.

Fixes branch name handling for pull request branches and other
hierarchical naming schemes.

References:
- OCI Image Spec: tags must match [a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}
  https://github.com/opencontainers/image-spec/blob/main/descriptor.md
- Git allows '/' in branch names for hierarchical organization
  https://git-scm.com/docs/git-check-ref-format
  https://docs.github.com/en/get-started/using-git/dealing-with-special-characters-in-branch-and-tag-names

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
src/script/build-with-container.py