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

Overcommit & Pronto Introduction

morizyun
August 25, 2016

Overcommit & Pronto Introduction

About RubyGem "Overcommit" and "Pronto"

morizyun

August 25, 2016
Tweet

More Decks by morizyun

Other Decks in Programming

Transcript

  1. When should run Rubocop / Lint Tool? • CI(Jenkins) ->

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

    manager • Run automatically Rubocop, Brakeman, etc when you execute "Git commands"
  3. 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
  4. 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
  5. Rubocop Configuration • The configuration is stored in .overcommit.yml: gemfile:

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

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

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

    Ruby, but also JS, Scala, Java, Python!
  9. 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:
  10. pronto • Runs analysis Rubocop, etc by checking only the

    relevant changes • Created to be used on PR(GitHub), message on GitLab commits
  11. 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
  12. 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
  13. 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