confgit 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -1
- data/Rakefile +1 -1
- data/VERSION +1 -0
- data/confgit.gemspec +4 -3
- data/etc/tools/update_revision.rb +14 -0
- data/lib/confgit/cli.rb +1 -0
- data/lib/confgit/repo.rb +5 -1
- data/lib/confgit/version.rb +22 -2
- data/spec/confgit_spec.rb +10 -7
- data/spec/spec_helper.rb +1 -1
- metadata +22 -45
- data/etc/tools/update_version.rb +0 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 73dda3c2ee34cd11e5554113fc2dbd45c1fddc55
|
4
|
+
data.tar.gz: 77574be9d13538ae74ad71394f1c0ae1f2799d26
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e0ba03a7151f4741552315b8df6cd4070dd071483ba8591f9f95041fed83808f28915e7607b09161e870c741a8946c93c38cab979d555e158efd01a18cdcbf2a
|
7
|
+
data.tar.gz: 827912809248b458f99d0ae09cb5f03e6ef6084883f010b2b29c8122994d20a0f21c7a662fb427ecf2e89122207d33f41ae87d666679232b64c28f16b5356525
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.6
|
data/confgit.gemspec
CHANGED
@@ -11,8 +11,9 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.description = %q{Config files management tool with git}
|
12
12
|
gem.summary = %q{Config files management tool with git}
|
13
13
|
gem.homepage = "https://github.com/gnue/confgit"
|
14
|
+
gem.license = "MIT"
|
14
15
|
|
15
|
-
gem.files = `git ls-files`.split($/) + %w(
|
16
|
+
gem.files = `git ls-files`.split($/) + %w(REVISION)
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
19
|
gem.require_paths = ["lib"]
|
@@ -21,10 +22,10 @@ Gem::Specification.new do |gem|
|
|
21
22
|
|
22
23
|
# dependency
|
23
24
|
gem.add_dependency('i18n')
|
24
|
-
gem.add_dependency('json')
|
25
25
|
|
26
26
|
# for development
|
27
|
-
gem.add_development_dependency('
|
27
|
+
gem.add_development_dependency('rake')
|
28
|
+
gem.add_development_dependency('minitest', '~> 4.7') if Gem.ruby_version < Gem::Version.create('2.0')
|
28
29
|
gem.add_development_dependency('turn')
|
29
30
|
|
30
31
|
gem.post_install_message = %Q{
|
@@ -0,0 +1,14 @@
|
|
1
|
+
def update_revision(path = 'REVISION')
|
2
|
+
rev = `git describe --dirty --long 2>/dev/null`.chomp
|
3
|
+
rev = `git describe --dirty --long --tags --always`.chomp if rev.empty?
|
4
|
+
rev.gsub!(/^v([0-9])/, '\1')
|
5
|
+
rev.gsub!(/(^|-)([a-z0-9]+(-dirty)?)$/, '/\2')
|
6
|
+
rev.gsub!(/^([0-9.]+)-0\//, '\1/')
|
7
|
+
|
8
|
+
return if File.exists?(path) && rev == open(path).read.chomp
|
9
|
+
|
10
|
+
open(path, 'w') { |f| f.puts rev }
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
update_revision
|
data/lib/confgit/cli.rb
CHANGED
@@ -45,6 +45,7 @@ class CLI
|
|
45
45
|
def i18n_init
|
46
46
|
I18n.load_path = Dir[File.expand_path('../locales/*.yml', __FILE__)]
|
47
47
|
I18n.backend.load_translations
|
48
|
+
I18n.enforce_available_locales = false
|
48
49
|
|
49
50
|
locale = ENV['LANG'][0, 2].to_sym if ENV['LANG']
|
50
51
|
I18n.locale = locale if I18n.available_locales.include?(locale)
|
data/lib/confgit/repo.rb
CHANGED
@@ -290,7 +290,11 @@ class Repo
|
|
290
290
|
# ファイルが書込み可能か?(シンボリックリンクの場合はわからないのでとりあえず true を返す)
|
291
291
|
def file_writable_real?(path)
|
292
292
|
return true if File.symlink?(path)
|
293
|
-
|
293
|
+
unless File.exist?(path)
|
294
|
+
dir = File.dirname(path)
|
295
|
+
dir = File.dirname(dir) until File.exist?(dir)
|
296
|
+
return File.writable_real?(dir)
|
297
|
+
end
|
294
298
|
|
295
299
|
File.writable_real?(path)
|
296
300
|
end
|
data/lib/confgit/version.rb
CHANGED
@@ -1,4 +1,24 @@
|
|
1
1
|
module Confgit
|
2
|
-
|
3
|
-
|
2
|
+
begin
|
3
|
+
dir = File.expand_path('../../..', __FILE__)
|
4
|
+
version = File.read(File.join(dir, 'VERSION')).chomp
|
5
|
+
revision = File.read(File.join(dir, 'REVISION')).chomp.split('/')
|
6
|
+
|
7
|
+
case revision.first
|
8
|
+
when /^#{version}(-|$)/
|
9
|
+
ver, rev = revision
|
10
|
+
else
|
11
|
+
version += 'dev'
|
12
|
+
ver = version
|
13
|
+
|
14
|
+
revision.delete('')
|
15
|
+
rev = revision.join('/')
|
16
|
+
end
|
17
|
+
|
18
|
+
rescue
|
19
|
+
ver = version
|
20
|
+
end
|
21
|
+
|
22
|
+
VERSION = version
|
23
|
+
LONG_VERSION = ver + (rev ? "(#{rev})" : '')
|
4
24
|
end
|
data/spec/confgit_spec.rb
CHANGED
@@ -332,11 +332,11 @@ describe Confgit do
|
|
332
332
|
|
333
333
|
it "backup -n" do
|
334
334
|
chroot { |root, *files|
|
335
|
-
|
335
|
+
out, err, status = capture_io { confgit 'backup', '-n' }
|
336
|
+
out.must_match <<-EOD.cut_indent
|
336
337
|
\e[34m--> #{@mod_file}\e[m
|
337
338
|
\e[34m--> mod_link\e[m
|
338
339
|
# On branch master
|
339
|
-
nothing to commit (working directory clean)
|
340
340
|
EOD
|
341
341
|
}
|
342
342
|
end
|
@@ -363,7 +363,8 @@ describe Confgit do
|
|
363
363
|
chroot { |root, *files|
|
364
364
|
File.delete @mod_file
|
365
365
|
|
366
|
-
|
366
|
+
out, err, status = capture_io { confgit 'backup', '-fn' }
|
367
|
+
out.must_match <<-EOD.cut_indent
|
367
368
|
\e[34m--> LICENSE.txt\e[m
|
368
369
|
\e[34m--> README\e[m
|
369
370
|
\e[31m[?] #{@mod_file}\e[m
|
@@ -372,7 +373,6 @@ describe Confgit do
|
|
372
373
|
\e[34m--> misc/README\e[m
|
373
374
|
\e[34m--> mod_link\e[m
|
374
375
|
# On branch master
|
375
|
-
nothing to commit (working directory clean)
|
376
376
|
EOD
|
377
377
|
}
|
378
378
|
end
|
@@ -382,6 +382,7 @@ describe Confgit do
|
|
382
382
|
def udpate_data
|
383
383
|
open(@mod_file, 'w') { |f| f.puts @data }
|
384
384
|
File.delete @del_file
|
385
|
+
FileUtils.remove_entry_secure(@deep_file.split('/').first)
|
385
386
|
|
386
387
|
@symlinks.each { |key, value|
|
387
388
|
old, file = value
|
@@ -396,10 +397,11 @@ describe Confgit do
|
|
396
397
|
dir = 'misc'
|
397
398
|
@mod_file = 'VERSION'
|
398
399
|
@del_file = 'LICENSE.txt'
|
400
|
+
@deep_file = 'a/b/c.txt'
|
399
401
|
@data = '0.0.1'
|
400
402
|
@symlinks = {'dir_link' => dir, 'file_link' => 'VERSION', 'mod_link' => ['README', 'LICENSE.txt']}
|
401
403
|
|
402
|
-
chroot(@mod_file, @del_file, 'README', File.join(dir, 'README')) { |root, *files|
|
404
|
+
chroot(@mod_file, @del_file, @deep_file, 'README', File.join(dir, 'README')) { |root, *files|
|
403
405
|
@symlinks.each { |key, value|
|
404
406
|
file, = value
|
405
407
|
File.symlink(file, key)
|
@@ -418,6 +420,7 @@ describe Confgit do
|
|
418
420
|
proc { confgit 'restore', '-n' }.must_output <<-EOD.cut_indent
|
419
421
|
\e[34m<-- #{@del_file}\e[m
|
420
422
|
\e[34m<-- #{@mod_file}\e[m
|
423
|
+
\e[34m<-- #{@deep_file}\e[m
|
421
424
|
\e[34m<-- mod_link\e[m
|
422
425
|
EOD
|
423
426
|
open(@mod_file).read.must_equal prev
|
@@ -433,6 +436,7 @@ describe Confgit do
|
|
433
436
|
proc { confgit 'restore', '-y' }.must_output <<-EOD.cut_indent
|
434
437
|
\e[34m<-- #{@del_file}\e[m
|
435
438
|
\e[34m<-- #{@mod_file}\e[m
|
439
|
+
\e[34m<-- #{@deep_file}\e[m
|
436
440
|
\e[34m<-- mod_link\e[m
|
437
441
|
EOD
|
438
442
|
open(@mod_file).read.must_equal prev
|
@@ -448,6 +452,7 @@ describe Confgit do
|
|
448
452
|
\e[34m<-- #{@del_file}\e[m
|
449
453
|
\e[34m<-- README\e[m
|
450
454
|
\e[34m<-- #{@mod_file}\e[m
|
455
|
+
\e[34m<-- #{@deep_file}\e[m
|
451
456
|
\e[34m<-- dir_link\e[m
|
452
457
|
\e[34m<-- file_link\e[m
|
453
458
|
\e[34m<-- misc/README\e[m
|
@@ -465,8 +470,6 @@ describe Confgit do
|
|
465
470
|
err.must_be_empty
|
466
471
|
status.must_be_nil
|
467
472
|
out.must_match <<-EOD.cut_indent('|')
|
468
|
-
|
|
469
|
-
| 0 files changed
|
470
473
|
| create mode 100644 #{file}
|
471
474
|
EOD
|
472
475
|
}
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,78 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confgit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- gnue
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-15 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: i18n
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
28
|
+
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: minitest
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
31
|
+
- - ">="
|
52
32
|
- !ruby/object:Gem::Version
|
53
33
|
version: '0'
|
54
34
|
type: :development
|
55
35
|
prerelease: false
|
56
36
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
37
|
requirements:
|
59
|
-
- -
|
38
|
+
- - ">="
|
60
39
|
- !ruby/object:Gem::Version
|
61
40
|
version: '0'
|
62
41
|
- !ruby/object:Gem::Dependency
|
63
42
|
name: turn
|
64
43
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
44
|
requirements:
|
67
|
-
- -
|
45
|
+
- - ">="
|
68
46
|
- !ruby/object:Gem::Version
|
69
47
|
version: '0'
|
70
48
|
type: :development
|
71
49
|
prerelease: false
|
72
50
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
51
|
requirements:
|
75
|
-
- -
|
52
|
+
- - ">="
|
76
53
|
- !ruby/object:Gem::Version
|
77
54
|
version: '0'
|
78
55
|
description: Config files management tool with git
|
@@ -83,15 +60,17 @@ executables:
|
|
83
60
|
extensions: []
|
84
61
|
extra_rdoc_files: []
|
85
62
|
files:
|
86
|
-
- .gitignore
|
63
|
+
- ".gitignore"
|
87
64
|
- Gemfile
|
88
65
|
- LICENSE.txt
|
89
66
|
- README.md
|
67
|
+
- REVISION
|
90
68
|
- Rakefile
|
69
|
+
- VERSION
|
91
70
|
- bin/confgit
|
92
71
|
- confgit.gemspec
|
93
72
|
- etc/bash_completion.d/confgit
|
94
|
-
- etc/tools/
|
73
|
+
- etc/tools/update_revision.rb
|
95
74
|
- lib/confgit.rb
|
96
75
|
- lib/confgit/cli.rb
|
97
76
|
- lib/confgit/locales/en.yml
|
@@ -101,35 +80,33 @@ files:
|
|
101
80
|
- lib/confgit/with_color.rb
|
102
81
|
- spec/confgit_spec.rb
|
103
82
|
- spec/spec_helper.rb
|
104
|
-
- VERSION
|
105
83
|
homepage: https://github.com/gnue/confgit
|
106
|
-
licenses:
|
107
|
-
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message: "\n ==================\n This software requires 'git'.\n
|
108
88
|
\ Also optional softwares 'tree' and 'tig'.\n\n If you are using the bash-completion\n\n
|
109
|
-
\ $ cp `gem env gemdir`/gems/confgit-0.0.
|
89
|
+
\ $ cp `gem env gemdir`/gems/confgit-0.0.6/etc/bash_completion.d/confgit $BASH_COMPLETION_DIR\n\n
|
110
90
|
\ ==================\n "
|
111
91
|
rdoc_options: []
|
112
92
|
require_paths:
|
113
93
|
- lib
|
114
94
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
95
|
requirements:
|
117
|
-
- -
|
96
|
+
- - ">="
|
118
97
|
- !ruby/object:Gem::Version
|
119
98
|
version: 1.9.0
|
120
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
100
|
requirements:
|
123
|
-
- -
|
101
|
+
- - ">="
|
124
102
|
- !ruby/object:Gem::Version
|
125
103
|
version: '0'
|
126
104
|
requirements: []
|
127
105
|
rubyforge_project:
|
128
|
-
rubygems_version:
|
106
|
+
rubygems_version: 2.2.0
|
129
107
|
signing_key:
|
130
|
-
specification_version:
|
108
|
+
specification_version: 4
|
131
109
|
summary: Config files management tool with git
|
132
110
|
test_files:
|
133
111
|
- spec/confgit_spec.rb
|
134
112
|
- spec/spec_helper.rb
|
135
|
-
has_rdoc:
|
data/etc/tools/update_version.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
def update_version(path)
|
2
|
-
version = `git describe --dirty 2>/dev/null`.chomp
|
3
|
-
version = `git describe --tags --dirty`.chomp if version.empty?
|
4
|
-
version[0, 1] = '' if version =~ /^v[0-9]/
|
5
|
-
version.gsub!(/-([a-z0-9]+(-dirty)?)$/) { |m| "(#{$1})" }
|
6
|
-
|
7
|
-
begin
|
8
|
-
return if version == open(path).read.chomp
|
9
|
-
return if version.empty?
|
10
|
-
rescue
|
11
|
-
end
|
12
|
-
|
13
|
-
open(path, 'w') { |f| f.puts version }
|
14
|
-
end
|
15
|
-
|
16
|
-
update_version 'VERSION'
|