mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-18 13:33:45 +00:00
Backport #40363 by @lazerg The container registry rejected image names with `__` or runs of `-` (like `a__b` or `a--b`) with `NAME_INVALID`, because the name check still used the distribution-spec v1.0 grammar. This updates the pattern to the v1.1 grammar, which docker and podman already accept. Fixes: https://github.com/go-gitea/gitea/issues/40360 Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Lazizbek Ergashev <lazerg2@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
20 lines
559 B
Go
20 lines
559 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package container
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestImageNamePattern(t *testing.T) {
|
|
for _, name := range []string{"a", "a.b", "a_b", "a__b", "a-b", "a--b", "a---b", "sub/a__b/c--d"} {
|
|
assert.True(t, globalVars().imageNamePattern.MatchString(name), name)
|
|
}
|
|
for _, name := range []string{"", "A", "a___b", "a._b", "-a", "a-", "a//b", "/a", "a/"} {
|
|
assert.False(t, globalVars().imageNamePattern.MatchString(name), name)
|
|
}
|
|
}
|