reapack-index 1.1rc1 → 1.1rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reapack/index/cli.rb +19 -5
- data/lib/reapack/index/cli/options.rb +10 -9
- data/lib/reapack/index/gem_version.rb +1 -1
- data/lib/reapack/index/git.rb +1 -1
- data/setup/reapack-index.nsi +1 -1
- data/test/cli/test_metadata.rb +18 -0
- data/test/cli/test_scan.rb +5 -1
- data/test/test_cli.rb +2 -1
- data/test/test_git.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45a5d393aea0b960659f4bb459bf40adfb0abc0c
|
4
|
+
data.tar.gz: 5f3955b073c091771b71383f1ce9fcb679593950
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34198f4f8e78724ae0036a4c7c1b421530c88f10446a0d60f6cc057fca43e12c80713874b95e57010e24b1a850c3f0bd7da0a2ccc504ca7d8ebf7aea90c97e12
|
7
|
+
data.tar.gz: a68176f901401b24fab087eae9e0507fc9fd9dccf8eebb479d2c482503a7621c15c7443c58ed5cc8ab5b3b6daad9fab2f3342d283308ce54b7c57a200ffda181
|
data/lib/reapack/index/cli.rb
CHANGED
@@ -7,12 +7,17 @@ class ReaPack::Index::CLI
|
|
7
7
|
@git = ReaPack::Index::Git.new argv.first || Dir.pwd
|
8
8
|
log "found git repository in #{@git.path}"
|
9
9
|
|
10
|
-
|
10
|
+
read_config unless @opts[:noconfig]
|
11
|
+
|
12
|
+
unless @opts[:output]
|
13
|
+
@opts[:output] = expand_path DEFAULTS[:output], relative: true
|
14
|
+
end
|
15
|
+
|
11
16
|
@opts = DEFAULTS.merge @opts
|
12
17
|
|
13
18
|
log Hash[@opts.sort].inspect
|
14
19
|
|
15
|
-
@index = ReaPack::Index.new expand_path(@opts[:output])
|
20
|
+
@index = ReaPack::Index.new File.expand_path(@opts[:output])
|
16
21
|
@index.amend = @opts[:amend]
|
17
22
|
@index.strict = @opts[:strict]
|
18
23
|
set_url_template
|
@@ -74,7 +79,7 @@ private
|
|
74
79
|
@index.auto_bump_commit = false
|
75
80
|
|
76
81
|
@opts[:scan].map {|hash|
|
77
|
-
if c = @git.last_commit_for(hash)
|
82
|
+
if c = @git.last_commit_for(@git.relative_path hash)
|
78
83
|
[c, hash]
|
79
84
|
elsif c = @git.get_commit(hash)
|
80
85
|
c
|
@@ -316,10 +321,19 @@ private
|
|
316
321
|
false
|
317
322
|
end
|
318
323
|
|
319
|
-
def expand_path(path)
|
324
|
+
def expand_path(path, **options)
|
320
325
|
# expand from the repository root or from the current directory if
|
321
326
|
# the repository is not yet initialized
|
322
|
-
File.expand_path path, @git ? @git.path : Dir.pwd
|
327
|
+
path = File.expand_path path, options[:base] || (@git ? @git.path : Dir.pwd)
|
328
|
+
|
329
|
+
if options[:relative]
|
330
|
+
root = Pathname.new Dir.pwd
|
331
|
+
file = Pathname.new path
|
332
|
+
|
333
|
+
file.relative_path_from(root).to_s
|
334
|
+
else
|
335
|
+
path
|
336
|
+
end
|
323
337
|
end
|
324
338
|
|
325
339
|
def indent(input)
|
@@ -11,7 +11,7 @@ class ReaPack::Index::CLI
|
|
11
11
|
commit: nil,
|
12
12
|
message: 'index: $changelog',
|
13
13
|
ignore: [],
|
14
|
-
output: '
|
14
|
+
output: 'index.xml',
|
15
15
|
progress: true,
|
16
16
|
quiet: false,
|
17
17
|
rebuild: false,
|
@@ -23,7 +23,7 @@ class ReaPack::Index::CLI
|
|
23
23
|
}.freeze
|
24
24
|
|
25
25
|
def read_config
|
26
|
-
CONFIG_SEARCH.
|
26
|
+
CONFIG_SEARCH.each {|dir|
|
27
27
|
dir = expand_path dir
|
28
28
|
path = File.expand_path '.reapack-index.conf', dir
|
29
29
|
|
@@ -34,13 +34,14 @@ class ReaPack::Index::CLI
|
|
34
34
|
next
|
35
35
|
end
|
36
36
|
|
37
|
-
Shellwords.split File.read(path)
|
38
|
-
|
37
|
+
opts = Shellwords.split File.read(path)
|
38
|
+
@opts = parse_options(opts, dir).merge @opts
|
39
|
+
}
|
39
40
|
rescue ArgumentError => e
|
40
41
|
raise ReaPack::Index::Error, e.message
|
41
42
|
end
|
42
43
|
|
43
|
-
def parse_options(args)
|
44
|
+
def parse_options(args, basepath = nil)
|
44
45
|
opts = Hash.new
|
45
46
|
|
46
47
|
OptionParser.new do |op|
|
@@ -60,7 +61,7 @@ class ReaPack::Index::CLI
|
|
60
61
|
opts[:scan] ||= []
|
61
62
|
|
62
63
|
if commit
|
63
|
-
opts[:scan] << commit.strip
|
64
|
+
opts[:scan] << expand_path(commit.strip, base: basepath, relative: true)
|
64
65
|
else
|
65
66
|
opts[:scan].clear
|
66
67
|
end
|
@@ -83,12 +84,12 @@ class ReaPack::Index::CLI
|
|
83
84
|
|
84
85
|
op.on '-i', '--ignore PATH', "Don't check or index any file starting with PATH" do |path|
|
85
86
|
opts[:ignore] ||= []
|
86
|
-
opts[:ignore] << expand_path(path)
|
87
|
+
opts[:ignore] << expand_path(path, base: basepath)
|
87
88
|
end
|
88
89
|
|
89
90
|
op.on '-o', "--output FILE=#{DEFAULTS[:output]}",
|
90
91
|
'Set the output filename and path for the index' do |file|
|
91
|
-
opts[:output] = file.strip
|
92
|
+
opts[:output] = expand_path(file.strip, base: basepath, relative: true)
|
92
93
|
end
|
93
94
|
|
94
95
|
op.on '--[no-]strict', 'Enable strict validation mode' do |bool|
|
@@ -126,7 +127,7 @@ class ReaPack::Index::CLI
|
|
126
127
|
end
|
127
128
|
|
128
129
|
op.on '-A', '--about=FILE', 'Set the about content from a file' do |file|
|
129
|
-
opts[:about] = file.strip
|
130
|
+
opts[:about] = expand_path file.strip, base: basepath, relative: true
|
130
131
|
end
|
131
132
|
|
132
133
|
op.on '--remove-about', 'Remove the about content from the index' do
|
data/lib/reapack/index/git.rb
CHANGED
data/setup/reapack-index.nsi
CHANGED
data/test/cli/test_metadata.rb
CHANGED
@@ -100,6 +100,24 @@ class TestCLI::Metadata < MiniTest::Test
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
+
def test_about_relative_config
|
104
|
+
setup = proc {
|
105
|
+
mkfile '.reapack-index.conf', '--about=README.md'
|
106
|
+
mkfile 'README.md', '# Hello World'
|
107
|
+
|
108
|
+
dir = mkpath 'test'
|
109
|
+
FileUtils.mkdir dir
|
110
|
+
Dir.chdir dir
|
111
|
+
}
|
112
|
+
|
113
|
+
wrapper [], setup: setup do
|
114
|
+
_, stderr = capture_io { @cli.run }
|
115
|
+
|
116
|
+
refute_match /no such file or directory/i, stderr
|
117
|
+
assert_match 'Hello World', read_index
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
103
121
|
def test_about_pandoc_not_found
|
104
122
|
old_path = ENV['PATH']
|
105
123
|
|
data/test/cli/test_scan.rb
CHANGED
@@ -321,6 +321,8 @@ processing [a-f0-9]{7}: third commit
|
|
321
321
|
options = [ '--scan', 'cat/test1.lua']
|
322
322
|
|
323
323
|
setup = proc {
|
324
|
+
Dir.chdir @git.path
|
325
|
+
|
324
326
|
@git.create_commit 'initial commit',
|
325
327
|
[mkfile('cat/test1.lua', '@version 1')]
|
326
328
|
|
@@ -390,7 +392,9 @@ processing [a-f0-9]{7}: third commit
|
|
390
392
|
end
|
391
393
|
|
392
394
|
def test_report_right_invalid_hash
|
393
|
-
|
395
|
+
setup = proc { Dir.chdir @git.path }
|
396
|
+
|
397
|
+
wrapper ['--scan', 'README.md', '--scan', INVALID_HASHES.first], setup: setup do
|
394
398
|
@git.create_commit 'initial commit', [mkfile('README.md')]
|
395
399
|
|
396
400
|
_, stderr = capture_io do
|
data/test/test_cli.rb
CHANGED
data/test/test_git.rb
CHANGED
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.
|
4
|
+
version: 1.1rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cfillion
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|