git-pivotal 0.2.3 → 0.8.0
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 +2 -0
- data/CHANGELOG +9 -1
- data/Rakefile +23 -10
- data/VERSION +1 -1
- data/bin/git-bug +0 -1
- data/bin/git-chore +0 -1
- data/bin/git-feature +0 -1
- data/bin/git-finish +0 -1
- data/bin/git-info +7 -0
- data/bin/git-pick +0 -1
- data/features/bug.feature +9 -0
- data/features/chore.feature +22 -0
- data/features/feature.feature +37 -0
- data/features/finish.feature +79 -0
- data/features/info.feature +39 -0
- data/features/step_definitions/steps.rb +18 -0
- data/features/support/env.rb +5 -0
- data/features/support/git-pivotal.rb +47 -0
- data/features/test_repo/readme +1 -0
- data/features/test_repo/working.git/COMMIT_EDITMSG +1 -0
- data/features/test_repo/working.git/HEAD +1 -0
- data/features/test_repo/working.git/config +8 -0
- data/features/test_repo/working.git/description +1 -0
- data/features/test_repo/working.git/hooks/applypatch-msg.sample +15 -0
- data/features/test_repo/working.git/hooks/commit-msg.sample +24 -0
- data/features/test_repo/working.git/hooks/post-commit.sample +8 -0
- data/features/test_repo/working.git/hooks/post-receive.sample +15 -0
- data/features/test_repo/working.git/hooks/post-update.sample +8 -0
- data/features/test_repo/working.git/hooks/pre-applypatch.sample +14 -0
- data/features/test_repo/working.git/hooks/pre-commit.sample +46 -0
- data/features/test_repo/working.git/hooks/pre-rebase.sample +169 -0
- data/features/test_repo/working.git/hooks/prepare-commit-msg.sample +36 -0
- data/features/test_repo/working.git/hooks/update.sample +128 -0
- data/features/test_repo/working.git/index +0 -0
- data/features/test_repo/working.git/info/exclude +6 -0
- data/features/test_repo/working.git/logs/HEAD +1 -0
- data/features/test_repo/working.git/logs/refs/heads/master +1 -0
- data/features/test_repo/working.git/objects/0c/6f7b1384910d1a2f137590095f008a06c7e00c +0 -0
- data/features/test_repo/working.git/objects/10/ecf2b7ce989f01f3f7266e712b48d9275f2635 +0 -0
- data/features/test_repo/working.git/objects/a5/71d56305df09fb060f6ccb730b46080d305beb +0 -0
- data/features/test_repo/working.git/refs/heads/master +1 -0
- data/git-pivotal.gemspec +49 -38
- data/lib/commands/base.rb +19 -9
- data/lib/commands/finish.rb +12 -9
- data/lib/commands/info.rb +31 -0
- data/lib/commands/pick.rb +26 -22
- data/lib/git-pivotal.rb +9 -0
- data/readme.markdown +13 -0
- data/spec/commands/base_spec.rb +20 -1
- data/spec/commands/bug_spec.rb +0 -1
- data/spec/commands/chore_spec.rb +0 -1
- data/spec/commands/feature_spec.rb +0 -1
- data/spec/commands/finish_spec.rb +1 -2
- data/spec/spec_helper.rb +4 -8
- metadata +61 -52
- data/lib/pivotal/api.rb +0 -17
- data/lib/pivotal/associations.rb +0 -17
- data/lib/pivotal/attributes.rb +0 -25
- data/lib/pivotal/base.rb +0 -73
- data/lib/pivotal/collection.rb +0 -63
- data/lib/pivotal/project.rb +0 -14
- data/lib/pivotal/story.rb +0 -44
- data/lib/pivotal.rb +0 -8
- data/spec/pivotal/api_spec.rb +0 -18
- data/spec/pivotal/associations_spec.rb +0 -13
- data/spec/pivotal/attributes_spec.rb +0 -31
- data/spec/pivotal/base_spec.rb +0 -77
- data/spec/pivotal/collection_spec.rb +0 -25
- data/spec/pivotal/project_spec.rb +0 -34
- data/spec/pivotal/story_spec.rb +0 -113
- data/spec/spec.opts +0 -1
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
v 0.8.0
|
2
|
+
- Drop home-rolled PivotalTracker API for pivotal-tracker gem
|
3
|
+
- Add Gemfile for easier development
|
4
|
+
- Add better test suite with Cucumber and Aruba
|
5
|
+
- Add option for appending the branch name (rather than prepending) [Addy
|
6
|
+
Naik]
|
7
|
+
- Add new `git info` command [Addy Naik]
|
8
|
+
|
1
9
|
v 0.2.3
|
2
10
|
- Allow the developer to specify the integration branch for git finish [Graeme Mathieson]
|
3
11
|
- Fixed bug which prevented chores from finishing successfully [Joshua Vial]
|
@@ -29,4 +37,4 @@ v 0.1.1
|
|
29
37
|
v 0.1.0
|
30
38
|
- Initial release
|
31
39
|
- Basic framework for reading from Pivotal Tracker
|
32
|
-
- git pick utility
|
40
|
+
- git pick utility
|
data/Rakefile
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
-
require 'spec/rake/spectask'
|
4
3
|
|
5
4
|
$LOAD_PATH.unshift('lib')
|
6
5
|
|
@@ -14,13 +13,13 @@ begin
|
|
14
13
|
gemspec.homepage = "http://github.com/trydionel/git-pivotal"
|
15
14
|
gemspec.authors = ["Jeff Tucker", "Sam Stokes"]
|
16
15
|
|
17
|
-
gemspec.add_dependency "nokogiri"
|
18
|
-
gemspec.add_dependency "rest-client", "~>1.4.0"
|
19
16
|
gemspec.add_dependency "builder"
|
17
|
+
gemspec.add_dependency "pivotal-tracker", "~>0.3.1"
|
20
18
|
|
21
|
-
gemspec.add_development_dependency "rspec"
|
19
|
+
gemspec.add_development_dependency "rspec", "~>2.5.0"
|
22
20
|
gemspec.add_development_dependency "rcov"
|
23
|
-
gemspec.add_development_dependency "
|
21
|
+
gemspec.add_development_dependency "cucumber", "~>0.9.2"
|
22
|
+
gemspec.add_development_dependency "aruba", "~>0.2.3"
|
24
23
|
end
|
25
24
|
|
26
25
|
Jeweler::GemcutterTasks.new
|
@@ -28,8 +27,22 @@ rescue
|
|
28
27
|
puts "Jeweler not available. Install it with: gem install jeweler"
|
29
28
|
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
begin
|
31
|
+
require 'rspec/core/rake_task'
|
32
|
+
RSpec::Core::RakeTask.new do |t|
|
33
|
+
t.rspec_opts = ['--color']
|
34
|
+
t.rcov = true
|
35
|
+
t.rcov_opts = ['--exclude', 'gems']
|
36
|
+
end
|
37
|
+
rescue LoadError => e
|
38
|
+
puts "RSpec not installed"
|
39
|
+
end
|
40
|
+
|
41
|
+
begin
|
42
|
+
require 'cucumber/rake/task'
|
43
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
44
|
+
t.cucumber_opts = "features --format pretty"
|
45
|
+
end
|
46
|
+
rescue LoadError => e
|
47
|
+
puts "Cucumber not installed"
|
48
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
data/bin/git-bug
CHANGED
data/bin/git-chore
CHANGED
data/bin/git-feature
CHANGED
data/bin/git-finish
CHANGED
data/bin/git-info
ADDED
data/bin/git-pick
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
Feature: git bug
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I have a Pivotal Tracker bug
|
5
|
+
|
6
|
+
Scenario: Verifying created branch
|
7
|
+
When I run "git-bug -k 10bfe281783e2bdc2d6592c0ea21e8d5 -p 52815 -D"
|
8
|
+
Then the output should contain "Switched to a new branch '5799841-bugfix'"
|
9
|
+
And I should be on the "5799841-bugfix" branch
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Feature: git chore
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I have a Pivotal Tracker chore
|
5
|
+
|
6
|
+
Scenario: Executing with inline options
|
7
|
+
When I run "git-chore -k 10bfe281783e2bdc2d6592c0ea21e8d5 -p 52815 -D"
|
8
|
+
Then the output should contain "Switched to a new branch '5799841-chore'"
|
9
|
+
And I should be on the "5799841-chore" branch
|
10
|
+
|
11
|
+
Scenario: Executing with git configuration
|
12
|
+
Given a file named ".gitconfig" with:
|
13
|
+
"""
|
14
|
+
[pivotal]
|
15
|
+
api-token = 10bfe281783e2bdc2d6592c0ea21e8d5
|
16
|
+
full-name = Jeff Tucker
|
17
|
+
integration-branch = develop
|
18
|
+
project-id = 52815
|
19
|
+
"""
|
20
|
+
When I run "git-chore -D"
|
21
|
+
Then the output should contain "Switched to a new branch '5799841-chore'"
|
22
|
+
And I should be on the "5799841-chore" branch
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Feature: git feature
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I have a Pivotal Tracker feature
|
5
|
+
|
6
|
+
Scenario: Executing with no settings
|
7
|
+
When I run "git-feature"
|
8
|
+
Then the output should contain:
|
9
|
+
"""
|
10
|
+
Pivotal Tracker API Token and Project ID are required
|
11
|
+
"""
|
12
|
+
And the exit status should be 1
|
13
|
+
|
14
|
+
Scenario: Executing with inline options
|
15
|
+
When I run "git-feature -k 10bfe281783e2bdc2d6592c0ea21e8d5 -p 52815 -D"
|
16
|
+
Then the output should contain:
|
17
|
+
"""
|
18
|
+
Retrieving latest features from Pivotal Tracker...
|
19
|
+
Story: Test Story
|
20
|
+
URL: http://www.pivotaltracker.com/story/show/5799841
|
21
|
+
Updating feature status in Pivotal Tracker...
|
22
|
+
Switched to a new branch '5799841-feature'
|
23
|
+
"""
|
24
|
+
And I should be on the "5799841-feature" branch
|
25
|
+
|
26
|
+
Scenario: Executing with git configuration
|
27
|
+
Given a file named ".gitconfig" with:
|
28
|
+
"""
|
29
|
+
[pivotal]
|
30
|
+
api-token = 10bfe281783e2bdc2d6592c0ea21e8d5
|
31
|
+
full-name = Jeff Tucker
|
32
|
+
integration-branch = develop
|
33
|
+
project-id = 52815
|
34
|
+
"""
|
35
|
+
When I run "git-feature -D"
|
36
|
+
Then the output should contain "Switched to a new branch '5799841-feature'"
|
37
|
+
And I should be on the "5799841-feature" branch
|
@@ -0,0 +1,79 @@
|
|
1
|
+
Feature: git finish
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I have a started Pivotal Tracker feature
|
5
|
+
And I am on the "5799841-feature" branch
|
6
|
+
|
7
|
+
Scenario: Executing with no settings
|
8
|
+
When I run "git-finish"
|
9
|
+
Then the output should contain:
|
10
|
+
"""
|
11
|
+
Pivotal Tracker API Token and Project ID are required
|
12
|
+
"""
|
13
|
+
And the exit status should be 1
|
14
|
+
|
15
|
+
Scenario: Excuting with inline settings
|
16
|
+
When I run "git-finish -k 10bfe281783e2bdc2d6592c0ea21e8d5 -p 52815"
|
17
|
+
Then the output should contain:
|
18
|
+
"""
|
19
|
+
Marking Story 5799841 as finished...
|
20
|
+
Merging 5799841-feature into master
|
21
|
+
Removing 5799841-feature branch
|
22
|
+
"""
|
23
|
+
And I should be on the "master" branch
|
24
|
+
|
25
|
+
Scenario: Executing with git configuration
|
26
|
+
Given a file named ".gitconfig" with:
|
27
|
+
"""
|
28
|
+
[pivotal]
|
29
|
+
api-token = 10bfe281783e2bdc2d6592c0ea21e8d5
|
30
|
+
full-name = Jeff Tucker
|
31
|
+
project-id = 52815
|
32
|
+
"""
|
33
|
+
When I run "git-finish -k 10bfe281783e2bdc2d6592c0ea21e8d5 -p 52815"
|
34
|
+
Then the output should contain:
|
35
|
+
"""
|
36
|
+
Marking Story 5799841 as finished...
|
37
|
+
Merging 5799841-feature into master
|
38
|
+
Removing 5799841-feature branch
|
39
|
+
"""
|
40
|
+
And I should be on the "master" branch
|
41
|
+
|
42
|
+
Scenario: Specifying an integration branch
|
43
|
+
Given I have a "develop" branch
|
44
|
+
And a file named ".gitconfig" with:
|
45
|
+
"""
|
46
|
+
[pivotal]
|
47
|
+
api-token = 10bfe281783e2bdc2d6592c0ea21e8d5
|
48
|
+
full-name = Jeff Tucker
|
49
|
+
integration-branch = develop
|
50
|
+
project-id = 52815
|
51
|
+
"""
|
52
|
+
When I run "git-finish -k 10bfe281783e2bdc2d6592c0ea21e8d5 -p 52815"
|
53
|
+
Then the output should contain:
|
54
|
+
"""
|
55
|
+
Marking Story 5799841 as finished...
|
56
|
+
Merging 5799841-feature into develop
|
57
|
+
Removing 5799841-feature branch
|
58
|
+
"""
|
59
|
+
And I should be on the "develop" branch
|
60
|
+
|
61
|
+
Scenario: Closing chore stories
|
62
|
+
Given I have a started Pivotal Tracker chore
|
63
|
+
And I am on the "5799841-chore" branch
|
64
|
+
And a file named ".gitconfig" with:
|
65
|
+
"""
|
66
|
+
[pivotal]
|
67
|
+
api-token = 10bfe281783e2bdc2d6592c0ea21e8d5
|
68
|
+
full-name = Jeff Tucker
|
69
|
+
project-id = 52815
|
70
|
+
"""
|
71
|
+
When I run "git-finish -k 10bfe281783e2bdc2d6592c0ea21e8d5 -p 52815"
|
72
|
+
Then the output should contain:
|
73
|
+
"""
|
74
|
+
Marking Story 5799841 as finished...
|
75
|
+
Merging 5799841-chore into master
|
76
|
+
Removing 5799841-chore branch
|
77
|
+
"""
|
78
|
+
And I should be on the "master" branch
|
79
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Feature: git info
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I have a Pivotal Tracker feature
|
5
|
+
And I am on the "5799841-feature" branch
|
6
|
+
|
7
|
+
Scenario: Executing with no settings
|
8
|
+
When I run "git-info"
|
9
|
+
Then the output should contain:
|
10
|
+
"""
|
11
|
+
Pivotal Tracker API Token and Project ID are required
|
12
|
+
"""
|
13
|
+
And the exit status should be 1
|
14
|
+
|
15
|
+
Scenario: Executing with inline options
|
16
|
+
When I run "git-info -k 10bfe281783e2bdc2d6592c0ea21e8d5 -p 52815 -D"
|
17
|
+
Then the output should contain:
|
18
|
+
"""
|
19
|
+
Story: Test Story
|
20
|
+
URL: http://www.pivotaltracker.com/story/show/5799841
|
21
|
+
Description: This is the description!
|
22
|
+
"""
|
23
|
+
|
24
|
+
Scenario: Executing with git configuration
|
25
|
+
Given a file named ".gitconfig" with:
|
26
|
+
"""
|
27
|
+
[pivotal]
|
28
|
+
api-token = 10bfe281783e2bdc2d6592c0ea21e8d5
|
29
|
+
full-name = Jeff Tucker
|
30
|
+
integration-branch = develop
|
31
|
+
project-id = 52815
|
32
|
+
"""
|
33
|
+
When I run "git-info"
|
34
|
+
Then the output should contain:
|
35
|
+
"""
|
36
|
+
Story: Test Story
|
37
|
+
URL: http://www.pivotaltracker.com/story/show/5799841
|
38
|
+
Description: This is the description!
|
39
|
+
"""
|
@@ -0,0 +1,18 @@
|
|
1
|
+
STORY_TYPE = /feature|bug|chore|release/
|
2
|
+
STORY_STATE = /unscheduled|unstarted|started|finished|delivered|accepted|rejected/
|
3
|
+
|
4
|
+
Given /^I have a(?:n)? (#{STORY_STATE})?\s?Pivotal Tracker (#{STORY_TYPE})$/ do |status, type|
|
5
|
+
update_test_story(type, status)
|
6
|
+
end
|
7
|
+
|
8
|
+
Given /^I am on the "([^"]*)" branch$/ do |branch|
|
9
|
+
`git checkout -b #{branch} > /dev/null 2>&1`
|
10
|
+
end
|
11
|
+
|
12
|
+
Given /^I have a "([^"]*)" branch$/ do |branch|
|
13
|
+
`git branch #{branch} > /dev/null 2>&1`
|
14
|
+
end
|
15
|
+
|
16
|
+
Then /^I should be on the "([^"]*)" branch$/ do |branch|
|
17
|
+
current_branch.should == branch
|
18
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
PIVOTAL_API_KEY = "10bfe281783e2bdc2d6592c0ea21e8d5"
|
4
|
+
PIVOTAL_TEST_PROJECT = 52815
|
5
|
+
PIVOTAL_TEST_ID = 5799841
|
6
|
+
|
7
|
+
Before do
|
8
|
+
build_temp_paths
|
9
|
+
set_env_variables
|
10
|
+
end
|
11
|
+
|
12
|
+
at_exit do
|
13
|
+
# The features seem to have trouble repeating accurately without
|
14
|
+
# setting the test story to an unstarted feature for the next run.
|
15
|
+
update_test_story("feature", "unstarted")
|
16
|
+
end
|
17
|
+
|
18
|
+
def build_temp_paths
|
19
|
+
_mkdir(current_dir)
|
20
|
+
|
21
|
+
test_repo = File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_repo'))
|
22
|
+
FileUtils.cp_r(test_repo, current_dir)
|
23
|
+
Dir.chdir(File.join(current_dir, 'test_repo')) do
|
24
|
+
FileUtils.mv('working.git', '.git')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_env_variables
|
29
|
+
set_env "GIT_DIR", File.expand_path(File.join(current_dir, 'test_repo', '.git'))
|
30
|
+
set_env "GIT_WORK_TREE", File.expand_path(File.join(current_dir, 'test_repo'))
|
31
|
+
set_env "HOME", File.expand_path(current_dir)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update_test_story(type, status = nil)
|
35
|
+
PivotalTracker::Client.token = PIVOTAL_API_KEY
|
36
|
+
project = PivotalTracker::Project.find(PIVOTAL_TEST_PROJECT)
|
37
|
+
story = project.stories.find(PIVOTAL_TEST_ID)
|
38
|
+
|
39
|
+
story.update(:story_type => type.to_s,
|
40
|
+
:current_state => status || "unstarted",
|
41
|
+
:estimate => (type.to_s == "feature" ? 1 : nil))
|
42
|
+
sleep(4) # let the data propagate
|
43
|
+
end
|
44
|
+
|
45
|
+
def current_branch
|
46
|
+
`git symbolic-ref HEAD`.chomp.split('/').last
|
47
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Testing repo
|
@@ -0,0 +1 @@
|
|
1
|
+
A blank repo for testing
|
@@ -0,0 +1 @@
|
|
1
|
+
ref: refs/heads/master
|
@@ -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,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,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 --
|