git_hook-pre_receive 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
18
+ vendor/cache/
data/.rdebugrc ADDED
@@ -0,0 +1,7 @@
1
+ set listsize 30
2
+ set history save on
3
+ set history size 99999
4
+ set history filename ~/.rdebug_history
5
+ set autolist
6
+ set autoeval
7
+ set autoreload
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format Fuubar
2
+ --order rand
3
+ --color
data/.simplecov ADDED
@@ -0,0 +1,8 @@
1
+ SimpleCov.start do
2
+ add_filter "/features/"
3
+ add_filter "/spec/"
4
+ add_filter "/tmp"
5
+ add_filter "/vendor"
6
+
7
+ add_group "lib", "lib"
8
+ end
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ bundler_args: --without development
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
7
+ script: bundle exec rake test:coveralls
data/.yardopts ADDED
@@ -0,0 +1,5 @@
1
+ -o doc/yard
2
+ --verbose
3
+ -
4
+ LICENSE.md
5
+ README.md
data/Gemfile ADDED
@@ -0,0 +1,35 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in git.gemspec
4
+ gemspec
5
+
6
+
7
+ group :test do
8
+ gem 'rack-test', require: 'rack/test'
9
+ gem 'rspec', require: false
10
+ gem 'fuubar', require: false
11
+ gem 'simplecov', require: false
12
+ gem 'rubocop', require: false
13
+ gem 'coveralls', require: false
14
+ end
15
+
16
+ group :development do
17
+ gem 'awesome_print', require: false
18
+ gem 'debugger'
19
+ gem 'debugger-completion'
20
+ gem 'foreman', require: false
21
+ gem 'github-markup'
22
+ gem 'pry'
23
+ gem 'pry-debugger', require: false
24
+ gem 'pry-doc', require: false
25
+ gem 'redcarpet', require: false
26
+ gem 'tmrb', require: false
27
+ gem 'yard', require: false
28
+ end
29
+
30
+ gem 'rake', group: [:development, :test], require: false
31
+ gem 'fedux_org-stdlib', group: [:development, :test], require: false
32
+ gem 'bundler', '~> 1.3', group: [:development, :test], require: false
33
+ gem 'erubis', group: [:development, :test]
34
+ gem 'versionomy', group: [:development, :test], require: false
35
+ gem 'activesupport', group: [:development, :test], require: false
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Dennis Günnewig
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,66 @@
1
+ # Git
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'git'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install git
18
+
19
+ ## Usage
20
+
21
+ Create a file `pre-receive` at `.git/hooks` with the following content:
22
+
23
+ ```ruby
24
+ #!/usr/bin/env ruby
25
+
26
+ require 'git_hook-pre_receive'
27
+ parser = Git::PreReceiveHookParser.new($stdin.read)
28
+ parser.files
29
+ ```
30
+
31
+ And do with it whatever you want.
32
+
33
+ ## Example file
34
+
35
+ Create a file `pre-receive` at `.git/hooks` with the following content:
36
+
37
+ ```ruby
38
+ #!/usr/bin/env ruby
39
+
40
+ require 'git_hook-pre_receive'
41
+ require 'pac'
42
+
43
+ class PacFileSyntaxChecker
44
+ def check(files)
45
+ files.each do |f|
46
+ begin
47
+ PAC.load f.content
48
+ rescue
49
+ $stderr.puts "Syntax error found in #{f.name}. Please check files locally again, fix the error and send update via git."
50
+ exit 1
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ parser = Git::PreReceiveHookParser.new($stdin.read)
57
+ PacFileSyntaxChecker.new.check(parser.files)
58
+ ```
59
+
60
+ ## Contributing
61
+
62
+ 1. Fork it ( http://github.com/<my-github-username>/git/fork )
63
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
64
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
65
+ 4. Push to the branch (`git push origin my-new-feature`)
66
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'fedux_org/stdlib/rake'
4
+
5
+ require 'local_pac/version'
6
+
7
+ def software
8
+ 'local_pac'
9
+ end
10
+
11
+ def version
12
+ Git::VERSION
13
+ end
14
+
15
+ def root_directory
16
+ File.expand_path('../', __FILE__)
17
+ end
18
+
19
+ def tar_file
20
+ File.join(pkg_directory, "#{software}-#{version}.tar.gz")
21
+ end
22
+
23
+ def tmp_directory
24
+ File.join(root_directory, 'tmp', "#{software}-#{version}")
25
+ end
26
+
27
+ def gem_file
28
+ File.join(root_directory, 'pkg', "#{software}-#{version}.gem")
29
+ end
30
+
31
+ def pkg_directory
32
+ File.join(root_directory, 'pkg')
33
+ end
34
+
35
+ def gem_directory
36
+ File.join(root_directory, 'vendor', 'cache')
37
+ end
38
+
39
+ task :default => 'gem:build'
40
+
41
+ file gem_file => 'gem:build'
42
+
43
+ file tmp_directory do
44
+ FileUtils.mkdir_p tmp_directory
45
+ end
46
+
47
+ namespace :gem do
48
+ desc 'build tar file'
49
+ task :package => [gem_file, tmp_directory] do
50
+ FileUtils.mv File.join(pkg_directory, "#{software}-#{version}.gem"), tmp_directory
51
+
52
+ Dir.chdir('tmp') do
53
+ sh "tar -czf #{tar_file} #{File.basename tmp_directory}"
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'git_hook-pre_receive/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'git_hook-pre_receive'
8
+ spec.version = Git::VERSION
9
+ spec.authors = ['Dennis Günnewig']
10
+ spec.email = ['dg1@vrnetze.de']
11
+ spec.summary = %q{pre-receive hook helper for git}
12
+ spec.description = %q{Provides parser to implement a pre-receive hook for git.}
13
+ spec.homepage = 'https://github.com/dg-vrnetze/git_hook-pre_receive'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+ module Git
3
+ class Command
4
+ def self.diff_tree(new)
5
+ runner = Runner.new("git diff-tree -r --root #{new}")
6
+ runner.result
7
+ end
8
+
9
+ def self.diff(old, new)
10
+ runner = Runner.new("git diff --raw #{old} #{new}")
11
+ runner.result
12
+ end
13
+
14
+ def self.init(path)
15
+ runner = Git::Runner.new("git init #{path}")
16
+ runner.result
17
+ end
18
+
19
+ def self.add(object)
20
+ runner = Git::Runner.new("git add #{object}")
21
+ runner.result
22
+ end
23
+
24
+ def self.status
25
+ runner = Git::Runner.new('git status')
26
+ runner.result
27
+ end
28
+
29
+ def self.commit(message)
30
+ runner = Git::Runner.new("git commit -m \"#{message}\"")
31
+ runner.result
32
+ end
33
+
34
+ def self.show(sha = nil)
35
+ cmd = ['git show']
36
+ cmd << " #{sha}" if sha
37
+
38
+ runner = Git::Runner.new(cmd.join(" "))
39
+ runner.result
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+ module Git
3
+ class File
4
+ attr_reader :sha, :name
5
+
6
+ def initialize(line)
7
+ @sha, @name = line.split(' ').values_at(3, 5)
8
+ @sha = @sha.gsub(/\./, '')
9
+ end
10
+
11
+ def content
12
+ runner = Runner.new("git show #{sha}")
13
+ runner.result.join "\n"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+ module Git
3
+ class PreReceiveHookParser
4
+ private
5
+
6
+ attr_reader :old_sha1, :new_sha1, :ref_name
7
+
8
+ public
9
+
10
+ def initialize(input)
11
+ @old_sha1, @new_sha1, @ref_name = input.split(" ")
12
+ end
13
+
14
+ def files
15
+ if old_sha1 == '0' * 40
16
+ result = Git::Command.diff_tree(new_sha1)
17
+ result.delete_at(0)
18
+ result.collect { |l| File.new(l) }
19
+ else
20
+ result = Git::Command.diff(old_sha1, new_sha1)
21
+ result.collect { |l| File.new(l) }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+ module Git
3
+ class Runner
4
+ private
5
+
6
+ attr_reader :command, :stdout
7
+
8
+ public
9
+
10
+ def initialize(command)
11
+ @command = command
12
+ end
13
+
14
+ def run
15
+ stdout, stderr, status = Open3.capture3(command)
16
+ fail RuntimeError, "Error executing command #{command}: #{stderr}" unless status.success?
17
+
18
+ @stdout = stdout.split("\n")
19
+ rescue Errno::ENOENT => e
20
+ fail RuntimeError, "Error executing command #{command}: #{e.message}"
21
+ end
22
+
23
+ def result
24
+ $stderr.puts command if Git.debug_mode
25
+ run
26
+ stdout
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,4 @@
1
+ #main Git
2
+ module Git
3
+ VERSION = '0.0.2'
4
+ end
@@ -0,0 +1,12 @@
1
+ require 'open3'
2
+
3
+ require 'git_hook-pre_receive/command'
4
+ require 'git_hook-pre_receive/file'
5
+ require 'git_hook-pre_receive/pre_receive_hook_parser.rb'
6
+ require 'git_hook-pre_receive/runner'
7
+
8
+ module Git
9
+ class << self
10
+ attr_accessor :debug_mode
11
+ end
12
+ end
@@ -0,0 +1,104 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Command do
5
+ let(:git_repo) { 'git_repo' }
6
+
7
+ context '#init' do
8
+ it 'creates a new repository' do
9
+ switch_to_working_directory do
10
+ Command.init(git_repo)
11
+ end
12
+
13
+ expect(path_exists?(git_repo)).to be_true
14
+ end
15
+ end
16
+
17
+ context '#add' do
18
+ it 'add dir/file to repository' do
19
+ git_init(git_repo)
20
+ create_file(File.join(git_repo, 'file.txt'))
21
+
22
+ Dir.chdir(::File.join(working_directory, git_repo)) do
23
+ Command.add('file.txt')
24
+ end
25
+
26
+ expect(git_status(git_repo)).to include("\tnew file: file.txt")
27
+ end
28
+ end
29
+
30
+ context '#commit' do
31
+ it 'commit dir/file to repository' do
32
+
33
+ git_init(git_repo)
34
+
35
+ create_file(File.join(git_repo, 'file.txt'))
36
+
37
+ git_add(git_repo, 'file.txt')
38
+
39
+ Dir.chdir(::File.join(working_directory, git_repo)) do
40
+ Command.commit('file.txt')
41
+ end
42
+
43
+ expect(git_status(git_repo)).to include('nothing to commit, working directory clean')
44
+ end
45
+ end
46
+
47
+ context '#show' do
48
+ it 'show ref/sha in repository' do
49
+ git_init(git_repo)
50
+ create_file(File.join(git_repo, 'file.txt'))
51
+ git_add(git_repo, 'file.txt')
52
+ git_commit(git_repo)
53
+
54
+ Dir.chdir(::File.join(working_directory, git_repo)) do
55
+ expect(Command.show.first).to include('commit')
56
+ end
57
+ end
58
+ end
59
+
60
+ context '#diff_tree' do
61
+ it 'diff values' do
62
+ git_init(git_repo)
63
+
64
+ create_file(File.join(git_repo, 'file.txt'))
65
+ create_file(File.join(git_repo, 'file1.txt'))
66
+ create_file(File.join(git_repo, 'file2.txt'))
67
+
68
+ git_add(git_repo, 'file.txt')
69
+ git_add(git_repo, 'file1.txt')
70
+ git_add(git_repo, 'file2.txt')
71
+
72
+ git_commit(git_repo)
73
+
74
+ commit = git_show(git_repo, nil).first.split(" ")[1]
75
+
76
+ Dir.chdir(::File.join(working_directory, git_repo)) do
77
+ expect(Command.diff_tree(commit).last).to include('file2.txt')
78
+ end
79
+ end
80
+ end
81
+
82
+ context '#diff' do
83
+ it 'diff values' do
84
+ git_init(git_repo)
85
+
86
+ create_file(File.join(git_repo, 'file.txt'))
87
+ git_add(git_repo, 'file.txt')
88
+ git_commit(git_repo)
89
+
90
+ create_file(File.join(git_repo, 'file1.txt'))
91
+ create_file(File.join(git_repo, 'file2.txt'))
92
+ git_add(git_repo, 'file1.txt')
93
+ git_add(git_repo, 'file2.txt')
94
+
95
+ git_commit(git_repo)
96
+
97
+ commit = git_show(git_repo, nil).first.split(" ")[1]
98
+
99
+ Dir.chdir(::File.join(working_directory, git_repo)) do
100
+ expect(Command.diff(commit,"#{commit}^").last).to include('file2.txt')
101
+ end
102
+ end
103
+ end
104
+ end
data/spec/file_spec.rb ADDED
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Git::File do
5
+ let(:git_repo) { 'git_repo' }
6
+
7
+ context '#initialize' do
8
+ it 'expects a line' do
9
+ line = ':000000 100644 0000000... a82b332... A test.d/test333.txt'
10
+ file = Git::File.new(line)
11
+ end
12
+ end
13
+
14
+ context '#content' do
15
+ it 'returns content of file in git repository' do
16
+ git_init(git_repo)
17
+
18
+ create_file(File.join(git_repo, 'file.txt'), 'content')
19
+ git_add(git_repo, 'file.txt')
20
+ git_commit(git_repo)
21
+
22
+ commit = git_show(git_repo, nil).first.split(" ")[1]
23
+
24
+ file = Git::File.new(git_diff_tree(git_repo, commit).last)
25
+
26
+ Dir.chdir(::File.join(working_directory, git_repo)) do
27
+ expect(file.content).to include('content')
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,64 @@
1
+ # encoding: utf-8
2
+ describe PreReceiveHookParser do
3
+ let(:git_repo) { 'git_repo' }
4
+
5
+ context '#initialize' do
6
+ it 'expects three values old_sha, new_sha, ref_name' do
7
+ PreReceiveHookParser.new('f5cb631e8b09444107408ad63c0fba13aaa23d18 76bc1a95fe094be30f7d77c9d374b0329b140ee9 /ref')
8
+ end
9
+ end
10
+
11
+ context '#files' do
12
+ it 'returns files for commit' do
13
+ git_init(git_repo)
14
+
15
+ create_file(File.join(git_repo, 'file.txt'))
16
+ git_add(git_repo, 'file.txt')
17
+ git_commit(git_repo)
18
+
19
+ create_file(File.join(git_repo, 'file1.txt'), 'content file1')
20
+ create_file(File.join(git_repo, 'file2.txt'), 'content file2')
21
+ git_add(git_repo, 'file1.txt')
22
+ git_add(git_repo, 'file2.txt')
23
+
24
+ git_commit(git_repo)
25
+
26
+ commit = git_show(git_repo, nil).first.split(" ")[1]
27
+
28
+ Dir.chdir(::File.join(working_directory, git_repo)) do
29
+ parser = PreReceiveHookParser.new("#{commit}^ #{commit} /ref/asdf/asdf")
30
+ expect(parser.files.collect { |f| f.name }).to eq(%w{file1.txt file2.txt})
31
+ end
32
+ end
33
+
34
+ it 'returns files for root commit' do
35
+ git_init(git_repo)
36
+
37
+ create_file(File.join(git_repo, 'file.txt'))
38
+ git_add(git_repo, 'file.txt')
39
+ git_commit(git_repo)
40
+
41
+ commit = git_show(git_repo, nil).first.split(" ")[1]
42
+
43
+ Dir.chdir(::File.join(working_directory, git_repo)) do
44
+ parser = PreReceiveHookParser.new("#{'0' * 40} #{commit} /ref/asdf/asdf")
45
+ expect(parser.files.collect { |f| f.name }).to eq(%w{file.txt})
46
+ end
47
+ end
48
+
49
+ it 'returns files in directories' do
50
+ git_init(git_repo)
51
+
52
+ create_file(File.join(git_repo, 'dir/file.txt'))
53
+ git_add(git_repo, 'dir/file.txt')
54
+ git_commit(git_repo)
55
+
56
+ commit = git_show(git_repo, nil).first.split(" ")[1]
57
+
58
+ Dir.chdir(::File.join(working_directory, git_repo)) do
59
+ parser = PreReceiveHookParser.new("#{'0' * 40} #{commit} /ref/asdf/asdf")
60
+ expect(parser.files.collect { |f| f.name }).to eq(%w{dir/file.txt})
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Runner do
5
+ context '#initialize' do
6
+ it 'expects a command string' do
7
+ Runner.new('echo')
8
+ end
9
+
10
+ end
11
+
12
+ context '#run' do
13
+ it 'runs a command' do
14
+ runner = Runner.new('echo')
15
+ expect {
16
+ runner.run
17
+ }.not_to raise_error
18
+ end
19
+
20
+ it 'fails on error file not found' do
21
+ runner = Runner.new('asdfasdf asfd')
22
+ expect {
23
+ runner.run
24
+ }.to raise_error RuntimeError
25
+ end
26
+
27
+ it 'fails on error status code' do
28
+ runner = Runner.new('exit 1')
29
+ expect {
30
+ runner.run
31
+ }.to raise_error RuntimeError
32
+ end
33
+ end
34
+
35
+ context '#result' do
36
+ it 'returns stdout as array' do
37
+ runner = Runner.new("echo -E \"hello\nworld\"")
38
+
39
+ expect(runner.result).to eq(["hello", "world"])
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
7
+ require 'git_hook-pre_receive'
8
+
9
+ # Pull in all of the gems including those in the `test` group
10
+ require 'bundler'
11
+ Bundler.require :default, :test, :development
12
+
13
+ Dir.glob(File.expand_path('../support/*.rb', __FILE__)).each { |f| require_relative f }
14
+
15
+ include Git
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+ require 'debugger'
3
+ require 'pry'
4
+ require 'ap'
5
+ require 'pp'
6
+
7
+ Git.debug_mode = true if ENV.key?('RSPEC_DEBUG')
@@ -0,0 +1,16 @@
1
+ require 'fedux_org/stdlib/environment'
2
+
3
+ module Git
4
+ module SpecHelper
5
+ module Environment
6
+ include FeduxOrg::Stdlib::Environment
7
+ alias_method :with_environment, :isolated_environment
8
+ end
9
+ end
10
+ end
11
+
12
+ # encoding: utf-8
13
+ RSpec.configure do |c|
14
+ c.include Git::SpecHelper::Environment
15
+ end
16
+
@@ -0,0 +1,19 @@
1
+ require 'fedux_org/stdlib/filesystem'
2
+
3
+ module Git
4
+ module SpecHelper
5
+ module Filesystem
6
+ include FeduxOrg::Stdlib::Filesystem
7
+
8
+ def root_directory
9
+ ::File.expand_path('../../../', __FILE__)
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ # encoding: utf-8
16
+ RSpec.configure do |c|
17
+ c.include Git::SpecHelper::Filesystem
18
+ c.before(:each) { cleanup_working_directory }
19
+ end
@@ -0,0 +1,54 @@
1
+ require 'fedux_org/stdlib/filesystem'
2
+
3
+ module Git
4
+ module SpecHelper
5
+ module GitHelper
6
+ include FeduxOrg::Stdlib::Filesystem
7
+
8
+ def root_directory
9
+ ::File.expand_path('../../../', __FILE__)
10
+ end
11
+
12
+ def git_init(path)
13
+ switch_to_working_directory do
14
+ Git::Command.init(path)
15
+ end
16
+ end
17
+
18
+ def git_add(repo, object)
19
+ Dir.chdir(::File.join(working_directory, repo)) do
20
+ Git::Command.add(object)
21
+ end
22
+ end
23
+
24
+ def git_commit(repo, message = 'Yay... Added objects')
25
+ Dir.chdir(::File.join(working_directory, repo)) do
26
+ Git::Command.commit(message)
27
+ end
28
+ end
29
+
30
+ def git_status(repo)
31
+ Dir.chdir(::File.join(working_directory, repo)) do
32
+ Git::Command.status
33
+ end
34
+ end
35
+
36
+ def git_show(repo, sha)
37
+ Dir.chdir(::File.join(working_directory, repo)) do
38
+ Git::Command.show(sha)
39
+ end
40
+ end
41
+
42
+ def git_diff_tree(repo, new)
43
+ Dir.chdir(::File.join(working_directory, repo)) do
44
+ Git::Command.diff_tree(new)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ # encoding: utf-8
52
+ RSpec.configure do |c|
53
+ c.include Git::SpecHelper::GitHelper
54
+ end
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |c|
2
+ c.filter_run_including :focus => true
3
+ c.run_all_when_everything_filtered = true
4
+ c.treat_symbols_as_metadata_keys_with_true_values = true
5
+ end
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require 'active_support/core_ext/string/strip'
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git_hook-pre_receive
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dennis Günnewig
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-02-14 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Provides parser to implement a pre-receive hook for git.
15
+ email:
16
+ - dg1@vrnetze.de
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - .rdebugrc
23
+ - .rspec
24
+ - .simplecov
25
+ - .travis.yml
26
+ - .yardopts
27
+ - Gemfile
28
+ - LICENSE.txt
29
+ - README.md
30
+ - Rakefile
31
+ - git_hook-pre_receive.gemspec
32
+ - lib/git_hook-pre_receive.rb
33
+ - lib/git_hook-pre_receive/command.rb
34
+ - lib/git_hook-pre_receive/file.rb
35
+ - lib/git_hook-pre_receive/pre_receive_hook_parser.rb
36
+ - lib/git_hook-pre_receive/runner.rb
37
+ - lib/git_hook-pre_receive/version.rb
38
+ - spec/command_spec.rb
39
+ - spec/file_spec.rb
40
+ - spec/pre_receive_hook_parser_spec.rb
41
+ - spec/runner_spec.rb
42
+ - spec/spec_helper.rb
43
+ - spec/support/debug.rb
44
+ - spec/support/environment.rb
45
+ - spec/support/filesystem.rb
46
+ - spec/support/git.rb
47
+ - spec/support/rspec.rb
48
+ - spec/support/string.rb
49
+ homepage: https://github.com/dg-vrnetze/git_hook-pre_receive
50
+ licenses:
51
+ - MIT
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 1.8.23
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: pre-receive hook helper for git
74
+ test_files:
75
+ - spec/command_spec.rb
76
+ - spec/file_spec.rb
77
+ - spec/pre_receive_hook_parser_spec.rb
78
+ - spec/runner_spec.rb
79
+ - spec/spec_helper.rb
80
+ - spec/support/debug.rb
81
+ - spec/support/environment.rb
82
+ - spec/support/filesystem.rb
83
+ - spec/support/git.rb
84
+ - spec/support/rspec.rb
85
+ - spec/support/string.rb
86
+ has_rdoc: