Validate derived candidate tags before checks

This commit is contained in:
2026-11-01 21:13:54 +00:00
parent abbab3c8ce
commit b91a0d1914
8 changed files with 54 additions and 14 deletions

View File

@@ -100,7 +100,7 @@ func (endpoint Endpoint) Recheck(ctx context.Context, repositoryDir string) erro
// Query reads exact main and tag refs. A command failure is unreadable,
// never evidence that a ref is absent.
func (endpoint Endpoint) Query(ctx context.Context, repositoryDir, tag string) (Snapshot, error) {
if err := checkTagRef(ctx, repositoryDir, tag); err != nil {
if err := CheckTagRef(ctx, repositoryDir, tag); err != nil {
return Snapshot{}, err
}
mainRef := "refs/heads/main"
@@ -301,7 +301,8 @@ func finalizeRef(ref RemoteRef) RemoteRef {
return ref
}
func checkTagRef(ctx context.Context, repositoryDir, tag string) error {
// CheckTagRef validates a complete tag name using Git ref rules.
func CheckTagRef(ctx context.Context, repositoryDir, tag string) error {
if tag == "" {
return fmt.Errorf("invalid Git tag name %q", tag)
}