Skip to content

Commit

Permalink
Add '--exit-code' option for 'pronto run'
Browse files Browse the repository at this point in the history
With it, pronto exits with non-zero code if there were any
warnings/errors.

Resolves prontolabs#27
  • Loading branch information
mmozuras committed Sep 10, 2014
1 parent d8064e9 commit d4cb558
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

### New features

* [#27](https://github.com/mmozuras/pronto/issues/27): '--exit-code' option for 'pronto run'. Pronto exits with non-zero code if there were any warnings/errors.

### Changes

* [#29](https://github.com/mmozuras/pronto/issues/29): Be compatible and depend on rugged '0.21.0'.
* Performance improvement - use Rugged::Blame instead of one provided by Grit.
* Performance improvement - cache comments retrieved from GitHub.
* Performance improvement: use Rugged::Blame instead of one provided by Grit.
* Performance improvement: cache comments retrieved from GitHub.

### Bugs fixed
4 changes: 3 additions & 1 deletion lib/pronto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def self.run(commit = 'master', repo_path = '.', formatter = nil)
result = run_all_runners(patches)

formatter ||= default_formatter
formatter.format(result, repo)
puts formatter.format(result, repo)

result
end

def self.gem_names
Expand Down
7 changes: 6 additions & 1 deletion lib/pronto/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def is_thor_reserved_word?(word, type)

desc 'run', 'Run Pronto'

method_option :'exit-code',
type: :boolean,
banner: 'Exits with non-zero code if there were any warnings/errors.'

method_option :commit,
type: :string,
default: 'master',
Expand All @@ -39,7 +43,8 @@ def run
end

formatter = ::Pronto::Formatter.get(options[:formatter])
puts ::Pronto.run(options[:commit], '.', formatter)
messages = ::Pronto.run(options[:commit], '.', formatter)
exit(messages.count) if options[:'exit-code']
rescue Rugged::RepositoryError
puts '"pronto" should be run from a git repository'
end
Expand Down

0 comments on commit d4cb558

Please sign in to comment.