git-topic 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.gvimrc +23 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/.vimproject +26 -0
- data/.vimrc +1 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +63 -0
- data/History.txt +6 -0
- data/LICENSE +20 -0
- data/README.rdoc +192 -0
- data/Rakefile +62 -0
- data/VERSION +1 -0
- data/autotest/discover.rb +1 -0
- data/bin/git-topic +143 -0
- data/git-topic.gemspec +127 -0
- data/lib/git-topic.rb +375 -0
- data/lib/util.rb +34 -0
- data/spec/git-topic_spec.rb +378 -0
- data/spec/spec_helper.rb +56 -0
- data/spec/template/origin/HEAD +1 -0
- data/spec/template/origin/config +7 -0
- data/spec/template/origin/description +1 -0
- data/spec/template/origin/hooks/applypatch-msg.sample +15 -0
- data/spec/template/origin/hooks/commit-msg.sample +24 -0
- data/spec/template/origin/hooks/post-commit.sample +8 -0
- data/spec/template/origin/hooks/post-receive.sample +15 -0
- data/spec/template/origin/hooks/post-update.sample +8 -0
- data/spec/template/origin/hooks/pre-applypatch.sample +14 -0
- data/spec/template/origin/hooks/pre-commit.sample +46 -0
- data/spec/template/origin/hooks/pre-rebase.sample +169 -0
- data/spec/template/origin/hooks/prepare-commit-msg.sample +36 -0
- data/spec/template/origin/hooks/update.sample +128 -0
- data/spec/template/origin/info/exclude +6 -0
- data/spec/template/origin/objects/0a/da6d051b94cd0df50f5a0b7229aec26f0d2cdf +0 -0
- data/spec/template/origin/objects/0c/e06c616769768f09f5e629cfcc68eabe3dee81 +0 -0
- data/spec/template/origin/objects/20/049991cdafdce826f5a3c01e10ffa84d6997ec +0 -0
- data/spec/template/origin/objects/33/1d827fd47fb234af54e3a4bbf8c6705e9116cc +3 -0
- data/spec/template/origin/objects/41/51899b742fd6b1c873b177b9d13451682089bc +0 -0
- data/spec/template/origin/objects/44/ffd9c9c8b52b201659e3ad318cdad6ec836b46 +0 -0
- data/spec/template/origin/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- data/spec/template/origin/objects/55/eeb01bdf874d1a35870bcf24a970c475c63344 +0 -0
- data/spec/template/origin/objects/8d/09f9b8d80ce282218125cb0cbf53cccf022203 +0 -0
- data/spec/template/origin/objects/b4/8e68d5cac189af36abe48e893d11c24b7b2a19 +0 -0
- data/spec/template/origin/objects/c0/838ed2ee8f2e83c8bda859fc5e332b92f0a5a3 +1 -0
- data/spec/template/origin/objects/cd/f7b9dbc4911a0d1404db54cde2ed448f6a6afd +0 -0
- data/spec/template/origin/objects/d2/6b33daea1ed9823a189992bba38fbc913483c1 +0 -0
- data/spec/template/origin/objects/fe/4e254557e19f338f40ccfdc00a7517771db880 +0 -0
- data/spec/template/origin/refs/heads/master +1 -0
- data/spec/template/origin/refs/heads/rejected/davidjh/krakens +1 -0
- data/spec/template/origin/refs/heads/review/davidjh/pirates +1 -0
- data/spec/template/origin/refs/heads/review/user24601/ninja-basic +1 -0
- data/spec/template/origin/refs/heads/review/user24601/zombie-basic +1 -0
- metadata +158 -0
@@ -0,0 +1,378 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
|
6
|
+
describe GitTopic do
|
7
|
+
|
8
|
+
before( :all ) do
|
9
|
+
@starting_dir = Dir.pwd
|
10
|
+
@user = ENV['USER'] || `whoami`
|
11
|
+
end
|
12
|
+
|
13
|
+
before( :each ) do
|
14
|
+
# setup the directories
|
15
|
+
FileUtils.rm_rf './tmp'
|
16
|
+
FileUtils.mkdir './tmp'
|
17
|
+
|
18
|
+
%w(fresh in-progress dirty origin).each do |repo|
|
19
|
+
FileUtils.cp_r "spec/template/#{repo}", './tmp'
|
20
|
+
|
21
|
+
# set template branches to their proper name (i.e. matching @user)
|
22
|
+
Dir.chdir "./tmp/#{repo}"
|
23
|
+
git_branches.each do |orig_name|
|
24
|
+
new_name = orig_name.gsub( 'USER', @user )
|
25
|
+
system(
|
26
|
+
"git branch -m #{orig_name} #{new_name}"
|
27
|
+
) unless orig_name == new_name
|
28
|
+
end
|
29
|
+
Dir.chdir @starting_dir
|
30
|
+
end
|
31
|
+
Dir.chdir './tmp'
|
32
|
+
|
33
|
+
# capture output
|
34
|
+
@output = ''
|
35
|
+
@err = ''
|
36
|
+
$stdout.stub!( :write ) { |*args| @output.<<( *args )}
|
37
|
+
$stderr.stub!( :write ) { |*args| @err.<<( *args )}
|
38
|
+
end
|
39
|
+
|
40
|
+
after( :each ) { Dir.chdir @starting_dir }
|
41
|
+
|
42
|
+
|
43
|
+
# helpers # {{{
|
44
|
+
|
45
|
+
def git_branch
|
46
|
+
all_branches = `git branch --no-color`.split( "\n" )
|
47
|
+
current_branch = all_branches.find{|b| b =~ /^\*/}
|
48
|
+
|
49
|
+
current_branch[ 2..-1 ] unless current_branch.nil?
|
50
|
+
end
|
51
|
+
|
52
|
+
def git_head
|
53
|
+
`git rev-parse HEAD`.chomp
|
54
|
+
end
|
55
|
+
|
56
|
+
def git_config( key )
|
57
|
+
`git config #{key}`.chomp
|
58
|
+
end
|
59
|
+
|
60
|
+
def git_branch_merge
|
61
|
+
git_config "branch.#{git_branch}.merge"
|
62
|
+
end
|
63
|
+
|
64
|
+
def git_branch_remote
|
65
|
+
git_config "branch.#{git_branch}.remote"
|
66
|
+
end
|
67
|
+
|
68
|
+
def git_branches
|
69
|
+
`git branch --no-color`.split( "\n" ).map do |bn|
|
70
|
+
bn.gsub /^\*?\s*/, ''
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def git_remote_branches
|
75
|
+
`git branch -r --no-color`.split( "\n" ).map do |bn|
|
76
|
+
bn.gsub! %r{^\s*origin/}, ''
|
77
|
+
bn.gsub! %r{ ->.*$}, ''
|
78
|
+
bn
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# }}}
|
83
|
+
|
84
|
+
|
85
|
+
describe "#work_on" do
|
86
|
+
|
87
|
+
describe "in fresh" do
|
88
|
+
before( :each ) { Dir.chdir( 'fresh' )}
|
89
|
+
after( :each ) { Dir.chdir( '..' )}
|
90
|
+
|
91
|
+
it "
|
92
|
+
should create (and switch to) a new branch with a name that matches the
|
93
|
+
given topic, in the wip namespace. A remote tracking branch should also
|
94
|
+
be set up.
|
95
|
+
".oneline do
|
96
|
+
|
97
|
+
GitTopic.work_on( 'topic' )
|
98
|
+
git_branch.should == "wip/#{@user}/topic"
|
99
|
+
git_branch_remote.should == 'origin'
|
100
|
+
git_branch_merge.should == "refs/heads/wip/#{@user}/topic"
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should fail if no topic is given" do
|
104
|
+
lambda { GitTopic.work_on( nil )}.should raise_error
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "in in-progress" do
|
110
|
+
|
111
|
+
before( :each ) { Dir.chdir( 'in-progress' )}
|
112
|
+
after( :each ) { Dir.chdir( '..' )}
|
113
|
+
|
114
|
+
|
115
|
+
it "should switch to (rather than create) an existing topic branch" do
|
116
|
+
git_branches.should include( "wip/#{@user}/zombie-basic" )
|
117
|
+
lambda{ GitTopic.work_on 'zombie-basic' }.should_not raise_error
|
118
|
+
|
119
|
+
git_branch.should == "wip/#{@user}/zombie-basic"
|
120
|
+
end
|
121
|
+
|
122
|
+
it "
|
123
|
+
should use (and then destroy) the rejected branch for the topic, if one
|
124
|
+
exists
|
125
|
+
".oneline do
|
126
|
+
|
127
|
+
git_remote_branches.should include( "rejected/#{@user}/krakens" )
|
128
|
+
GitTopic.work_on 'krakens'
|
129
|
+
git_branch.should == "wip/#{@user}/krakens"
|
130
|
+
git_remote_branches.should_not include( "rejected/#{@user}/krakens" )
|
131
|
+
git_remote_branches.should include( "wip/#{@user}/krakens" )
|
132
|
+
git_head.should == '44ffd9c9c8b52b201659e3ad318cdad6ec836b46'
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
describe "#done" do
|
139
|
+
|
140
|
+
describe "in in-progress" do
|
141
|
+
|
142
|
+
before( :each ) { Dir.chdir 'in-progress' }
|
143
|
+
after( :each ) { Dir.chdir '..' }
|
144
|
+
|
145
|
+
describe "without an argument" do
|
146
|
+
|
147
|
+
it "should fail if the working tree is dirty" do
|
148
|
+
GitTopic.work_on 'zombie-basic'
|
149
|
+
File.open( 'foo', 'w' ){|f| f.puts "some content" }
|
150
|
+
system "git add -N foo"
|
151
|
+
|
152
|
+
lambda{ GitTopic.done }.should raise_error
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should fail if not on a wip branch" do
|
156
|
+
`git checkout master > /dev/null 2> /dev/null`
|
157
|
+
lambda{ GitTopic.done }.should raise_error
|
158
|
+
end
|
159
|
+
|
160
|
+
it "
|
161
|
+
should push the wip branch to origin in the review namespace, delete the
|
162
|
+
local branch, and leave the user on master
|
163
|
+
".oneline do
|
164
|
+
|
165
|
+
git_branches.should include( "wip/#{@user}/zombie-basic" )
|
166
|
+
git_remote_branches.should_not include( "review/#{@user}/zombie-basic" )
|
167
|
+
GitTopic.work_on 'zombie-basic'
|
168
|
+
GitTopic.done
|
169
|
+
|
170
|
+
git_branches.should_not include( "wip/#{@user}/zombie-basic" )
|
171
|
+
git_remote_branches.should include( "review/#{@user}/zombie-basic" )
|
172
|
+
git_remote_branches.should_not include( "wip/#{@user}/zombie-basic" )
|
173
|
+
git_branch.should == 'master'
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
describe "#status" do
|
181
|
+
|
182
|
+
describe "with pending review branches" do
|
183
|
+
|
184
|
+
before( :each ) { Dir.chdir 'in-progress' }
|
185
|
+
after( :each ) { Dir.chdir '..' }
|
186
|
+
|
187
|
+
|
188
|
+
it "should not show my review branches, but it should show others'" do
|
189
|
+
git_remote_branches.should include 'review/davidjh/pirates'
|
190
|
+
|
191
|
+
GitTopic.status
|
192
|
+
@output.should_not be_nil
|
193
|
+
|
194
|
+
@output.should_not =~ /^#\s*pirates\s*$/m
|
195
|
+
@output.should =~ /^#\s*ninja-basic\s*$/m
|
196
|
+
@output.should =~ /^#\s*zombie-basic\s*$/m
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should show my rejected topics" do
|
200
|
+
git_remote_branches.should include 'rejected/davidjh/krakens'
|
201
|
+
GitTopic.status
|
202
|
+
@output.should_not be_nil
|
203
|
+
|
204
|
+
@output.should =~ /^#\s*krakens\s*$/m
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
describe "passed the --prepended flag" do
|
210
|
+
before( :each ) { Dir.chdir 'in-progress' }
|
211
|
+
after( :each ) { Dir.chdir '..' }
|
212
|
+
|
213
|
+
it "should invoke git status before producing its output" do
|
214
|
+
GitTopic.status( :prepended => true )
|
215
|
+
@output.should_not be_nil
|
216
|
+
@output.should =~ /# On branch master/
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe "#review" do
|
222
|
+
|
223
|
+
describe "with no review branches" do
|
224
|
+
before( :each ) { Dir.chdir 'fresh' }
|
225
|
+
after( :each ) { Dir.chdir '..' }
|
226
|
+
|
227
|
+
it "should report that there is nothing to do" do
|
228
|
+
git_remote_branches.each do |b|
|
229
|
+
b.should_not =~ /review/
|
230
|
+
end
|
231
|
+
|
232
|
+
GitTopic.review
|
233
|
+
@output.should =~ /nothing to review/
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
describe "with some review branches" do
|
238
|
+
before( :each ) { Dir.chdir 'in-progress' }
|
239
|
+
after( :each ) { Dir.chdir '..' }
|
240
|
+
|
241
|
+
it "
|
242
|
+
should create a local tracking branch for the most recent remote review
|
243
|
+
branch if none was specified
|
244
|
+
" do
|
245
|
+
|
246
|
+
git_remote_branches.should include 'review/user24601/zombie-basic'
|
247
|
+
GitTopic.review
|
248
|
+
git_branch.should == 'review/user24601/zombie-basic'
|
249
|
+
git_branch_remote.should == 'origin'
|
250
|
+
git_branch_merge.should == 'refs/heads/review/user24601/zombie-basic'
|
251
|
+
end
|
252
|
+
|
253
|
+
it "should create a local tracking branch for the specified topic" do
|
254
|
+
git_remote_branches.should include 'review/user24601/ninja-basic'
|
255
|
+
GitTopic.review( 'user24601/ninja-basic' )
|
256
|
+
git_branch.should == 'review/user24601/ninja-basic'
|
257
|
+
git_branch_remote.should == 'origin'
|
258
|
+
git_branch_merge.should == 'refs/heads/review/user24601/ninja-basic'
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should error if an illegal topic is specified" do
|
262
|
+
lambda{ GitTopic.review( 'fakeuser/faketopic' )}.should raise_error
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
describe "#accept" do
|
268
|
+
|
269
|
+
describe "while on a review branch" do
|
270
|
+
before( :each ) do
|
271
|
+
Dir.chdir 'in-progress'
|
272
|
+
GitTopic.review 'user24601/zombie-basic'
|
273
|
+
end
|
274
|
+
after( :each ) { Dir.chdir '..' }
|
275
|
+
|
276
|
+
describe "with no specified argument" do
|
277
|
+
it "
|
278
|
+
should merge to master, push master and destroy the local and remote
|
279
|
+
branches when the merge is a fast-forward merge
|
280
|
+
".oneline do
|
281
|
+
|
282
|
+
git_branch.should == 'review/user24601/zombie-basic'
|
283
|
+
GitTopic.accept
|
284
|
+
git_branch.should == 'master'
|
285
|
+
git_branches.should_not include( 'review/user24601/zombie-basic' )
|
286
|
+
git_remote_branches.should_not include( 'review/user24601/zombie-basic' )
|
287
|
+
|
288
|
+
git_head.should == '0ce06c616769768f09f5e629cfcc68eabe3dee81'
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
describe "while on a review branch that does not FF" do
|
294
|
+
before( :each ) do
|
295
|
+
Dir.chdir 'in-progress'
|
296
|
+
system "
|
297
|
+
git checkout master > /dev/null 2> /dev/null &&
|
298
|
+
git merge wip/prevent-ff > /dev/null 2> /dev/null
|
299
|
+
"
|
300
|
+
@original_git_Head = git_head
|
301
|
+
GitTopic.review 'user24601/zombie-basic'
|
302
|
+
end
|
303
|
+
after( :each ) { Dir.chdir '..' }
|
304
|
+
|
305
|
+
it "should refuse to accept the review branch" do
|
306
|
+
git_branch.should == 'review/user24601/zombie-basic'
|
307
|
+
lambda{ GitTopic.accept }.should raise_error
|
308
|
+
git_branch.should == 'review/user24601/zombie-basic'
|
309
|
+
git_remote_branches.should include( 'review/user24601/zombie-basic' )
|
310
|
+
|
311
|
+
system "git checkout master > /dev/null 2> /dev/null"
|
312
|
+
git_head.should == @original_git_Head
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
describe "while not on a review branch" do
|
317
|
+
before( :each ) { Dir.chdir 'in-progress' }
|
318
|
+
after( :each ) { Dir.chdir '..' }
|
319
|
+
|
320
|
+
it "should fail" do
|
321
|
+
lambda{ GitTopic.accept }.should raise_error
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
end
|
326
|
+
|
327
|
+
describe "#reject" do
|
328
|
+
|
329
|
+
describe "while on a review branch" do
|
330
|
+
before( :each ) do
|
331
|
+
Dir.chdir 'in-progress'
|
332
|
+
GitTopic.review 'user24601/zombie-basic'
|
333
|
+
end
|
334
|
+
after( :each ) { Dir.chdir '..' }
|
335
|
+
|
336
|
+
describe "with no specified argument" do
|
337
|
+
it "
|
338
|
+
should move branch to the rejected namespace and destroy the local and
|
339
|
+
remote review branches
|
340
|
+
".oneline do
|
341
|
+
|
342
|
+
git_branch.should == 'review/user24601/zombie-basic'
|
343
|
+
GitTopic.reject
|
344
|
+
git_branch.should == 'master'
|
345
|
+
git_branches.should_not include( 'review/user24601/zombie-basic' )
|
346
|
+
git_remote_branches.should_not include( 'review/user24601/zombie-basic' )
|
347
|
+
git_remote_branches.should include( 'rejected/user24601/zombie-basic' )
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
describe "while not on a review branch" do
|
353
|
+
before( :each ) { Dir.chdir 'in-progress' }
|
354
|
+
after( :each ) { Dir.chdir '..' }
|
355
|
+
|
356
|
+
it "should fail" do
|
357
|
+
lambda{ GitTopic.reject }.should raise_error
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
|
363
|
+
describe "#install_aliases" do
|
364
|
+
it "should install aliases" do
|
365
|
+
GitTopic.install_aliases :local => true
|
366
|
+
git_config( 'alias.work-on' ).should == 'topic work-on'
|
367
|
+
git_config( 'alias.done' ).should == 'topic done'
|
368
|
+
git_config( 'alias.review' ).should == 'topic review'
|
369
|
+
git_config( 'alias.accept' ).should == 'topic accept'
|
370
|
+
git_config( 'alias.reject' ).should == 'topic reject'
|
371
|
+
|
372
|
+
git_config( 'alias.w' ).should == 'topic work-on'
|
373
|
+
git_config( 'alias.r' ).should == 'topic review'
|
374
|
+
git_config( 'alias.st' ).should == 'topic status --prepended'
|
375
|
+
end
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'git-topic'
|
3
|
+
|
4
|
+
|
5
|
+
# Disable caching on GitTopic for specs since we're calling the methods directly
|
6
|
+
# rather than assuming atmoic invocations.
|
7
|
+
module GitTopic
|
8
|
+
class << self
|
9
|
+
%w( current_branch remote_branches remote_branches_organized branches
|
10
|
+
).each do |m|
|
11
|
+
|
12
|
+
define_method( "#{m}_with_nocache" ) do
|
13
|
+
rv = send( "#{m}_without_nocache" )
|
14
|
+
self.class_variable_set( "@@#{m}", nil )
|
15
|
+
rv
|
16
|
+
end
|
17
|
+
alias_method_chain m.to_sym, :nocache
|
18
|
+
end
|
19
|
+
|
20
|
+
def git_with_implicit_capture( cmds=[], opts={} )
|
21
|
+
if opts[:show]
|
22
|
+
puts capture_git( cmds )
|
23
|
+
else
|
24
|
+
git_without_implicit_capture( cmds, opts )
|
25
|
+
end
|
26
|
+
end
|
27
|
+
alias_method_chain :git, :implicit_capture
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
# Track original $stdout, $stderr write methods so we can “unmock” them for
|
33
|
+
# debugging
|
34
|
+
|
35
|
+
class << $stdout
|
36
|
+
alias_method :real_write, :write
|
37
|
+
end
|
38
|
+
class << $stderr
|
39
|
+
alias_method :real_write, :write
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
class Object
|
44
|
+
def debug
|
45
|
+
# For debugging, restore stubbed write
|
46
|
+
class << $stdout
|
47
|
+
alias_method :write, :real_write
|
48
|
+
end
|
49
|
+
class << $stderr
|
50
|
+
alias_method :write, :real_write
|
51
|
+
end
|
52
|
+
|
53
|
+
require 'ruby-debug'
|
54
|
+
debugger
|
55
|
+
end
|
56
|
+
end
|
@@ -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 --
|