Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Overcommit & Pronto Introduction

August 25, 2016

Overcommit & Pronto Introduction

About RubyGem "Overcommit" and "Pronto"


August 25, 2016

More Decks by morizyun

Other Decks in Programming


  1. overcommit & pronto introduction Japanese: @zyunnosuke English: @morizyune

  2. Today's Topic • Introducing RubyGems to improve productivity: • https://github.com/brigade/overcommit

    • https://github.com/mmozuras/pronto
  3. When should run Rubocop / Lint Tool? • CI(Jenkins) ->

    Too late... • Manual execution -> Sometimes forgot... • Before git commit/push(overcommit) -> Best
  4. Introducing overcommit • A fully configurable and extendable Git hook

    manager • Run automatically Rubocop, Brakeman, etc when you execute "Git commands"
  5. Profits of overcommit? • Readability • You can get some

    suggestions to adjust coding rule in only changed files by Rubocop, EsLint(JS), etc • Vulnerability Scan • You can scan vulnerability in your project by Brakeman, bundle-audit, etc. • Share "Git Best Practice” • Check for illegal pushes to protected branches, commit message matches expected pattern, etc
  6. Installation (1) • overcommit is installed by bundler: gem 'overcommit'

    gem 'rubocop', require: false
  7. Installation (2) • Generate git hook in each machine: #

    generate git hook $ overcommit --install #=> .git/hooks/pre-rebase #=> .git/hooks/pre-push #=> .git/hooks/pre-commit #=> .git/hooks/post-rewrite #=> .git/hooks/post-merge #=> .git/hooks/post-commit #=> .git/hooks/post-checkout #=> .git/hooks/overcommit-hook #=> .git/hooks/commit-msg
  8. Rubocop Configuration • The configuration is stored in .overcommit.yml: gemfile:

    'Gemfile' # load Gemfile in git hook PreCommit: RuboCop: enabled: true
  9. Activate Configuration • After the change, you should activate the

    configuration: $ bundle exec overcommit --sign
  10. Usage # Run pre-commit hook (Automatically run) $ git commit

    # Run pre-commit hook against all tracked files $ bundle exec overcommit --run
  11. Built-In Hooks • overcommit supports 105 tools • Not only

    Ruby, but also JS, Scala, Java, Python!
  12. overcommit tips • If you want to disable overcommit, you

    can use the follows: $ OVERCOMMIT_DISABLE=1 git commit $ export GIT_TEMPLATE_DIR=`overcommit --template-dir` • If you want to install automatically Overcommit Hooks, please run:
  13. pronto • Runs analysis Rubocop, etc by checking only the

    relevant changes • Created to be used on PR(GitHub), message on GitLab commits
  14. Installation • You can install Pronto using bundler: gem 'pronto'

    gem 'pronto-rubocop', require: false
  15. Usage for Local/GitHub # Analyze *all* changes since the *initial*

    commit (may take some time): $ pronto run --commit=$(git log -- pretty=format:%H | head -1) # if you want comments to appear on pull request diff: $ GITHUB_ACCESS_TOKEN=token pronto run -f github_pr -c origin/master
  16. Configuration for GitLab • The behavior of Pronto can be

    controlled via the .pronto.yml: all: exclude: - 'spec**/*' gitlab: slug: 445 # Project id api_private_token: 46751 # Get by Profile Seeting api_endpoint: https://gitlabcomapiv3 max_warnings: 150 verbose: false
  17. Usage for GitLab # Get the results as comments on

    GitLab commits $ GITLAB_API_ENDPOINT="https://gitlab.com/api/v3" GITLAB_API_PRIVATE_TOKEN=token pronto run -f gitlab -c origin/master
  18. Pronto Runners • Currently available: