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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55a64059d22c205bb18d8854f3603fc8e89110e6
4
- data.tar.gz: 849a34318b8679e8d34d4f10c99a7101b22c2fd7
3
+ metadata.gz: 45a5d393aea0b960659f4bb459bf40adfb0abc0c
4
+ data.tar.gz: 5f3955b073c091771b71383f1ce9fcb679593950
5
5
  SHA512:
6
- metadata.gz: bf8ba5d83856c37efc94d269d09cab08b98e31d0197711f73511710c44854211ff535600d7ae89527d5239856bc4769e030a1ac2107f20ece264323c9a78ce11
7
- data.tar.gz: 5e4d1f32904bdbd1a01d201de7c37d02e2e7b919956e6cd6e0dd16f9a0542fbbe2c10fccd450c94aa59a4c1e0b5474b1804d25270cff3c9d7a1b16a25d3badee
6
+ metadata.gz: 34198f4f8e78724ae0036a4c7c1b421530c88f10446a0d60f6cc057fca43e12c80713874b95e57010e24b1a850c3f0bd7da0a2ccc504ca7d8ebf7aea90c97e12
7
+ data.tar.gz: a68176f901401b24fab087eae9e0507fc9fd9dccf8eebb479d2c482503a7621c15c7443c58ed5cc8ab5b3b6daad9fab2f3342d283308ce54b7c57a200ffda181
@@ -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
- @opts = parse_options(read_config).merge @opts unless @opts[:noconfig]
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: './index.xml',
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.map {|dir|
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
- }.flatten.compact
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
@@ -1,5 +1,5 @@
1
1
  module ReaPack
2
2
  class Index
3
- VERSION = '1.1rc1'
3
+ VERSION = '1.1rc2'
4
4
  end
5
5
  end
@@ -65,7 +65,7 @@ class ReaPack::Index
65
65
 
66
66
  def relative_path(path)
67
67
  root = Pathname.new self.path
68
- file = Pathname.new path
68
+ file = Pathname.new File.expand_path(path)
69
69
 
70
70
  file.relative_path_from(root).to_s
71
71
  end
@@ -4,7 +4,7 @@ Unicode true
4
4
  !include Sections.nsh
5
5
  !include StrRep.nsh
6
6
 
7
- !define VERSION "1.1rc1"
7
+ !define VERSION "1.1rc2"
8
8
  !define NAME "reapack-index ${VERSION}"
9
9
  !define LONG_VERSION "0.1.0.0"
10
10
 
@@ -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
 
@@ -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
- wrapper ['--scan', 'README.md', '--scan', INVALID_HASHES.first] do
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
@@ -42,7 +42,8 @@ class TestCLI < MiniTest::Test
42
42
  end
43
43
 
44
44
  def test_output
45
- wrapper ['-o output.xml'] do
45
+ setup = proc { Dir.chdir @git.path }
46
+ wrapper ['-o output.xml'], setup: setup do
46
47
  assert_equal mkpath('output.xml'), @cli.index.path
47
48
  end
48
49
  end
@@ -18,6 +18,7 @@ class TestGit < MiniTest::Test
18
18
 
19
19
  def test_relative_path
20
20
  assert_equal 'test', @git.relative_path(File.join(@git.path, 'test'))
21
+ assert_match 'test', @git.relative_path('test')
21
22
  end
22
23
 
23
24
  def test_guess_url_template
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.1rc1
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-13 00:00:00.000000000 Z
11
+ date: 2016-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler