File tree Expand file tree Collapse file tree 4 files changed +45
-3
lines changed Expand file tree Collapse file tree 4 files changed +45
-3
lines changed Original file line number Diff line number Diff line change 4
4
- 2.4
5
5
- 2.5
6
6
- 2.6
7
+ - 2.7
7
8
- ruby-head
8
9
- jruby
9
10
10
11
matrix :
11
12
allow_failures :
12
13
- rvm : jruby
13
14
- rvm : ruby-head
14
- fast_finish : true
15
+ fast_finish : true
Original file line number Diff line number Diff line change @@ -243,6 +243,8 @@ def process_commit_log_data(data)
243
243
next
244
244
end
245
245
246
+ in_message = false if in_message && line [ 0 ..3 ] != " "
247
+
246
248
if in_message
247
249
hsh [ 'message' ] << "#{ line [ 4 ..-1 ] } \n "
248
250
next
@@ -592,9 +594,10 @@ def remove(path = '.', opts = {})
592
594
# :author
593
595
# :date
594
596
# :no_verify
597
+ # :allow_empty_message
595
598
#
596
599
# @param [String] message the commit message to be used
597
- # @param [Array ] opts the commit options to be used
600
+ # @param [Hash ] opts the commit options to be used
598
601
def commit ( message , opts = { } )
599
602
arr_opts = [ ]
600
603
arr_opts << "--message=#{ message } " if message
@@ -604,6 +607,7 @@ def commit(message, opts = {})
604
607
arr_opts << "--author=#{ opts [ :author ] } " if opts [ :author ]
605
608
arr_opts << "--date=#{ opts [ :date ] } " if opts [ :date ] . is_a? String
606
609
arr_opts << '--no-verify' if opts [ :no_verify ]
610
+ arr_opts << '--allow-empty-message' if opts [ :allow_empty_message ]
607
611
608
612
command ( 'commit' , arr_opts )
609
613
end
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env ruby
2
+ require File . dirname ( __FILE__ ) + '/../test_helper'
3
+
4
+ class TestCommitWithEmptyMessage < Test ::Unit ::TestCase
5
+ def setup
6
+ set_file_paths
7
+ end
8
+
9
+ def test_without_allow_empty_message_option
10
+ Dir . mktmpdir do |dir |
11
+ git = Git . init ( dir )
12
+ assert_raises Git ::GitExecuteError do
13
+ git . commit ( '' , { allow_empty : true } )
14
+ end
15
+ end
16
+ end
17
+
18
+ def test_with_allow_empty_message_option
19
+ Dir . mktmpdir do |dir |
20
+ git = Git . init ( dir )
21
+ git . commit ( '' , { allow_empty : true , allow_empty_message : true } )
22
+ assert_equal ( 1 , git . log . to_a . size )
23
+ end
24
+ end
25
+ end
Original file line number Diff line number Diff line change @@ -78,5 +78,17 @@ def test_log_file_noexist
78
78
@git . log . object ( 'no-exist.txt' ) . size
79
79
end
80
80
end
81
-
81
+
82
+ def test_log_with_empty_commit_message
83
+ Dir . mktmpdir do |dir |
84
+ git = Git . init ( dir )
85
+ expected_message = 'message'
86
+ git . commit ( expected_message , { allow_empty : true } )
87
+ git . commit ( '' , { allow_empty : true , allow_empty_message : true } )
88
+ log = git . log
89
+ assert_equal ( 2 , log . to_a . size )
90
+ assert_equal ( '' , log [ 0 ] . message )
91
+ assert_equal ( expected_message , log [ 1 ] . message )
92
+ end
93
+ end
82
94
end
You can’t perform that action at this time.
0 commit comments