gitkeep 0.2.40 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/bin/gitkeep +8 -1
- data/lib/gitkeep.rb +45 -35
- metadata +5 -7
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NmY3OTNmMGU4MWY3ZWZiNmE5YmQ3MTFhM2I5NzMxZTk3ZTc1NjM0Yg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MjA1YzZjNGMzNTc2MTA2ZjZjMjQ0MzdkYmYyNTNjMWNlMDY2MWM2NQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZWExZjQ2MTUwNWI1OGU1ZTJlZDFiMTZkYjZjYjliZGRkYWEzN2RkMWE5YThj
|
10
|
+
MzFmZTQyY2JjODlmODM1YjE3MTJhZmEzOWFhZDRmZWNlZTU4YWZlNzA5ZjVm
|
11
|
+
Y2UyZGVjZjkwZDljMmQyMGY0ZmNlMGM3OTk3NGEzZDgxNDA3NzE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZjEyMGZlYmY5ZWZlZWY0NTQ2MGZmODY3NGFkZGFjOTZjMzE1MDUwYzY1NGJk
|
14
|
+
ZTMyYTE2M2RjN2ViMDFmNWRkMjgyMjhlMzgwYzMxYTU1NDI5ZjI0NmIwOGZh
|
15
|
+
OGE0NmQzMDYzMDgyZDRmYjhhMDhiY2YwZjFjYzNlNDNjMDY1MWE=
|
data/bin/gitkeep
CHANGED
@@ -8,6 +8,8 @@ if !ARGV.delete('-h').nil?
|
|
8
8
|
puts "-d \t drymode"
|
9
9
|
puts "-i \t interactive"
|
10
10
|
puts "-a \t adding .gitkeep files to your git index"
|
11
|
+
puts "-ac \t removes unneeded .gitkeep files"
|
12
|
+
puts "-acr \t removes unneeded .gitkeep files and removes the git index"
|
11
13
|
exit
|
12
14
|
end
|
13
15
|
|
@@ -16,6 +18,11 @@ gitkeep = Gitkeep.new
|
|
16
18
|
# set options
|
17
19
|
gitkeep.dryrun = !ARGV.delete('-d').nil?
|
18
20
|
gitkeep.interactive = !ARGV.delete('-i').nil?
|
21
|
+
gitkeep.autoclean = !ARGV.delete('-ac').nil?
|
22
|
+
if !ARGV.delete('-acc').nil?
|
23
|
+
gitkeep.autoclean = true
|
24
|
+
gitkeep.deindex = true
|
25
|
+
end
|
19
26
|
if !ARGV.delete('-a').nil?
|
20
27
|
gitkeep.search(".")
|
21
28
|
exit
|
@@ -29,4 +36,4 @@ else
|
|
29
36
|
ARGV.each do |arg|
|
30
37
|
gitkeep.create(arg) unless arg =~ /^-+/
|
31
38
|
end
|
32
|
-
end
|
39
|
+
end
|
data/lib/gitkeep.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'find'
|
2
2
|
|
3
3
|
class Gitkeep
|
4
|
-
|
5
|
-
VERSION = '0.2
|
6
|
-
attr_accessor :dryrun, :interactive, :__test
|
4
|
+
|
5
|
+
VERSION = '0.3.2'
|
6
|
+
attr_accessor :dryrun, :interactive, :__test, :autoclean, :deindex
|
7
7
|
attr_reader :file_count, :error_count
|
8
8
|
|
9
9
|
@@ignores = ['.git']
|
@@ -12,11 +12,13 @@ class Gitkeep
|
|
12
12
|
@__test = false
|
13
13
|
@dryrun = false
|
14
14
|
@interactive = false
|
15
|
+
@autoclean = false
|
16
|
+
@deindex = false
|
15
17
|
@file_count = 0
|
16
18
|
@error_count = 0
|
17
19
|
end
|
18
20
|
|
19
|
-
def create(path)
|
21
|
+
def create(path)
|
20
22
|
path = "." if path.empty?
|
21
23
|
|
22
24
|
unless File.directory?(path)
|
@@ -27,21 +29,29 @@ class Gitkeep
|
|
27
29
|
puts "gitkeep is creating files..."
|
28
30
|
|
29
31
|
Find.find(path) do |p|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
name = File.basename(p)
|
33
|
+
if File.directory?(p)
|
34
|
+
if File.readable?(p)
|
35
|
+
if @@ignores.include?(name)
|
36
|
+
Find.prune
|
37
|
+
else
|
36
38
|
if Dir.entries(p).size == 2
|
37
|
-
save(p)
|
39
|
+
save(p)
|
40
|
+
end
|
41
|
+
|
42
|
+
if @autoclean && Dir.entries(p).size >= 3
|
43
|
+
File.delete("#{p}/.gitkeep") if File.exists?("#{p}/.gitkeep")
|
44
|
+
|
45
|
+
if @deindex
|
46
|
+
`git rm -rf #{p}/.gitkeep`
|
47
|
+
end
|
38
48
|
end
|
39
49
|
end
|
40
50
|
else
|
41
51
|
puts red("[error] could not READ in #{p}/ -> check permissions")
|
42
52
|
@error_count += 1
|
43
53
|
end
|
44
|
-
|
54
|
+
end
|
45
55
|
end
|
46
56
|
|
47
57
|
puts "finished. #{@file_count} file(s) created!"
|
@@ -53,11 +63,11 @@ class Gitkeep
|
|
53
63
|
files = []
|
54
64
|
|
55
65
|
Find.find(path) do |p|
|
56
|
-
|
66
|
+
name = File.basename(p)
|
57
67
|
if @@ignores.include?(name)
|
58
|
-
|
59
|
-
|
60
|
-
|
68
|
+
Find.prune
|
69
|
+
else
|
70
|
+
files << p if name == '.gitkeep'
|
61
71
|
end
|
62
72
|
end
|
63
73
|
|
@@ -75,19 +85,19 @@ class Gitkeep
|
|
75
85
|
|
76
86
|
protected if @__test == false
|
77
87
|
|
78
|
-
|
79
|
-
|
88
|
+
def save(path)
|
89
|
+
gitkeep = "#{path}/.gitkeep"
|
80
90
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
+
unless File.writable?(path)
|
92
|
+
puts red("[error] could not WRITE in #{path}/ -> check permissions")
|
93
|
+
@error_count += 1
|
94
|
+
return false
|
95
|
+
end
|
96
|
+
|
97
|
+
return true if File.exists?(gitkeep)
|
98
|
+
|
99
|
+
if @interactive
|
100
|
+
puts "create #{gitkeep} ? [Yn]"
|
91
101
|
a = $stdin.gets # read from stdin to avoid collision with params ARGV
|
92
102
|
return false unless a == "\n" || a.downcase == "y\n"
|
93
103
|
end
|
@@ -105,21 +115,21 @@ class Gitkeep
|
|
105
115
|
end
|
106
116
|
end
|
107
117
|
|
108
|
-
|
118
|
+
private if @__test == false
|
109
119
|
|
110
120
|
def colorize(text, color_code)
|
111
|
-
|
121
|
+
"\e[#{color_code}m#{text}\e[0m"
|
112
122
|
end
|
113
|
-
|
123
|
+
|
114
124
|
def green(text)
|
115
|
-
|
125
|
+
colorize(text, 32)
|
116
126
|
end
|
117
127
|
|
118
128
|
def red(text)
|
119
|
-
|
129
|
+
colorize(text, 31)
|
120
130
|
end
|
121
131
|
|
122
132
|
def blue(text)
|
123
|
-
|
133
|
+
colorize(text, 36)
|
124
134
|
end
|
125
|
-
end
|
135
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitkeep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Arthur Zielinski
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-05-21 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: create .gitkeep files in all empty directories in your project
|
15
14
|
email: arthurz.mobile@gmail.com
|
@@ -22,26 +21,25 @@ files:
|
|
22
21
|
- bin/gitkeep
|
23
22
|
homepage: http://rubygems.org/gems/gitkeep
|
24
23
|
licenses: []
|
24
|
+
metadata: {}
|
25
25
|
post_install_message:
|
26
26
|
rdoc_options: []
|
27
27
|
require_paths:
|
28
28
|
- lib
|
29
29
|
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
-
none: false
|
31
30
|
requirements:
|
32
31
|
- - ! '>='
|
33
32
|
- !ruby/object:Gem::Version
|
34
33
|
version: '0'
|
35
34
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
-
none: false
|
37
35
|
requirements:
|
38
36
|
- - ! '>='
|
39
37
|
- !ruby/object:Gem::Version
|
40
38
|
version: '0'
|
41
39
|
requirements: []
|
42
40
|
rubyforge_project:
|
43
|
-
rubygems_version:
|
41
|
+
rubygems_version: 2.0.3
|
44
42
|
signing_key:
|
45
|
-
specification_version:
|
43
|
+
specification_version: 4
|
46
44
|
summary: gitkeep
|
47
45
|
test_files: []
|