deployments 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/.gitignore +17 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +19 -0
  5. data/Guardfile +7 -0
  6. data/LICENSE +22 -0
  7. data/README.md +28 -0
  8. data/Rakefile +2 -0
  9. data/config/deployments.yml +2 -0
  10. data/deployments.gemspec +21 -0
  11. data/lib/deployments/build.rb +36 -0
  12. data/lib/deployments/dispatcher.rb +26 -0
  13. data/lib/deployments/project.rb +41 -0
  14. data/lib/deployments/railtie.rb +13 -0
  15. data/lib/deployments/version.rb +3 -0
  16. data/lib/deployments.rb +13 -0
  17. data/lib/tasks/deployments.rake +15 -0
  18. data/spec/build_spec.rb +43 -0
  19. data/spec/deployments_spec.rb +10 -0
  20. data/spec/dispatcher_spec.rb +51 -0
  21. data/spec/fixtures/repositories/commits/README +2 -0
  22. data/spec/fixtures/repositories/commits/dot_git/COMMIT_EDITMSG +1 -0
  23. data/spec/fixtures/repositories/commits/dot_git/HEAD +1 -0
  24. data/spec/fixtures/repositories/commits/dot_git/config +6 -0
  25. data/spec/fixtures/repositories/commits/dot_git/description +1 -0
  26. data/spec/fixtures/repositories/commits/dot_git/hooks/applypatch-msg.sample +15 -0
  27. data/spec/fixtures/repositories/commits/dot_git/hooks/commit-msg.sample +24 -0
  28. data/spec/fixtures/repositories/commits/dot_git/hooks/post-commit.sample +8 -0
  29. data/spec/fixtures/repositories/commits/dot_git/hooks/post-receive.sample +15 -0
  30. data/spec/fixtures/repositories/commits/dot_git/hooks/post-update.sample +8 -0
  31. data/spec/fixtures/repositories/commits/dot_git/hooks/pre-applypatch.sample +14 -0
  32. data/spec/fixtures/repositories/commits/dot_git/hooks/pre-commit.sample +46 -0
  33. data/spec/fixtures/repositories/commits/dot_git/hooks/pre-rebase.sample +169 -0
  34. data/spec/fixtures/repositories/commits/dot_git/hooks/prepare-commit-msg.sample +36 -0
  35. data/spec/fixtures/repositories/commits/dot_git/hooks/update.sample +128 -0
  36. data/spec/fixtures/repositories/commits/dot_git/index +0 -0
  37. data/spec/fixtures/repositories/commits/dot_git/info/exclude +6 -0
  38. data/spec/fixtures/repositories/commits/dot_git/logs/HEAD +2 -0
  39. data/spec/fixtures/repositories/commits/dot_git/logs/refs/heads/master +2 -0
  40. data/spec/fixtures/repositories/commits/dot_git/objects/0e/f7d9a5b81e3944a1aff4dff604cd8ec51b643e +1 -0
  41. data/spec/fixtures/repositories/commits/dot_git/objects/54/3b9bebdc6bd5c4b22136034a95dd097a57d3dd +0 -0
  42. data/spec/fixtures/repositories/commits/dot_git/objects/56/4afd6047dd8e9ffaba37b37db3563f2a305990 +0 -0
  43. data/spec/fixtures/repositories/commits/dot_git/objects/89/21daeccfb9870c0d79efbedc6c5977a8e459d0 +0 -0
  44. data/spec/fixtures/repositories/commits/dot_git/objects/cb/57bbb4eefe68fec78490d18e78f79cbbdf5b03 +0 -0
  45. data/spec/fixtures/repositories/commits/dot_git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
  46. data/spec/fixtures/repositories/commits/dot_git/refs/heads/master +1 -0
  47. data/spec/fixtures/repositories/commits_tag/README +2 -0
  48. data/spec/fixtures/repositories/commits_tag/dot_git/COMMIT_EDITMSG +1 -0
  49. data/spec/fixtures/repositories/commits_tag/dot_git/HEAD +1 -0
  50. data/spec/fixtures/repositories/commits_tag/dot_git/config +6 -0
  51. data/spec/fixtures/repositories/commits_tag/dot_git/description +1 -0
  52. data/spec/fixtures/repositories/commits_tag/dot_git/hooks/applypatch-msg.sample +15 -0
  53. data/spec/fixtures/repositories/commits_tag/dot_git/hooks/commit-msg.sample +24 -0
  54. data/spec/fixtures/repositories/commits_tag/dot_git/hooks/post-commit.sample +8 -0
  55. data/spec/fixtures/repositories/commits_tag/dot_git/hooks/post-receive.sample +15 -0
  56. data/spec/fixtures/repositories/commits_tag/dot_git/hooks/post-update.sample +8 -0
  57. data/spec/fixtures/repositories/commits_tag/dot_git/hooks/pre-applypatch.sample +14 -0
  58. data/spec/fixtures/repositories/commits_tag/dot_git/hooks/pre-commit.sample +46 -0
  59. data/spec/fixtures/repositories/commits_tag/dot_git/hooks/pre-rebase.sample +169 -0
  60. data/spec/fixtures/repositories/commits_tag/dot_git/hooks/prepare-commit-msg.sample +36 -0
  61. data/spec/fixtures/repositories/commits_tag/dot_git/hooks/update.sample +128 -0
  62. data/spec/fixtures/repositories/commits_tag/dot_git/index +0 -0
  63. data/spec/fixtures/repositories/commits_tag/dot_git/info/exclude +6 -0
  64. data/spec/fixtures/repositories/commits_tag/dot_git/logs/HEAD +2 -0
  65. data/spec/fixtures/repositories/commits_tag/dot_git/logs/refs/heads/master +2 -0
  66. data/spec/fixtures/repositories/commits_tag/dot_git/objects/45/bedbc8cbb57792e00ad8dd9c9e7740ff3c2da5 +0 -0
  67. data/spec/fixtures/repositories/commits_tag/dot_git/objects/54/3b9bebdc6bd5c4b22136034a95dd097a57d3dd +0 -0
  68. data/spec/fixtures/repositories/commits_tag/dot_git/objects/56/4afd6047dd8e9ffaba37b37db3563f2a305990 +0 -0
  69. data/spec/fixtures/repositories/commits_tag/dot_git/objects/89/21daeccfb9870c0d79efbedc6c5977a8e459d0 +0 -0
  70. data/spec/fixtures/repositories/commits_tag/dot_git/objects/dc/7671f8a112706b6ee2404bae958fb8079dbda0 +5 -0
  71. data/spec/fixtures/repositories/commits_tag/dot_git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
  72. data/spec/fixtures/repositories/commits_tag/dot_git/refs/heads/master +1 -0
  73. data/spec/fixtures/repositories/commits_tag/dot_git/refs/tags/0.0.1 +1 -0
  74. data/spec/fixtures/repositories/commits_tags/README +3 -0
  75. data/spec/fixtures/repositories/commits_tags/config.rb +1 -0
  76. data/spec/fixtures/repositories/commits_tags/dot_git/COMMIT_EDITMSG +1 -0
  77. data/spec/fixtures/repositories/commits_tags/dot_git/HEAD +1 -0
  78. data/spec/fixtures/repositories/commits_tags/dot_git/config +6 -0
  79. data/spec/fixtures/repositories/commits_tags/dot_git/description +1 -0
  80. data/spec/fixtures/repositories/commits_tags/dot_git/hooks/applypatch-msg.sample +15 -0
  81. data/spec/fixtures/repositories/commits_tags/dot_git/hooks/commit-msg.sample +24 -0
  82. data/spec/fixtures/repositories/commits_tags/dot_git/hooks/post-commit.sample +8 -0
  83. data/spec/fixtures/repositories/commits_tags/dot_git/hooks/post-receive.sample +15 -0
  84. data/spec/fixtures/repositories/commits_tags/dot_git/hooks/post-update.sample +8 -0
  85. data/spec/fixtures/repositories/commits_tags/dot_git/hooks/pre-applypatch.sample +14 -0
  86. data/spec/fixtures/repositories/commits_tags/dot_git/hooks/pre-commit.sample +46 -0
  87. data/spec/fixtures/repositories/commits_tags/dot_git/hooks/pre-rebase.sample +169 -0
  88. data/spec/fixtures/repositories/commits_tags/dot_git/hooks/prepare-commit-msg.sample +36 -0
  89. data/spec/fixtures/repositories/commits_tags/dot_git/hooks/update.sample +128 -0
  90. data/spec/fixtures/repositories/commits_tags/dot_git/index +0 -0
  91. data/spec/fixtures/repositories/commits_tags/dot_git/info/exclude +6 -0
  92. data/spec/fixtures/repositories/commits_tags/dot_git/logs/HEAD +4 -0
  93. data/spec/fixtures/repositories/commits_tags/dot_git/logs/refs/heads/master +4 -0
  94. data/spec/fixtures/repositories/commits_tags/dot_git/objects/14/e1208852a51b6b9b504d8f341c297e17a9cc34 +0 -0
  95. data/spec/fixtures/repositories/commits_tags/dot_git/objects/36/a6db1da19073578865cf0abf3ee36d0e46bbce +3 -0
  96. data/spec/fixtures/repositories/commits_tags/dot_git/objects/43/492464a9a16b233f5e7fb091e80321ada87687 +0 -0
  97. data/spec/fixtures/repositories/commits_tags/dot_git/objects/54/3b9bebdc6bd5c4b22136034a95dd097a57d3dd +0 -0
  98. data/spec/fixtures/repositories/commits_tags/dot_git/objects/63/18a50043e3f5a213cd0d37e5b6a53b1fe61e19 +1 -0
  99. data/spec/fixtures/repositories/commits_tags/dot_git/objects/71/dcbac57898e7ec88ab676d10ae416bf0ea6024 +2 -0
  100. data/spec/fixtures/repositories/commits_tags/dot_git/objects/93/3a3e1c3f7e4860f2f47d947650596283698320 +0 -0
  101. data/spec/fixtures/repositories/commits_tags/dot_git/objects/b4/b1532fabadea3358eff3765c5dba8c86d6b8e1 +1 -0
  102. data/spec/fixtures/repositories/commits_tags/dot_git/objects/bc/02f5403a84f9fc08c16c91e4f6f3729ea67974 +0 -0
  103. data/spec/fixtures/repositories/commits_tags/dot_git/objects/c7/80ec8329c9b5b944d737dc94f7f5babdeb3745 +0 -0
  104. data/spec/fixtures/repositories/commits_tags/dot_git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
  105. data/spec/fixtures/repositories/commits_tags/dot_git/refs/heads/master +1 -0
  106. data/spec/fixtures/repositories/commits_tags/dot_git/refs/tags/0.0.1 +1 -0
  107. data/spec/fixtures/repositories/commits_tags/dot_git/refs/tags/0.0.2 +1 -0
  108. data/spec/project_spec.rb +58 -0
  109. data/spec/spec_helper.rb +6 -0
  110. metadata +296 -0
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use --create 1.9.3@deployments
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'curb'
6
+ gem 'grit'
7
+ gem 'simple-conf'
8
+
9
+ group :development do
10
+ gem 'debugger'
11
+ gem 'ruby_gntp'
12
+ gem 'guard'
13
+ gem 'guard-rspec'
14
+ end
15
+
16
+ group :test do
17
+ gem 'rspec'
18
+ end
19
+
data/Guardfile ADDED
@@ -0,0 +1,7 @@
1
+ guard 'rspec', :cli => '--format documentation', :version => 2, :all_after_pass => false, :all_on_start => false, :keep_failed => false do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^spec/.+\.rb$})
4
+ watch(%r{^lib/(.+)\.rb$}) { "spec" }
5
+ watch(%r{^lib/messaging_app/(.+)\.rb$}) { "spec" }
6
+ watch('spec/spec_helper.rb') { "spec" }
7
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Alexander Korsak
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Deployments
2
+
3
+ Library for pushing details(commits, tag, username, env) about the current app
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'deployments'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install deployments
18
+
19
+ ## Usage
20
+
21
+
22
+ ## Contributing
23
+
24
+ 1. Fork it
25
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
26
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
27
+ 4. Push to the branch (`git push origin my-new-feature`)
28
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ server: "example.com"
2
+
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/deployments/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Alexander Korsak"]
6
+ gem.email = ["alex.korsak@gmail.com"]
7
+ gem.description = %q{Library for pushing details(commits, tag, username, env) about the current app}
8
+ gem.summary = %q{Library for pushing details(commits, tag, username, env) about the current app}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "deployments"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Deployments::VERSION
17
+
18
+ gem.add_dependency('curb')
19
+ gem.add_dependency('grit')
20
+ gem.add_dependency('simple-conf')
21
+ end
@@ -0,0 +1,36 @@
1
+ require 'etc'
2
+
3
+ module Deployments
4
+ class Build
5
+ attr_reader :env, :project
6
+
7
+ def initialize(env)
8
+ @env = env
9
+ @project = Project.new('./')
10
+ end
11
+
12
+ def to_params
13
+ {
14
+ :username => username,
15
+ :env => env,
16
+ :tag => tag,
17
+ :commits => commits
18
+ }
19
+ end
20
+
21
+ private
22
+
23
+ def username
24
+ Etc.getlogin
25
+ end
26
+
27
+ def commits
28
+ project.commits
29
+ end
30
+
31
+ def tag
32
+ project.tag
33
+ end
34
+ end
35
+ end
36
+
@@ -0,0 +1,26 @@
1
+ require 'curb'
2
+
3
+ module Deployments
4
+ class Dispatcher
5
+ attr_reader :build
6
+
7
+ def initialize(build)
8
+ @build = build
9
+ end
10
+
11
+ def run
12
+ c = Curl::Easy.http_post(Deployments.server, fields)
13
+
14
+ c.response_code.to_i == 200
15
+ end
16
+
17
+ private
18
+
19
+ def fields
20
+ build.to_params.map do |key, value|
21
+ Curl::PostField.content(key, value)
22
+ end
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,41 @@
1
+ require 'grit'
2
+
3
+ module Deployments
4
+ class Project
5
+ attr_reader :path, :repo
6
+
7
+ def initialize(path)
8
+ @path = path
9
+ @repo = Grit::Repo.new(path)
10
+ end
11
+
12
+ def commits
13
+ commits = between_tags(repo) if has_commits_between_tags?
14
+
15
+ (commits || repo.commits).map do |commit|
16
+ commit.message
17
+ end
18
+ end
19
+
20
+ def tag
21
+ repo.tags.last.name if has_tags?
22
+ end
23
+
24
+ private
25
+
26
+ def between_tags(repo)
27
+ last = repo.tags.last
28
+ previous = repo.tags[repo.tags.size - 2]
29
+ repo.commits_between(previous.commit.id, last.commit.id)
30
+ end
31
+
32
+ def has_commits_between_tags?
33
+ repo.tags.size > 1
34
+ end
35
+
36
+ def has_tags?
37
+ not repo.tags.empty?
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,13 @@
1
+ require 'rails'
2
+
3
+ module Deployments
4
+
5
+ class Railtie < Rails::Railtie
6
+ railtie_name :deployments
7
+
8
+ rake_tasks do
9
+ load File.join(File.dirname(__FILE__),"../tasks/deployments.rake")
10
+ end
11
+ end
12
+ end
13
+
@@ -0,0 +1,3 @@
1
+ module Deployments
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,13 @@
1
+ require "deployments/version"
2
+ require "deployments/project"
3
+ require "deployments/build"
4
+ require "deployments/dispatcher"
5
+
6
+ require "deployments/railtie" if defined?(Rails) and Rails.version > "3.0.0"
7
+
8
+ require 'simple-conf'
9
+
10
+ module Deployments
11
+ include SimpleConf
12
+ end
13
+
@@ -0,0 +1,15 @@
1
+ require 'deployments'
2
+ require 'rake'
3
+
4
+ include Rake::DSL if defined?(Rake::DSL)
5
+
6
+ namespace :deployments do
7
+
8
+ desc "Push deployments details to the server"
9
+ task :push do
10
+ build = Build.new(ENV['deployment_env'])
11
+ dispatcher = Deployments::Dispatcher.new(build)
12
+ dispatcher.run
13
+ end
14
+ end
15
+
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ include Deployments
4
+
5
+ describe Build do
6
+ let(:build) { Build.new("staging") }
7
+
8
+ describe "interface for getting build information as json params" do
9
+ it "should return deployer name information" do
10
+ Etc.should_receive(:getlogin).and_return("john.smith")
11
+ build.to_params[:username].should == "john.smith"
12
+ end
13
+
14
+ it "should return env" do
15
+ build.should_receive(:env).and_return("staging")
16
+ build.to_params[:env].should == "staging"
17
+ end
18
+
19
+ context "in the current git project" do
20
+ let(:project_path) { './spec/fixtures/repositories/commits_tag/dot_git' }
21
+
22
+ before do
23
+ @repo = Grit::Repo.new(project_path, :is_bare => true)
24
+ Grit::Repo.should_receive(:new).and_return(@repo)
25
+
26
+ @project = Project.new(project_path)
27
+ Project.should_receive(:new).and_return(@project)
28
+ end
29
+
30
+ it "should return current tag of the git project" do
31
+ build.to_params[:tag].should == "0.0.1"
32
+ end
33
+
34
+ it "should return commits of the git project between the latests tags" do
35
+ build.to_params[:commits].should == [
36
+ "Added deployments section to the README file",
37
+ "Added README file"
38
+ ]
39
+ end
40
+ end
41
+ end
42
+ end
43
+
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe Deployments do
4
+ context "getting access to the configuration" do
5
+ it "should get server url" do
6
+ Deployments.server.should == "example.com"
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ include Deployments
4
+
5
+ describe Dispatcher do
6
+ let(:build) { Build.new("staging") }
7
+ let(:dispatcher) { Dispatcher.new(build) }
8
+
9
+ context "post deployment data" do
10
+ before do
11
+ Curl::Easy.should_receive(:http_post).and_return(response)
12
+
13
+ build.should_receive(:to_params).and_return(fields)
14
+ end
15
+
16
+ context "with valid data" do
17
+ let(:response) { double('response', :response_code => 200) }
18
+ let(:fields) do
19
+ {
20
+ :username => "john.smith",
21
+ :env => "staging",
22
+ :tag => "0.0.1",
23
+ :commits => [
24
+ "Added deployments section to the README file",
25
+ "Added README file"
26
+ ]
27
+ }
28
+ end
29
+
30
+ it "should successfully send" do
31
+ dispatcher.run.should be_true
32
+ end
33
+ end
34
+
35
+ context "with invalid data" do
36
+ let(:fields) { { :key => "invalid value" } }
37
+ let(:response) { double('response', :response_code => 500) }
38
+
39
+ it "should unlucky send" do
40
+ dispatcher.run.should be_false
41
+ end
42
+ end
43
+ end
44
+
45
+ def curl_fields
46
+ fields.map do |key, value|
47
+ Curl::PostField.content(key, value)
48
+ end
49
+ end
50
+ end
51
+
@@ -0,0 +1,2 @@
1
+ Deployments
2
+ -----------
@@ -0,0 +1 @@
1
+ Added deployments section to the README file
@@ -0,0 +1 @@
1
+ ref: refs/heads/master
@@ -0,0 +1,6 @@
1
+ [core]
2
+ repositoryformatversion = 0
3
+ filemode = true
4
+ bare = false
5
+ logallrefupdates = true
6
+ ignorecase = true
@@ -0,0 +1 @@
1
+ Unnamed repository; edit this file 'description' to name the repository.
@@ -0,0 +1,15 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script to check the commit log message taken by
4
+ # applypatch from an e-mail message.
5
+ #
6
+ # The hook should exit with non-zero status after issuing an
7
+ # appropriate message if it wants to stop the commit. The hook is
8
+ # allowed to edit the commit message file.
9
+ #
10
+ # To enable this hook, rename this file to "applypatch-msg".
11
+
12
+ . git-sh-setup
13
+ test -x "$GIT_DIR/hooks/commit-msg" &&
14
+ exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"}
15
+ :
@@ -0,0 +1,24 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script to check the commit log message.
4
+ # Called by "git commit" with one argument, the name of the file
5
+ # that has the commit message. The hook should exit with non-zero
6
+ # status after issuing an appropriate message if it wants to stop the
7
+ # commit. The hook is allowed to edit the commit message file.
8
+ #
9
+ # To enable this hook, rename this file to "commit-msg".
10
+
11
+ # Uncomment the below to add a Signed-off-by line to the message.
12
+ # Doing this in a hook is a bad idea in general, but the prepare-commit-msg
13
+ # hook is more suited to it.
14
+ #
15
+ # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
16
+ # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
17
+
18
+ # This example catches duplicate Signed-off-by lines.
19
+
20
+ test "" = "$(grep '^Signed-off-by: ' "$1" |
21
+ sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
22
+ echo >&2 Duplicate Signed-off-by lines.
23
+ exit 1
24
+ }
@@ -0,0 +1,8 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script that is called after a successful
4
+ # commit is made.
5
+ #
6
+ # To enable this hook, rename this file to "post-commit".
7
+
8
+ : Nothing
@@ -0,0 +1,15 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script for the "post-receive" event.
4
+ #
5
+ # The "post-receive" script is run after receive-pack has accepted a pack
6
+ # and the repository has been updated. It is passed arguments in through
7
+ # stdin in the form
8
+ # <oldrev> <newrev> <refname>
9
+ # For example:
10
+ # aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
11
+ #
12
+ # see contrib/hooks/ for a sample, or uncomment the next line and
13
+ # rename the file to "post-receive".
14
+
15
+ #. /usr/share/doc/git-core/contrib/hooks/post-receive-email
@@ -0,0 +1,8 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script to prepare a packed repository for use over
4
+ # dumb transports.
5
+ #
6
+ # To enable this hook, rename this file to "post-update".
7
+
8
+ exec git update-server-info
@@ -0,0 +1,14 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script to verify what is about to be committed
4
+ # by applypatch from an e-mail message.
5
+ #
6
+ # The hook should exit with non-zero status after issuing an
7
+ # appropriate message if it wants to stop the commit.
8
+ #
9
+ # To enable this hook, rename this file to "pre-applypatch".
10
+
11
+ . git-sh-setup
12
+ test -x "$GIT_DIR/hooks/pre-commit" &&
13
+ exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"}
14
+ :
@@ -0,0 +1,46 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script to verify what is about to be committed.
4
+ # Called by "git commit" with no arguments. The hook should
5
+ # exit with non-zero status after issuing an appropriate message if
6
+ # it wants to stop the commit.
7
+ #
8
+ # To enable this hook, rename this file to "pre-commit".
9
+
10
+ if git rev-parse --verify HEAD >/dev/null 2>&1
11
+ then
12
+ against=HEAD
13
+ else
14
+ # Initial commit: diff against an empty tree object
15
+ against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
16
+ fi
17
+
18
+ # If you want to allow non-ascii filenames set this variable to true.
19
+ allownonascii=$(git config hooks.allownonascii)
20
+
21
+ # Cross platform projects tend to avoid non-ascii filenames; prevent
22
+ # them from being added to the repository. We exploit the fact that the
23
+ # printable range starts at the space character and ends with tilde.
24
+ if [ "$allownonascii" != "true" ] &&
25
+ # Note that the use of brackets around a tr range is ok here, (it's
26
+ # even required, for portability to Solaris 10's /usr/bin/tr), since
27
+ # the square bracket bytes happen to fall in the designated range.
28
+ test "$(git diff --cached --name-only --diff-filter=A -z $against |
29
+ LC_ALL=C tr -d '[ -~]\0')"
30
+ then
31
+ echo "Error: Attempt to add a non-ascii file name."
32
+ echo
33
+ echo "This can cause problems if you want to work"
34
+ echo "with people on other platforms."
35
+ echo
36
+ echo "To be portable it is advisable to rename the file ..."
37
+ echo
38
+ echo "If you know what you are doing you can disable this"
39
+ echo "check using:"
40
+ echo
41
+ echo " git config hooks.allownonascii true"
42
+ echo
43
+ exit 1
44
+ fi
45
+
46
+ exec git diff-index --check --cached $against --