reapack-index 1.1beta4 → 1.1rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68a03118ab26b00e4fd7969dc54c9b2b350f517a
4
- data.tar.gz: 2bc39e1d5de9c718b69f8f8efbcd4c10fcc3e496
3
+ metadata.gz: 55a64059d22c205bb18d8854f3603fc8e89110e6
4
+ data.tar.gz: 849a34318b8679e8d34d4f10c99a7101b22c2fd7
5
5
  SHA512:
6
- metadata.gz: 88efa5f4a1116dd6ad47cb3fe2bf3418eac5621a6c2e5031e7d33284b66a5540977bc11a1e89ba4e9f60cbeccc91409841a6b64c0a227dbdd75945950baa1395
7
- data.tar.gz: 8fd0bcb5dba3dcc5f20dd5eccc0e82f21f4ec4017bd1ca2cf6e85fb7e6b9ffe23cb1b69c9d3b23c5045c27efcdb149a546c640c3280cfc24b8588ca5c9d8ad2f
6
+ metadata.gz: bf8ba5d83856c37efc94d269d09cab08b98e31d0197711f73511710c44854211ff535600d7ae89527d5239856bc4769e030a1ac2107f20ece264323c9a78ce11
7
+ data.tar.gz: 5e4d1f32904bdbd1a01d201de7c37d02e2e7b919956e6cd6e0dd16f9a0542fbbe2c10fccd450c94aa59a4c1e0b5474b1804d25270cff3c9d7a1b16a25d3badee
data/README.md CHANGED
@@ -30,6 +30,7 @@ reapack-index [options] [path-to-your-repository]
30
30
  Modes:
31
31
  -c, --check Test every package including uncommited changes and exit
32
32
  -s, --scan [FILE|COMMIT] Scan new commits (default), a file or a commit
33
+ --no-scan Do not scan for new commits
33
34
  --rebuild Clear the index and rescan the whole git history
34
35
  Indexer options:
35
36
  -a, --[no-]amend Update existing versions
@@ -51,6 +52,7 @@ Misc options:
51
52
  -V, --[no-]verbose Activate diagnosis messages
52
53
  -C, --[no-]commit Select whether to commit the modified index
53
54
  --prompt-commit Ask at runtime whether to commit the index
55
+ -m, --commit-template MESSAGE Customize the commit message. Supported placeholder: $changelog
54
56
  -W, --warnings Enable warnings
55
57
  -w, --no-warnings Turn off warnings
56
58
  -q, --[no-]quiet Disable almost all output
@@ -9,6 +9,7 @@ class ReaPack::Index::CLI
9
9
  DEFAULTS = {
10
10
  check: false,
11
11
  commit: nil,
12
+ message: 'index: $changelog',
12
13
  ignore: [],
13
14
  output: './index.xml',
14
15
  progress: true,
@@ -33,10 +34,10 @@ class ReaPack::Index::CLI
33
34
  next
34
35
  end
35
36
 
36
- opts = Array.new
37
- File.foreach(path) {|line| opts << Shellwords.split(line) }
38
- opts
37
+ Shellwords.split File.read(path)
39
38
  }.flatten.compact
39
+ rescue ArgumentError => e
40
+ raise ReaPack::Index::Error, e.message
40
41
  end
41
42
 
42
43
  def parse_options(args)
@@ -65,6 +66,10 @@ class ReaPack::Index::CLI
65
66
  end
66
67
  end
67
68
 
69
+ op.on '--no-scan', 'Do not scan for new commits' do
70
+ opts[:scan] = false
71
+ end
72
+
68
73
  op.on '--rebuild', 'Clear the index and rescan the whole git history' do
69
74
  opts[:check] = false
70
75
  opts[:rebuild] = true
@@ -150,6 +155,11 @@ class ReaPack::Index::CLI
150
155
  opts[:commit] = nil
151
156
  end
152
157
 
158
+ op.on '-m', "--commit-template MESSAGE",
159
+ 'Customize the commit message. Supported placeholder: $changelog' do |msg|
160
+ opts[:message] = msg
161
+ end
162
+
153
163
  op.on '-W', '--warnings', 'Enable warnings' do
154
164
  opts[:warnings] = true
155
165
  end
@@ -40,7 +40,7 @@ class ReaPack::Index::CLI
40
40
 
41
41
  unless @index.modified?
42
42
  $stderr.puts 'Nothing to do!' unless @opts[:quiet]
43
- return
43
+ return true
44
44
  end
45
45
 
46
46
  # changelog will be cleared by Index#write!
@@ -63,14 +63,11 @@ private
63
63
  end
64
64
 
65
65
  def do_scan
66
- if @git.empty?
67
- warn 'The current branch does not contains any commit.'
68
- return
69
- end
70
-
71
66
  commits = if @opts[:rebuild]
72
67
  @index.clear
73
68
  @git.commits
69
+ elsif @opts[:scan] == false
70
+ []
74
71
  elsif @opts[:scan].empty?
75
72
  @git.commits_since @index.last_commit
76
73
  else
@@ -256,7 +253,8 @@ private
256
253
  prompt 'Commit the new index?'
257
254
  end
258
255
 
259
- @git.create_commit "index: #{changelog}", [@index.path]
256
+ message = @opts[:message].gsub '$changelog', changelog
257
+ @git.create_commit message, [@index.path]
260
258
  $stderr.puts 'commit created'
261
259
  end
262
260
 
@@ -1,5 +1,5 @@
1
1
  module ReaPack
2
2
  class Index
