Releaser.CommitValidator (releaser v0.0.5)

Copy Markdown View Source

Validates commit messages against Conventional Commits + project-specific rules.

Pure functions — no git, no filesystem. The Mix task wraps this module to read a COMMIT_EDITMSG file and produce CLI output.

Rules applied

  • Format: <type>(<scope>)?(!)?: <subject>
  • Type: must be in bump_rules or allowed_types when strict_types: true
  • Scope: must be in allowed_scopes (auto-inferred from app names + aliases when not configured) when strict_scopes: true
  • No scope: rejected when allow_no_scope: false
  • Subject length: max_subject_length, default 100

Return

  • :ok — valid
  • {:error, reason} — one of:
    • :missing_header
    • :bad_format
    • {:unknown_type, type, allowed}
    • {:unknown_scope, scope, allowed}
    • :scope_required
    • {:subject_too_long, length, max}

Summary

Functions

Humanizes an error reason for display.

Returns the list of allowed scopes, resolving from config + apps.

Validates a raw commit message string.

Functions

format_error(reason, commits_config, apps)

@spec format_error(term(), map(), [map()]) :: String.t()

Humanizes an error reason for display.

resolve_allowed_scopes(commits_config, apps)

@spec resolve_allowed_scopes(map(), [map()]) :: [String.t()]

Returns the list of allowed scopes, resolving from config + apps.

validate(raw, commits_config, opts \\ [])

@spec validate(String.t(), map(), keyword()) :: :ok | {:error, term()}

Validates a raw commit message string.

Returns :ok or {:error, reason}.