diff --git a/CHANGELOG.md b/CHANGELOG.md index 08f00d87..9f7a128f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Overcommit Changelog +## master (unreleased) + +* Add [`GitLfs`](https://git-lfs.github.com/) post-checkout, post-commit and post-merge hooks + ## 0.42.0 ### New Features diff --git a/README.md b/README.md index b565602a..76bf0277 100644 --- a/README.md +++ b/README.md @@ -571,7 +571,6 @@ but before any objects have been transferred. If a hook fails, the push is aborted. * [Brakeman](lib/overcommit/hook/pre_push/brakeman.rb) -* [GitLfs](lib/overcommit/hook/pre_push/git_lfs.rb) * [Minitest](lib/overcommit/hook/pre_push/minitest.rb) * [ProtectedBranches](lib/overcommit/hook/pre_push/protected_branches.rb) * [Pytest](lib/overcommit/hook/pre_push/pytest.rb) diff --git a/config/default.yml b/config/default.yml index 95fcb7f1..12c01396 100644 --- a/config/default.yml +++ b/config/default.yml @@ -822,6 +822,12 @@ PostCheckout: flags: ['install'] include: 'composer.json' + GitLfs: + enabled: false + description: 'Check status of lockable files tracked by Git LFS' + required_executable: 'git-lfs' + install_command: 'brew install git-lfs' + IndexTags: enabled: false description: 'Generate tags file from source' @@ -906,6 +912,12 @@ PostCommit: flags: ['HEAD~', 'HEAD'] install_command: 'npm install -g git-guilt' + GitLfs: + enabled: false + description: 'Check status of lockable files tracked by Git LFS' + required_executable: 'git-lfs' + install_command: 'brew install git-lfs' + IndexTags: enabled: false description: 'Generate tags file from source' @@ -974,6 +986,12 @@ PostMerge: flags: ['install'] include: 'composer.json' + GitLfs: + enabled: false + description: 'Check status of lockable files tracked by Git LFS' + required_executable: 'git-lfs' + install_command: 'brew install git-lfs' + IndexTags: enabled: false description: 'Generate tags file from source' @@ -1082,6 +1100,25 @@ PrePush: required: false quiet: false + Brakeman: + enabled: false + description: 'Check for security vulnerabilities' + required_executable: 'brakeman' + flags: ['--exit-on-warn', '--quiet', '--summary'] + install_command: 'gem install brakeman' + + GitLfs: + enabled: false + description: 'Upload files tracked by Git LFS' + required_executable: 'git-lfs' + install_command: 'brew install git-lfs' + + Minitest: + enabled: false + description: 'Run Minitest test suite' + command: ['ruby', '-Ilib:test', '-rminitest', "-e 'exit! Minitest.run'"] + include: 'test/**/*_test.rb' + ProtectedBranches: enabled: false description: 'Check for illegal pushes to protected branches' @@ -1115,28 +1152,11 @@ PrePush: required_executable: 'rake' install_command: 'gem install rake' - Minitest: - enabled: false - description: 'Run Minitest test suite' - command: ['ruby', '-Ilib:test', '-rminitest', "-e 'exit! Minitest.run'"] - include: 'test/**/*_test.rb' - TestUnit: enabled: false description: 'Run Test::Unit test suite' command: ['ruby', '-Ilib:test', '-rtest/unit', "-e 'exit! Test::Unit::AutoRunner.run'"] - Brakeman: - enabled: false - description: 'Check for security vulnerabilities' - required_executable: 'brakeman' - flags: ['--exit-on-warn', '--quiet', '--summary'] - install_command: 'gem install brakeman' - - GitLfs: - enabled: false - description: 'Upload files tracked by Git LFS' - # Hooks that run during `git rebase`, before any commits are rebased. # If a hook fails, the rebase is aborted. PreRebase: diff --git a/lib/overcommit/hook/pre_push/git_lfs.rb b/lib/overcommit/hook/pre_push/git_lfs.rb deleted file mode 100644 index f29c3437..00000000 --- a/lib/overcommit/hook/pre_push/git_lfs.rb +++ /dev/null @@ -1,20 +0,0 @@ -module Overcommit::Hook::PrePush - # Invokes Git LFS command that uploads files tracked by Git LFS to the LFS storage - # - # @see https://git-lfs.github.com/ - class GitLfs < Base - def run - unless in_path?('git-lfs') - return :warn, 'This repository is configured for Git LFS but \'git-lfs\' ' \ - "was not found on your path.\nIf you no longer wish to use Git LFS, " \ - 'disable this hook by removing or setting \'enabled: false\' for GitLFS ' \ - 'hook in your .overcommit.yml file' - end - - result = execute(['git', 'lfs', 'pre-push', remote_name, remote_url]) - return :fail, result.stderr unless result.success? - - :pass - end - end -end diff --git a/spec/overcommit/hook/pre_push/git_lfs_spec.rb b/spec/overcommit/hook/pre_push/git_lfs_spec.rb deleted file mode 100644 index 1d85fc3f..00000000 --- a/spec/overcommit/hook/pre_push/git_lfs_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'spec_helper' - -describe Overcommit::Hook::PrePush::GitLfs do - let(:config) { Overcommit::ConfigurationLoader.default_configuration } - let(:context) { double('context', remote_name: 'remote_name', remote_url: 'remote_url') } - subject { described_class.new(config, context) } - - let(:result) { double('result') } - - before do - subject.stub(in_path?: true) - subject.stub(:execute).and_return(result) - end - - context 'when git-lfs is not on path' do - before do - subject.stub(in_path?: false) - end - - it { should warn } - end - - context 'when git lfs hook exits successfully' do - before do - result.stub(success?: true, stderr: '') - end - - it { should pass } - end - - context 'when git lfs hook exits unsuccessfully' do - before do - result.stub(success?: false) - result.stub(stderr: 'error: failed to push some refs') - end - - it { should fail_hook } - end -end