Sha256: 00201425056e7abc5ee6d16a73aa625f7972d41018767e478038b2ebae83656e
Contents?: true
Size: 995 Bytes
Versions: 1
Compression:
Stored size: 995 Bytes
Contents
module Danger module SemanticCommit class TypeValidator def initialize(types) @types = types || default_types end def valid?(commit) subject = commit.fetch(:subject) type_from(subject) && types.include?(type_from(subject)) end def message(_commit) <<~MSG Commit is missing a type. Start your commit with one of the following: #{types.join(',')} For more information see: [http://karma-runner.github.io/1.0/dev/git-commit-msg.html](http://karma-runner.github.io/1.0/dev/git-commit-msg.html) MSG end private attr_reader :types def type_from(subject) if matches = subject.match(/^(?<type>\w+)(\(|:)/) matches[:type] end end def default_types [ "chore", "docs", "feat", "fix", "refactor", "style", "test", ] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
danger-semantic-commit-0.3.1 | lib/semantic_commit/type_validator.rb |