3
- VERSION = '1.1beta4'
3
+ VERSION = '1.1rc1'
4
4
  end
5
5
  end
@@ -2,14 +2,20 @@ class ReaPack::Index
2
2
  class Git
3
3
  def initialize(path)
4
4
  @repo = Rugged::Repository.discover path.encode(Encoding::UTF_8)
5
+
6
+ if @repo.bare?
7
+ raise ReaPack::Index::Error,
8
+ 'reapack-index cannot be run in a repository without a work tree'
9
+ end
5
10
  end
6
11
 
7
12
  def empty?
8
- @repo.empty?
13
+ # head_unborn = orphan branch – FIXME: add test for this case
14
+ @repo.empty? || @repo.head_unborn?
9
15
  end
10
16
 
11
17
  def path
12
- File.expand_path @repo.workdir
18
+ @path ||= File.expand_path @repo.workdir
13
19
  end
14
20
 
15
21
  def commits
@@ -58,7 +64,7 @@ class ReaPack::Index
58
64
  end
59
65
 
60
66
  def relative_path(path)
61
- root = Pathname.new @repo.workdir
67
+ root = Pathname.new self.path
62
68
  file = Pathname.new path
63
69
 
64
70
  file.relative_path_from(root).to_s
@@ -4,7 +4,7 @@ Unicode true
4
4
  !include Sections.nsh
5
5
  !include StrRep.nsh
6
6
 
7
- !define VERSION "1.1beta4"
7
+ !define VERSION "1.1rc1"
8
8
  !define NAME "reapack-index ${VERSION}"
9
9
  !define LONG_VERSION "0.1.0.0"
10
10
 
@@ -42,14 +42,6 @@ class TestCLI::Scan < MiniTest::Test
42
42
  end
43
43
  end
44
44
 
45
- def test_empty_branch
46
- wrapper do
47
- assert_output nil, /the current branch does not contains any commit/i do
48
- @cli.run
49
- end
50
- end
51
- end
52
-
53
45
  def test_workingdir_is_subdirectory
54
46
  wrapper do
55
47
  @git.create_commit 'initial commit',
@@ -464,6 +456,21 @@ processing [a-f0-9]{7}: third commit
464
456
  end
465
457
  end
466
458
 
459
+ def test_no_scan
460
+ options = ['--no-scan']
461
+
462
+ setup = proc {
463
+ @git.create_commit 'initial commit',
464
+ [mkfile('cat/test1.lua', '@version 1.0')]
465
+ }
466
+
467
+ wrapper options, setup: setup do
468
+ capture_io { @cli.run }
469
+
470
+ refute_match 'test1.lua', read_index, 'The initial commit was scanned'
471
+ end
472
+ end
473
+
467
474
  def test_no_arguments
468
475
  wrapper ['--scan'] do; end
469
476
  end
data/test/test_cli.rb CHANGED
@@ -89,9 +89,19 @@ class TestCLI < MiniTest::Test
89
89
  end
90
90
  end
91
91
 
92
+ def test_custom_commit_message
93
+ wrapper ['--commit', '--commit-template', 'a $changelog b $changelog c'] do
94
+ assert_output("empty index\n", /commit created\n/) { @cli.run }
95
+
96
+ commit = @git.last_commit
97
+ assert_equal 'a empty index b empty index c', commit.message
98
+ assert_equal ['index.xml'], commit.each_diff.map {|d| d.file }
99
+ end
100
+ end
101
+
92
102
  def test_config
93
- catch :stop do
94
- assert_output /--help/, '' do
103
+ assert_output /--help/, '' do
104
+ catch :stop do
95
105
  wrapper [], setup: proc {
96
106
  mkfile '.reapack-index.conf', '--help'
97
107
  }
@@ -141,6 +151,24 @@ class TestCLI < MiniTest::Test
141
151
  end
142
152
  end
143
153
 
154
+ def test_config_unmatched_quote
155
+ assert_output '', /unmatched double quote/i do
156
+ catch :stop do
157
+ wrapper [], setup: proc {
158
+ mkfile '.reapack-index.conf', '--output "'
159
+ }
160
+ end
161
+ end
162
+ end
163
+
164
+ def test_config_line_break
165
+ assert_output '', '' do
166
+ wrapper [], setup: proc {
167
+ mkfile '.reapack-index.conf', %Q{--commit-template="hello\nworld"}
168
+ }
169
+ end
170
+ end
171
+
144
172
  def test_working_directory_with_options
145
173
  wrapper do
146
174
  @git.create_commit 'initial commit',
@@ -207,7 +235,7 @@ class TestCLI < MiniTest::Test
207
235
 
208
236
  wrapper ['--progress'], setup: setup do
209
237
  assert_output '', /nothing to do/i do
210
- @cli.run
238
+ assert_equal true, @cli.run
211
239
  end
212
240
  end
213
241
  end
data/test/test_git.rb CHANGED
@@ -170,4 +170,11 @@ class TestGit < MiniTest::Test
170
170
  assert_match c.summary, c.inspect
171
171
  refute_match c.message, c.inspect
172
172
  end
173
+
174
+ def test_bare_repo
175
+ path = Dir.mktmpdir 'test-repository'
176
+
177
+ repo = Rugged::Repository.init_at path, true
178
+ assert_raises(ReaPack::Index::Error) { ReaPack::Index::Git.new path }
179
+ end
173
180
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reapack-index
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1beta4
4
+ version: 1.1rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - cfillion
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-26 00:00:00.000000000 Z
11
+ date: 2016-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler