Skip to content
This repository was archived by the owner on May 5, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DS_Store
pkg
.idea/
Gemfile.lock
.ruby-version
.ruby-gemset
.ruby-version
.yardoc/
Gemfile.lock
pkg
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ language: ruby
cache: bundler

rvm:
- 2.2
- 2.3.3
- 2.4.0
- jruby-9
- 2.4.5
- 2.5.5
- 2.6.2
- jruby-9.2.6.0

script:
- bundle exec rake
Expand Down
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,22 @@ The format is based on [Keep a Changelog][keep] and this project adheres to

## [Unreleased]

[Unreleased]: https://github.com/jonallured/danger-commit_lint/compare/v0.0.6...master
[Unreleased]: https://github.com/SimeonC/danger-angular_commit_lint/compare/v1.2.0...master

## [1.2.0] - 2019-05-05

### Changed

* Ignore git generated subject in commit messages [#21][]
* Express danger plugin dependency in terms of plugin api [#24][]

[1.2.0]: https://github.com/SimeonC/danger-angular_commit_lint/compare/v0.0.6...v1.2.0
[#21]: https://github.com/jonallured/danger-commit_lint/pull/21
[#24]: https://github.com/jonallured/danger-commit_lint/pull/24

### Removed

* Drop Ruby 2.3 from Travis [1aa9cff][1aa9cff]

## [0.0.6] - 2017-04-27

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ That will check each commit in the PR to ensure the following is true:

* Commit subject follows the angular pattern of `<type>(<scope>): <subject>`
* Commit <subject> begins with a capital letter (`subject_cap`)
* Commit <subject> is more than one word (`subject_word`)
* Commit <subject> is more than one word (`subject_words`)
* Commit <subject> is no longer than 50 characters (`subject_length`)
* Commit <subject> does not end in a period (`subject_period`)
* Commit <subject> and body are separated by an empty line (`empty_line`)
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require 'rubocop/rake_task'

RSpec::Core::RakeTask.new(:spec)

task default: [:spec, :rubocop, :spec_docs]
task default: %i[rubocop spec spec_docs]

desc 'Run RuboCop on the lib/specs directory'
RuboCop::RakeTask.new(:rubocop) do |task|
Expand Down
17 changes: 8 additions & 9 deletions danger-angular_commit_lint.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'angular_commit_lint/gem_version.rb'

Expand All @@ -13,17 +12,17 @@ Gem::Specification.new do |spec|
spec.homepage = 'https://github.com/simeonc/danger-angular_commit_lint'
spec.license = 'MIT'

spec.files = `git ls-files`.split($/)
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

spec.add_runtime_dependency 'danger', '~> 5.0'
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'

spec.add_development_dependency 'bundler', '~> 1.3'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec', '~> 3.4'
spec.add_development_dependency "rubocop", "~> 0.41"
spec.add_development_dependency "yard", "~> 0.8"
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'yard'
end
2 changes: 1 addition & 1 deletion lib/angular_commit_lint/gem_version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module AngularCommitLint
VERSION = '1.1.2'.freeze
VERSION = '1.2.0'.freeze
end
1 change: 1 addition & 0 deletions lib/angular_commit_lint/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def disabled_checks

def warning_checks
return checks if @config[:warn] == :all

@config[:warn] || []
end

Expand Down
10 changes: 9 additions & 1 deletion lib/angular_commit_lint/subject_length_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ class SubjectLengthCheck < CommitCheck # :nodoc:
def message
'Please limit commit subject line to 50 characters.'.freeze
end
GIT_GENERATED_SUBJECT = /^Merge branch \'.+\' into\ /.freeze
GITHUB_GENERATED_SUBJECT = /^Merge pull request #\d+ from\ /.freeze

attr_reader :subject

def self.type
:subject_length
Expand All @@ -16,7 +20,11 @@ def initialize(message, _config = {})
end

def fail?
@subject.length > 50
subject.length > 50 && !merge_commit?
end

def merge_commit?
subject =~ /#{GIT_GENERATED_SUBJECT}|#{GITHUB_GENERATED_SUBJECT}/
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/commit_lint_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path('../spec_helper', __FILE__)
require File.expand_path('spec_helper', __dir__)

# rubocop:disable Metrics/LineLength

Expand All @@ -10,7 +10,7 @@
subject_period: 'fix: This subject line ends in a period.',
empty_line: "fix: This subject line is fine\nBut then I forgot the empty line separating the subject and the body.",
all_errors: "this is a really long subject and it even ends in a period.\nNot to mention the missing empty line!",
valid: "fix: This is a valid message\n\nYou can tell because it meets all the criteria and the linter does not complain."
valid: "fix: This is a valid message\n\nYou can tell because it meets all the criteria and the linter does not complain."
}.freeze

BLANK_MESSAGE = {
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'pathname'
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
ROOT = Pathname.new(File.expand_path('..', __dir__))
$LOAD_PATH.unshift((ROOT + 'lib').to_s)
$LOAD_PATH.unshift((ROOT + 'spec').to_s)

Expand Down
43 changes: 43 additions & 0 deletions spec/subject_length_check_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require File.expand_path('spec_helper', __dir__)

describe Danger::DangerAngularCommitLint::SubjectLengthCheck do
describe '#fail?' do
let(:commit_subject) { 'This is a common valid commit message' }

let(:message) do
{
subject: commit_subject
}
end

subject do
described_class.new(message).fail?
end

it { expect(subject).to be_falsy }

context 'when message is invalid' do
let(:commit_subject) do
'This is a really long subject line and should result in an error'
end

it { expect(subject).to be_truthy }
end

context 'when message is a merge commit generated by git' do
let(:commit_subject) do
"Merge branch 'ignore-length-on-git-merge-commits' into master"
end

it { expect(subject).to be_falsy }
end

context 'when message is a merge commit generated by GitHub' do
let(:commit_subject) do
'Merge pull request #1234 from jonallured/ignore-length-merge-commits'
end

it { expect(subject).to be_falsy }
end
end
end