Skip to content
Merged
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
36 changes: 36 additions & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,15 @@ PostCheckout:
- 'Gemfile.lock'
- '*.gemspec'

ComposerInstall:
enabled: false
description: 'Install composer dependencies'
requires_files: true
required_executable: 'composer'
install_command: 'curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer'
flags: ['install']
include: 'composer.json'

IndexTags:
enabled: false
description: 'Generate tags file from source'
Expand Down Expand Up @@ -851,6 +860,15 @@ PostCommit:
install_command: 'npm install --save-dev commitplease'
flags: ['-1']

ComposerInstall:
enabled: false
description: 'Install composer dependencies'
requires_files: true
required_executable: 'composer'
install_command: 'curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer'
flags: ['install']
include: 'composer.json'

GitGuilt:
enabled: false
description: 'Calculate changes in blame since last commit'
Expand Down Expand Up @@ -918,6 +936,15 @@ PostMerge:
- 'Gemfile.lock'
- '*.gemspec'

ComposerInstall:
enabled: false
description: 'Install composer dependencies'
requires_files: true
required_executable: 'composer'
install_command: 'curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer'
flags: ['install']
include: 'composer.json'

IndexTags:
enabled: false
description: 'Generate tags file from source'
Expand Down Expand Up @@ -977,6 +1004,15 @@ PostRewrite:
- 'Gemfile.lock'
- '*.gemspec'

ComposerInstall:
enabled: false
description: 'Install composer dependencies'
requires_files: true
required_executable: 'composer'
install_command: 'curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer'
flags: ['install']
include: 'composer.json'

IndexTags:
enabled: false
description: 'Generate tags file from source'
Expand Down
11 changes: 11 additions & 0 deletions lib/overcommit/hook/post_checkout/composer_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'overcommit/hook/shared/composer_install'

module Overcommit::Hook::PostCheckout
# Runs `composer install` when a change is detected in the repository's
# dependencies.
#
# @see {Overcommit::Hook::Shared::ComposerInstall}
class ComposerInstall < Base
include Overcommit::Hook::Shared::ComposerInstall
end
end
11 changes: 11 additions & 0 deletions lib/overcommit/hook/post_commit/composer_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'overcommit/hook/shared/composer_install'

module Overcommit::Hook::PostCommit
# Runs `composer install` when a change is detected in the repository's
# dependencies.
#
# @see {Overcommit::Hook::Shared::ComposerInstall}
class ComposerInstall < Base
include Overcommit::Hook::Shared::ComposerInstall
end
end
11 changes: 11 additions & 0 deletions lib/overcommit/hook/post_merge/composer_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'overcommit/hook/shared/composer_install'

module Overcommit::Hook::PostMerge
# Runs `composer install` when a change is detected in the repository's
# dependencies.
#
# @see {Overcommit::Hook::Shared::ComposerInstall}
class ComposerInstall < Base
include Overcommit::Hook::Shared::ComposerInstall
end
end
11 changes: 11 additions & 0 deletions lib/overcommit/hook/post_rewrite/composer_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'overcommit/hook/shared/composer_install'

module Overcommit::Hook::PostRewrite
# Runs `composer install` when a change is detected in the repository's
# dependencies.
#
# @see {Overcommit::Hook::Shared::ComposerInstall}
class ComposerInstall < Base
include Overcommit::Hook::Shared::ComposerInstall
end
end
13 changes: 13 additions & 0 deletions lib/overcommit/hook/shared/composer_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Overcommit::Hook::Shared
# Shared code used by all ComposerInstall hooks. Runs `composer install` when
# a change is detected in the repository's dependencies.
#
# @see https://getcomposer.org/
module ComposerInstall
def run
result = execute(command)
return :fail, result.stdout unless result.success?
:pass
end
end
end
29 changes: 29 additions & 0 deletions spec/overcommit/hook/post_checkout/composer_install_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'spec_helper'

describe Overcommit::Hook::PostCheckout::ComposerInstall do
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
let(:context) { double('context') }
subject { described_class.new(config, context) }

let(:result) { double('result') }

before do
subject.stub(:execute).and_return(result)
end

context 'when composer install exits successfully' do
before do
result.stub(:success?).and_return(true)
end

it { should pass }
end

context 'when composer install exits unsuccessfully' do
before do
result.stub(success?: false, stdout: 'Composer could not find a composer.json file')
end

it { should fail_hook }
end
end
29 changes: 29 additions & 0 deletions spec/overcommit/hook/post_commit/composer_install_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'spec_helper'

describe Overcommit::Hook::PostCommit::ComposerInstall do
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
let(:context) { double('context') }
subject { described_class.new(config, context) }

let(:result) { double('result') }

before do
subject.stub(:execute).and_return(result)
end

context 'when composer install exits successfully' do
before do
result.stub(:success?).and_return(true)
end

it { should pass }
end

context 'when composer install exits unsuccessfully' do
before do
result.stub(success?: false, stdout: 'Composer could not find a composer.json file')
end

it { should fail_hook }
end
end
29 changes: 29 additions & 0 deletions spec/overcommit/hook/post_merge/composer_install_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'spec_helper'

describe Overcommit::Hook::PostMerge::ComposerInstall do
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
let(:context) { double('context') }
subject { described_class.new(config, context) }

let(:result) { double('result') }

before do
subject.stub(:execute).and_return(result)
end

context 'when composer install exits successfully' do
before do
result.stub(:success?).and_return(true)
end

it { should pass }
end

context 'when composer install exits unsuccessfully' do
before do
result.stub(success?: false, stdout: 'Composer could not find a composer.json file')
end

it { should fail_hook }
end
end
29 changes: 29 additions & 0 deletions spec/overcommit/hook/post_rewrite/composer_install_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'spec_helper'

describe Overcommit::Hook::PostRewrite::ComposerInstall do
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
let(:context) { double('context') }
subject { described_class.new(config, context) }

let(:result) { double('result') }

before do
subject.stub(:execute).and_return(result)
end

context 'when composer install exits successfully' do
before do
result.stub(:success?).and_return(true)
end

it { should pass }
end

context 'when composer install exits unsuccessfully' do
before do
result.stub(success?: false, stdout: 'Composer could not find a composer.json file')
end

it { should fail_hook }
end
end