mgmt 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/mgmt +53 -35
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0dca341a6b2e3e10a68e4801180d0ccffa6765c
|
4
|
+
data.tar.gz: d49f1de8ae327fc31b5ad1c521ea4c341ff7ff82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf018f3223b6f6ebde93cfcb515aa7e1022b57c4e8d890366baabb7fa8c984cfcb89fc0255208c1e49a6266e7aa0502d129ac5a822df9eb84c3a8da678c05480
|
7
|
+
data.tar.gz: d2c5a7a62dd93fd5ce5ae3e690bb20294e6e87833b19385516722d57a382740b65f19964b989db7ff08853816c9c4f7c918f093b66542d1a8732ccfc77328e82
|
data/bin/mgmt
CHANGED
@@ -9,7 +9,7 @@ module MGMT
|
|
9
9
|
DEPSFILE = "Gopherfile"
|
10
10
|
LOCKFILE = "Gopherfile.lock"
|
11
11
|
VENDOR = ".vendor"
|
12
|
-
VERSION = "0.
|
12
|
+
VERSION = "0.3.0"
|
13
13
|
|
14
14
|
def xputs(code, msg)
|
15
15
|
code = nil if ENV['TERM'] != "xterm"
|
@@ -23,6 +23,12 @@ module MGMT
|
|
23
23
|
system(cmd) || abort("Failed to execute command: #{cmd}")
|
24
24
|
end
|
25
25
|
|
26
|
+
def shv(cmd)
|
27
|
+
value = `#{cmd}`
|
28
|
+
abort "Failed to execute command: #{cmd}" unless $?.success?
|
29
|
+
value.strip
|
30
|
+
end
|
31
|
+
|
26
32
|
def abort(msg)
|
27
33
|
xputs "31", ">>> #{msg}"
|
28
34
|
Kernel.exit(1)
|
@@ -31,8 +37,8 @@ module MGMT
|
|
31
37
|
def read
|
32
38
|
abort "#{DEPSFILE} not found" unless File.exist?(DEPSFILE)
|
33
39
|
|
34
|
-
deps = Deps.parse(DEPSFILE)
|
35
|
-
deps.merge! Deps.parse(LOCKFILE) if File.exist?(LOCKFILE)
|
40
|
+
deps = Deps.parse(DEPSFILE, :tag)
|
41
|
+
deps.merge! Deps.parse(LOCKFILE, :rev) if File.exist?(LOCKFILE)
|
36
42
|
deps
|
37
43
|
end
|
38
44
|
|
@@ -40,11 +46,24 @@ module MGMT
|
|
40
46
|
deps.each do |dep|
|
41
47
|
MGMT.xputs "33", "### #{dep.name}"
|
42
48
|
if dep.pull!
|
43
|
-
MGMT.xputs nil, " now at ##{dep.
|
49
|
+
MGMT.xputs nil, " now at ##{dep.version}"
|
44
50
|
end
|
45
51
|
end
|
46
52
|
end
|
47
53
|
|
54
|
+
def update(deps, updates)
|
55
|
+
versions = {}
|
56
|
+
updates.each do |str|
|
57
|
+
name, rev = str.split("#", 2)
|
58
|
+
versions[name] = rev
|
59
|
+
end
|
60
|
+
deps.select do |dep|
|
61
|
+
versions.include?(dep.name)
|
62
|
+
end.each do |dep|
|
63
|
+
dep.rev = versions[dep.name]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
48
67
|
def lock(deps)
|
49
68
|
deps.lock!
|
50
69
|
MGMT.xputs "32", "=== #{LOCKFILE} written"
|
@@ -52,15 +71,15 @@ module MGMT
|
|
52
71
|
|
53
72
|
def exec(*c)
|
54
73
|
ENV['GOPATH'] = "#{File.expand_path(VENDOR, ".")}:#{ENV['GOPATH']}"
|
55
|
-
Kernel.exec
|
74
|
+
Kernel.exec(*c)
|
56
75
|
end
|
57
76
|
|
58
77
|
class Deps < Array
|
59
78
|
|
60
|
-
def self.parse(file)
|
79
|
+
def self.parse(file, field)
|
61
80
|
deps = []
|
62
81
|
File.read(file).each_line do |line|
|
63
|
-
deps.push Dep.parse(line)
|
82
|
+
deps.push Dep.parse(line, field)
|
64
83
|
end
|
65
84
|
new deps.compact
|
66
85
|
end
|
@@ -69,28 +88,20 @@ module MGMT
|
|
69
88
|
detect {|i| i.name == name }
|
70
89
|
end
|
71
90
|
|
72
|
-
def
|
73
|
-
self.class.new
|
74
|
-
end
|
75
|
-
|
76
|
-
def reset!
|
77
|
-
each do |dep|
|
78
|
-
dep.tag = nil
|
79
|
-
end
|
91
|
+
def select
|
92
|
+
self.class.new(super)
|
80
93
|
end
|
81
94
|
|
82
95
|
def merge!(locked)
|
83
96
|
each do |dep|
|
84
|
-
|
85
|
-
|
86
|
-
match = locked.find(dep.name)
|
87
|
-
dep.tag = match.tag if match
|
97
|
+
match = locked.find(dep.name)
|
98
|
+
dep.rev = match.rev if match
|
88
99
|
end
|
89
100
|
end
|
90
101
|
|
91
102
|
def lock!
|
92
103
|
temp = Tempfile.new LOCKFILE
|
93
|
-
each {|
|
104
|
+
each {|dep| temp.puts dep.to_s }
|
94
105
|
temp.close
|
95
106
|
FileUtils.mv temp.path, LOCKFILE
|
96
107
|
end
|
@@ -99,7 +110,7 @@ module MGMT
|
|
99
110
|
|
100
111
|
class Dep
|
101
112
|
|
102
|
-
def self.parse(line)
|
113
|
+
def self.parse(line, field)
|
103
114
|
line = line.strip
|
104
115
|
return if line[0] == "#"
|
105
116
|
|
@@ -112,18 +123,19 @@ module MGMT
|
|
112
123
|
when "!", 33
|
113
124
|
opts[:repo] = token[1..-1]
|
114
125
|
when "#", 35
|
115
|
-
opts[
|
126
|
+
opts[field] = token[1..-1]
|
116
127
|
end
|
117
128
|
end
|
118
129
|
new tokens[0], opts
|
119
130
|
end
|
120
131
|
|
121
132
|
attr_reader :name, :repo
|
122
|
-
attr_accessor :tag
|
133
|
+
attr_accessor :tag, :rev
|
123
134
|
|
124
135
|
def initialize(name, opts = {})
|
125
136
|
@name = name
|
126
|
-
@tag = opts[:tag]
|
137
|
+
@tag = opts[:tag] # Specified tag
|
138
|
+
@rev = opts[:rev] # Locked rev
|
127
139
|
@repo = opts[:repo] || "http://#{name}"
|
128
140
|
end
|
129
141
|
|
@@ -131,22 +143,29 @@ module MGMT
|
|
131
143
|
@target ||= File.join(VENDOR, 'src', @name)
|
132
144
|
end
|
133
145
|
|
146
|
+
def version
|
147
|
+
@rev || @tag || 'master'
|
148
|
+
end
|
149
|
+
|
134
150
|
def pull!
|
135
|
-
|
136
|
-
if
|
137
|
-
|
138
|
-
|
139
|
-
else
|
151
|
+
current = MGMT.shv("cd #{target} && git --git-dir=.git log -n 1 --pretty=format:'%h'") if File.directory?(target)
|
152
|
+
return false if current && current == rev
|
153
|
+
|
154
|
+
if current.nil?
|
140
155
|
MGMT.sh "git clone -q #{@repo} #{target}"
|
156
|
+
else
|
157
|
+
MGMT.sh "cd #{target} && git --git-dir=.git fetch -q origin"
|
141
158
|
end
|
142
159
|
|
143
|
-
|
144
|
-
MGMT.
|
145
|
-
|
160
|
+
remote = "origin/#{version}"
|
161
|
+
@rev = MGMT.shv "cd #{target} && git --git-dir=.git show-ref -q #{remote} && git --git-dir=.git rev-parse --short #{remote} || git --git-dir=.git rev-parse --short #{version}"
|
162
|
+
|
163
|
+
MGMT.sh "cd #{target} && git --git-dir=.git reset -q --hard #{rev}"
|
164
|
+
true
|
146
165
|
end
|
147
166
|
|
148
167
|
def to_s
|
149
|
-
"#{@name} ##{
|
168
|
+
"#{@name} ##{version} !#{@repo}"
|
150
169
|
end
|
151
170
|
end
|
152
171
|
end
|
@@ -162,9 +181,8 @@ when "go"
|
|
162
181
|
MGMT.exec "go", *ARGV
|
163
182
|
when "update"
|
164
183
|
deps = MGMT.read
|
165
|
-
some =
|
184
|
+
some = MGMT.update(deps, ARGV)
|
166
185
|
unless some.empty?
|
167
|
-
some.reset!
|
168
186
|
MGMT.pull(some)
|
169
187
|
MGMT.lock(deps)
|
170
188
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mgmt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitrij Denissenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -57,8 +57,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
57
|
version: '0'
|
58
58
|
requirements: []
|
59
59
|
rubyforge_project:
|
60
|
-
rubygems_version: 2.4.
|
60
|
+
rubygems_version: 2.4.6
|
61
61
|
signing_key:
|
62
62
|
specification_version: 4
|
63
63
|
summary: a minimalistic, self-contained, massively opinionated dependency manager
|
64
64
|
test_files: []
|
65
|
+
has_rdoc:
|