oxidized 0.25.1 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +30 -9
- data/.rubocop_todo.yml +16 -637
- data/.travis.yml +2 -3
- data/CHANGELOG.md +14 -0
- data/Dockerfile +7 -5
- data/README.md +18 -14
- data/Rakefile +2 -2
- data/bin/console +1 -1
- data/bin/oxidized +2 -2
- data/docs/Configuration.md +6 -0
- data/docs/Model-Notes/README.md +1 -0
- data/docs/Model-Notes/SmartAX-Huawei.md +35 -0
- data/docs/Supported-OS-Types.md +12 -0
- data/extra/nagios_check_failing_nodes.rb +1 -1
- data/extra/rest_client.rb +6 -8
- data/extra/syslog.rb +33 -33
- data/lib/oxidized/cli.rb +25 -26
- data/lib/oxidized/config.rb +9 -9
- data/lib/oxidized/config/vars.rb +3 -7
- data/lib/oxidized/core.rb +4 -7
- data/lib/oxidized/hook.rb +16 -17
- data/lib/oxidized/hook/awssns.rb +4 -4
- data/lib/oxidized/hook/exec.rb +16 -20
- data/lib/oxidized/hook/githubrepo.rb +8 -14
- data/lib/oxidized/hook/noophook.rb +1 -1
- data/lib/oxidized/hook/xmppdiff.rb +1 -1
- data/lib/oxidized/input/cli.rb +12 -12
- data/lib/oxidized/input/ftp.rb +8 -8
- data/lib/oxidized/input/http.rb +37 -14
- data/lib/oxidized/input/input.rb +6 -6
- data/lib/oxidized/input/ssh.rb +31 -31
- data/lib/oxidized/input/telnet.rb +24 -24
- data/lib/oxidized/input/tftp.rb +9 -10
- data/lib/oxidized/jobs.rb +7 -7
- data/lib/oxidized/manager.rb +13 -13
- data/lib/oxidized/model/acos.rb +2 -2
- data/lib/oxidized/model/aireos.rb +3 -3
- data/lib/oxidized/model/aos7.rb +1 -1
- data/lib/oxidized/model/aosw.rb +12 -14
- data/lib/oxidized/model/apc_aos.rb +1 -1
- data/lib/oxidized/model/aricentiss.rb +6 -8
- data/lib/oxidized/model/asa.rb +1 -1
- data/lib/oxidized/model/audiocodesmp.rb +28 -0
- data/lib/oxidized/model/awplus.rb +9 -9
- data/lib/oxidized/model/boss.rb +1 -1
- data/lib/oxidized/model/ciscosmb.rb +1 -1
- data/lib/oxidized/model/ciscovpn3k.rb +11 -0
- data/lib/oxidized/model/comware.rb +1 -1
- data/lib/oxidized/model/cumulus.rb +3 -1
- data/lib/oxidized/model/dellx.rb +5 -5
- data/lib/oxidized/model/edgeos.rb +1 -1
- data/lib/oxidized/model/edgeswitch.rb +1 -1
- data/lib/oxidized/model/fabricos.rb +1 -1
- data/lib/oxidized/model/fortios.rb +5 -5
- data/lib/oxidized/model/ftos.rb +1 -1
- data/lib/oxidized/model/gcombnps.rb +7 -7
- data/lib/oxidized/model/grandstream.rb +9 -0
- data/lib/oxidized/model/hatteras.rb +8 -8
- data/lib/oxidized/model/ios.rb +22 -40
- data/lib/oxidized/model/ironware.rb +1 -1
- data/lib/oxidized/model/junos.rb +1 -1
- data/lib/oxidized/model/mlnxos.rb +1 -1
- data/lib/oxidized/model/model.rb +32 -38
- data/lib/oxidized/model/netgearxs716.rb +23 -0
- data/lib/oxidized/model/netonix.rb +1 -1
- data/lib/oxidized/model/netscaler.rb +1 -1
- data/lib/oxidized/model/nos.rb +2 -2
- data/lib/oxidized/model/nxos.rb +1 -1
- data/lib/oxidized/model/openbsd.rb +3 -2
- data/lib/oxidized/model/outputs.rb +4 -4
- data/lib/oxidized/model/planet.rb +4 -4
- data/lib/oxidized/model/powerconnect.rb +8 -8
- data/lib/oxidized/model/procurve.rb +2 -1
- data/lib/oxidized/model/quantaos.rb +3 -3
- data/lib/oxidized/model/raisecom.rb +19 -0
- data/lib/oxidized/model/siklu.rb +1 -1
- data/lib/oxidized/model/slxos.rb +1 -1
- data/lib/oxidized/model/smartax.rb +25 -0
- data/lib/oxidized/model/sros.rb +4 -4
- data/lib/oxidized/model/tdre.rb +30 -0
- data/lib/oxidized/model/tmos.rb +3 -0
- data/lib/oxidized/model/trango.rb +17 -37
- data/lib/oxidized/model/voltaire.rb +1 -1
- data/lib/oxidized/model/voss.rb +1 -1
- data/lib/oxidized/model/vyatta.rb +1 -1
- data/lib/oxidized/model/xos.rb +1 -1
- data/lib/oxidized/model/zhoneolt.rb +1 -1
- data/lib/oxidized/node.rb +42 -46
- data/lib/oxidized/node/stats.rb +6 -6
- data/lib/oxidized/nodes.rb +42 -42
- data/lib/oxidized/output/file.rb +16 -20
- data/lib/oxidized/output/git.rb +68 -78
- data/lib/oxidized/output/gitcrypt.rb +77 -91
- data/lib/oxidized/output/http.rb +17 -19
- data/lib/oxidized/output/output.rb +1 -1
- data/lib/oxidized/source/csv.rb +3 -3
- data/lib/oxidized/source/http.rb +11 -14
- data/lib/oxidized/source/source.rb +3 -3
- data/lib/oxidized/source/sql.rb +16 -18
- data/lib/oxidized/string.rb +10 -10
- data/lib/oxidized/version.rb +4 -4
- data/lib/oxidized/worker.rb +15 -15
- data/oxidized.gemspec +6 -9
- metadata +32 -25
data/lib/oxidized/node/stats.rb
CHANGED
@@ -6,11 +6,11 @@ module Oxidized
|
|
6
6
|
|
7
7
|
# @param [Job] job job whose information add to stats
|
8
8
|
# @return [void]
|
9
|
-
def add
|
9
|
+
def add(job)
|
10
10
|
stat = {
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
11
|
+
start: job.start,
|
12
|
+
end: job.end,
|
13
|
+
time: job.time
|
14
14
|
}
|
15
15
|
@stats[job.status] ||= []
|
16
16
|
@stats[job.status].shift if @stats[job.status].size > @history_size
|
@@ -20,11 +20,11 @@ module Oxidized
|
|
20
20
|
|
21
21
|
# @param [Symbol] status stats for specific status
|
22
22
|
# @return [Hash,Array] Hash of stats for every status or Array of stats for specific status
|
23
|
-
def get
|
23
|
+
def get(status = nil)
|
24
24
|
status ? @stats[status] : @stats
|
25
25
|
end
|
26
26
|
|
27
|
-
def get_counter
|
27
|
+
def get_counter(counter = nil)
|
28
28
|
counter ? @stats[:counter][counter] : @stats[:counter]
|
29
29
|
end
|
30
30
|
|
data/lib/oxidized/nodes.rb
CHANGED
@@ -5,12 +5,12 @@ module Oxidized
|
|
5
5
|
class Oxidized::NodeNotFound < OxidizedError; end
|
6
6
|
class Nodes < Array
|
7
7
|
attr_accessor :source, :jobs
|
8
|
-
alias
|
9
|
-
def load
|
8
|
+
alias put unshift
|
9
|
+
def load(node_want = nil)
|
10
10
|
with_lock do
|
11
11
|
new = []
|
12
12
|
@source = Oxidized.config.source.default
|
13
|
-
Oxidized.mgr.add_source(@source)
|
13
|
+
Oxidized.mgr.add_source(@source) || raise(MethodNotFound, "cannot load node source '#{@source}', not found")
|
14
14
|
Oxidized.logger.info "lib/oxidized/nodes.rb: Loading nodes"
|
15
15
|
nodes = Oxidized.mgr.source[@source].new.load node_want
|
16
16
|
nodes.each do |node|
|
@@ -18,27 +18,27 @@ module Oxidized
|
|
18
18
|
next unless node_want? node_want, node
|
19
19
|
|
20
20
|
begin
|
21
|
-
|
22
|
-
new.push
|
21
|
+
node_obj = Node.new node
|
22
|
+
new.push node_obj
|
23
23
|
rescue ModelNotFound => err
|
24
24
|
Oxidized.logger.error "node %s raised %s with message '%s'" % [node, err.class, err.message]
|
25
25
|
rescue Resolv::ResolvError => err
|
26
26
|
Oxidized.logger.error "node %s is not resolvable, raised %s with message '%s'" % [node, err.class, err.message]
|
27
27
|
end
|
28
28
|
end
|
29
|
-
size
|
29
|
+
size.zero? ? replace(new) : update_nodes(new)
|
30
30
|
Oxidized.logger.info "lib/oxidized/nodes.rb: Loaded #{size} nodes"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def node_want?
|
34
|
+
def node_want?(node_want, node)
|
35
35
|
return true unless node_want
|
36
36
|
|
37
37
|
node_want_ip = (IPAddr.new(node_want) rescue false)
|
38
38
|
name_is_ip = (IPAddr.new(node[:name]) rescue false)
|
39
|
-
if name_is_ip
|
39
|
+
if name_is_ip && (node_want_ip == node[:name])
|
40
40
|
true
|
41
|
-
elsif node[:ip]
|
41
|
+
elsif node[:ip] && (node_want_ip == node[:ip])
|
42
42
|
true
|
43
43
|
elsif node_want.match node[:name]
|
44
44
|
true unless name_is_ip
|
@@ -51,36 +51,36 @@ module Oxidized
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
def show
|
54
|
+
def show(node)
|
55
55
|
with_lock do
|
56
56
|
i = find_node_index node
|
57
57
|
self[i].serialize
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
def fetch
|
61
|
+
def fetch(node_name, group)
|
62
62
|
yield_node_output(node_name) do |node, output|
|
63
63
|
output.fetch node, group
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
# @param node [String] name of the node moved into the head of array
|
68
|
-
def next
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
68
|
+
def next(node, opt = {})
|
69
|
+
return unless waiting.find_node_index(node)
|
70
|
+
|
71
|
+
with_lock do
|
72
|
+
n = del node
|
73
|
+
n.user = opt['user']
|
74
|
+
n.email = opt['email']
|
75
|
+
n.msg = opt['msg']
|
76
|
+
n.from = opt['from']
|
77
|
+
# set last job to nil so that the node is picked for immediate update
|
78
|
+
n.last = nil
|
79
|
+
put n
|
80
|
+
jobs.want += 1 if Oxidized.config.next_adds_job?
|
81
81
|
end
|
82
82
|
end
|
83
|
-
alias
|
83
|
+
alias top next
|
84
84
|
|
85
85
|
# @return [String] node from the head of the array
|
86
86
|
def get
|
@@ -91,23 +91,23 @@ module Oxidized
|
|
91
91
|
|
92
92
|
# @param node node whose index number in Nodes to find
|
93
93
|
# @return [Fixnum] index number of node in Nodes
|
94
|
-
def find_node_index
|
95
|
-
find_index
|
94
|
+
def find_node_index(node)
|
95
|
+
find_index(node) || raise(Oxidized::NodeNotFound, "unable to find '#{node}'")
|
96
96
|
end
|
97
97
|
|
98
|
-
def version
|
98
|
+
def version(node_name, group)
|
99
99
|
yield_node_output(node_name) do |node, output|
|
100
100
|
output.version node, group
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
def get_version
|
104
|
+
def get_version(node_name, group, oid)
|
105
105
|
yield_node_output(node_name) do |node, output|
|
106
106
|
output.get_version node, group, oid
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
def get_diff
|
110
|
+
def get_diff(node_name, group, oid1, oid2)
|
111
111
|
yield_node_output(node_name) do |node, output|
|
112
112
|
output.get_diff node, group, oid1, oid2
|
113
113
|
end
|
@@ -115,39 +115,39 @@ module Oxidized
|
|
115
115
|
|
116
116
|
private
|
117
117
|
|
118
|
-
def initialize
|
118
|
+
def initialize(opts = {})
|
119
119
|
super()
|
120
120
|
node = opts.delete :node
|
121
121
|
@mutex = Mutex.new # we compete for the nodes with webapi thread
|
122
|
-
if nodes = opts.delete(:nodes)
|
122
|
+
if (nodes = opts.delete(:nodes))
|
123
123
|
replace nodes
|
124
124
|
else
|
125
125
|
load node
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
-
def with_lock
|
129
|
+
def with_lock(&block)
|
130
130
|
@mutex.synchronize(&block)
|
131
131
|
end
|
132
132
|
|
133
|
-
def find_index
|
134
|
-
index { |e| e.name
|
133
|
+
def find_index(node)
|
134
|
+
index { |e| [e.name, e.ip].include? node }
|
135
135
|
end
|
136
136
|
|
137
137
|
# @param node node which is removed from nodes list
|
138
138
|
# @return [Node] deleted node
|
139
|
-
def del
|
139
|
+
def del(node)
|
140
140
|
delete_at find_node_index(node)
|
141
141
|
end
|
142
142
|
|
143
143
|
# @return [Nodes] list of nodes running now
|
144
144
|
def running
|
145
|
-
Nodes.new :
|
145
|
+
Nodes.new nodes: select { |node| node.running? }
|
146
146
|
end
|
147
147
|
|
148
148
|
# @return [Nodes] list of nodes waiting (not running)
|
149
149
|
def waiting
|
150
|
-
Nodes.new :
|
150
|
+
Nodes.new nodes: select { |node| not node.running? }
|
151
151
|
end
|
152
152
|
|
153
153
|
# walks list of new nodes, if old node contains same name, adds last and
|
@@ -155,16 +155,16 @@ module Oxidized
|
|
155
155
|
#
|
156
156
|
# @todo can we trust name to be unique identifier, what about when groups are used?
|
157
157
|
# @param [Array] nodes Array of nodes used to replace+update old
|
158
|
-
def update_nodes
|
159
|
-
old =
|
158
|
+
def update_nodes(nodes)
|
159
|
+
old = dup
|
160
160
|
replace(nodes)
|
161
161
|
each do |node|
|
162
162
|
begin
|
163
|
-
if i = old.find_node_index(node.name)
|
163
|
+
if (i = old.find_node_index(node.name))
|
164
164
|
node.stats = old[i].stats
|
165
165
|
node.last = old[i].last
|
166
166
|
end
|
167
|
-
rescue Oxidized::NodeNotFound
|
167
|
+
rescue Oxidized::NodeNotFound # rubocop:disable Lint/HandleExceptions
|
168
168
|
end
|
169
169
|
end
|
170
170
|
sort_by! { |x| x.last.nil? ? Time.new(0) : x.last.end }
|
data/lib/oxidized/output/file.rb
CHANGED
@@ -9,49 +9,45 @@ module Oxidized
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def setup
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
return unless @cfg.empty?
|
13
|
+
|
14
|
+
Oxidized.asetus.user.output.file.directory = File.join(Config::Root, 'configs')
|
15
|
+
Oxidized.asetus.save :user
|
16
|
+
raise NoConfig, 'no output file config, edit ~/.config/oxidized/config'
|
17
17
|
end
|
18
18
|
|
19
|
-
def store
|
19
|
+
def store(node, outputs, opt = {})
|
20
20
|
file = File.expand_path @cfg.directory
|
21
|
-
if opt[:group]
|
22
|
-
file = File.join File.dirname(file), opt[:group]
|
23
|
-
end
|
21
|
+
file = File.join File.dirname(file), opt[:group] if opt[:group]
|
24
22
|
FileUtils.mkdir_p file
|
25
23
|
file = File.join file, node
|
26
|
-
open(file, 'w') { |fh| fh.write outputs.to_cfg }
|
24
|
+
File.open(file, 'w') { |fh| fh.write outputs.to_cfg }
|
27
25
|
@commitref = file
|
28
26
|
end
|
29
27
|
|
30
|
-
def fetch
|
28
|
+
def fetch(node, group)
|
31
29
|
cfg_dir = File.expand_path @cfg.directory
|
32
30
|
node_name = node.name
|
33
31
|
|
34
32
|
if group # group is explicitly defined by user
|
35
33
|
cfg_dir = File.join File.dirname(cfg_dir), group
|
36
34
|
File.read File.join(cfg_dir, node_name)
|
35
|
+
elsif File.exist? File.join(cfg_dir, node_name) # node configuration file is stored on base directory
|
36
|
+
File.read File.join(cfg_dir, node_name)
|
37
37
|
else
|
38
|
-
|
39
|
-
|
40
|
-
else
|
41
|
-
path = Dir.glob(File.join(File.dirname(cfg_dir), '**', node_name)).first # fetch node in all groups
|
42
|
-
File.read path
|
43
|
-
end
|
38
|
+
path = Dir.glob(File.join(File.dirname(cfg_dir), '**', node_name)).first # fetch node in all groups
|
39
|
+
File.read path
|
44
40
|
end
|
45
41
|
rescue Errno::ENOENT
|
46
|
-
|
42
|
+
nil
|
47
43
|
end
|
48
44
|
|
49
|
-
def version
|
45
|
+
def version(_node, _group)
|
50
46
|
# not supported
|
51
47
|
[]
|
52
48
|
end
|
53
49
|
|
54
|
-
def get_version
|
50
|
+
def get_version(_node, _group, _oid)
|
55
51
|
'not supported'
|
56
52
|
end
|
57
53
|
end
|
data/lib/oxidized/output/git.rb
CHANGED
@@ -31,10 +31,10 @@ module Oxidized
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def store
|
34
|
+
def store(file, outputs, opt = {})
|
35
35
|
@msg = opt[:msg]
|
36
|
-
@user = (opt[:user]
|
37
|
-
@email = (opt[:email]
|
36
|
+
@user = (opt[:user] || @cfg.user)
|
37
|
+
@email = (opt[:email] || @cfg.email)
|
38
38
|
@opt = opt
|
39
39
|
@commitref = nil
|
40
40
|
repo = @cfg.repo
|
@@ -43,7 +43,7 @@ module Oxidized
|
|
43
43
|
type_cfg = ''
|
44
44
|
type_repo = File.join(File.dirname(repo), type + '.git')
|
45
45
|
outputs.type(type).each do |output|
|
46
|
-
(type_cfg << output; next)
|
46
|
+
(type_cfg << output; next) unless output.name # rubocop:disable Style/Semicolon
|
47
47
|
type_file = file + '--' + output.name
|
48
48
|
if @cfg.type_as_directory?
|
49
49
|
type_file = type + '/' + type_file
|
@@ -57,85 +57,77 @@ module Oxidized
|
|
57
57
|
update repo, file, outputs.to_cfg
|
58
58
|
end
|
59
59
|
|
60
|
-
def fetch
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
'node not found'
|
69
|
-
end
|
60
|
+
def fetch(node, group)
|
61
|
+
repo, path = yield_repo_and_path(node, group)
|
62
|
+
repo = Rugged::Repository.new repo
|
63
|
+
index = repo.index
|
64
|
+
index.read_tree repo.head.target.tree unless repo.empty?
|
65
|
+
repo.read(index.get(path)[:oid]).data
|
66
|
+
rescue StandardError
|
67
|
+
'node not found'
|
70
68
|
end
|
71
69
|
|
72
70
|
# give a hash of all oid revision for the given node, and the date of the commit
|
73
|
-
def version
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
92
|
-
end
|
93
|
-
walker.reset
|
94
|
-
tab
|
95
|
-
rescue
|
96
|
-
'node not found'
|
71
|
+
def version(node, group)
|
72
|
+
repo, path = yield_repo_and_path(node, group)
|
73
|
+
|
74
|
+
repo = Rugged::Repository.new repo
|
75
|
+
walker = Rugged::Walker.new(repo)
|
76
|
+
walker.sorting(Rugged::SORT_DATE)
|
77
|
+
walker.push(repo.head.target)
|
78
|
+
i = -1
|
79
|
+
tab = []
|
80
|
+
walker.each do |commit|
|
81
|
+
next if commit.diff(paths: [path]).empty?
|
82
|
+
|
83
|
+
hash = {}
|
84
|
+
hash[:date] = commit.time.to_s
|
85
|
+
hash[:oid] = commit.oid
|
86
|
+
hash[:author] = commit.author
|
87
|
+
hash[:message] = commit.message
|
88
|
+
tab[i += 1] = hash
|
97
89
|
end
|
90
|
+
walker.reset
|
91
|
+
tab
|
92
|
+
rescue StandardError
|
93
|
+
'node not found'
|
98
94
|
end
|
99
95
|
|
100
96
|
# give the blob of a specific revision
|
101
|
-
def get_version
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
'version not found'
|
108
|
-
end
|
97
|
+
def get_version(node, group, oid)
|
98
|
+
repo, path = yield_repo_and_path(node, group)
|
99
|
+
repo = Rugged::Repository.new repo
|
100
|
+
repo.blob_at(oid, path).content
|
101
|
+
rescue StandardError
|
102
|
+
'version not found'
|
109
103
|
end
|
110
104
|
|
111
105
|
# give a hash with the patch of a diff between 2 revision and the stats (added and deleted lines)
|
112
|
-
def get_diff
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
break
|
126
|
-
end
|
106
|
+
def get_diff(node, group, oid1, oid2)
|
107
|
+
diff_commits = nil
|
108
|
+
repo, = yield_repo_and_path(node, group)
|
109
|
+
repo = Rugged::Repository.new repo
|
110
|
+
commit = repo.lookup(oid1)
|
111
|
+
|
112
|
+
if oid2
|
113
|
+
commit_old = repo.lookup(oid2)
|
114
|
+
diff = repo.diff(commit_old, commit)
|
115
|
+
diff.each do |patch|
|
116
|
+
if /#{node.name}\s+/ =~ patch.to_s.lines.first
|
117
|
+
diff_commits = { patch: patch.to_s, stat: patch.stat }
|
118
|
+
break
|
127
119
|
end
|
128
|
-
else
|
129
|
-
stat = commit.parents[0].diff(commit).stat
|
130
|
-
stat = [stat[1], stat[2]]
|
131
|
-
patch = commit.parents[0].diff(commit).patch
|
132
|
-
diff_commits = { :patch => patch, :stat => stat }
|
133
120
|
end
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
121
|
+
else
|
122
|
+
stat = commit.parents[0].diff(commit).stat
|
123
|
+
stat = [stat[1], stat[2]]
|
124
|
+
patch = commit.parents[0].diff(commit).patch
|
125
|
+
diff_commits = { patch: patch, stat: stat }
|
138
126
|
end
|
127
|
+
|
128
|
+
diff_commits
|
129
|
+
rescue StandardError
|
130
|
+
'no diffs'
|
139
131
|
end
|
140
132
|
|
141
133
|
private
|
@@ -143,14 +135,12 @@ module Oxidized
|
|
143
135
|
def yield_repo_and_path(node, group)
|
144
136
|
repo, path = node.repo, node.name
|
145
137
|
|
146
|
-
if group
|
147
|
-
path = "#{group}/#{node.name}"
|
148
|
-
end
|
138
|
+
path = "#{group}/#{node.name}" if group && @cfg.single_repo?
|
149
139
|
|
150
140
|
[repo, path]
|
151
141
|
end
|
152
142
|
|
153
|
-
def update
|
143
|
+
def update(repo, file, data)
|
154
144
|
return if data.empty?
|
155
145
|
|
156
146
|
if @opt[:group]
|
@@ -171,20 +161,20 @@ module Oxidized
|
|
171
161
|
rescue Rugged::OSError, Rugged::RepositoryError => open_error
|
172
162
|
begin
|
173
163
|
Rugged::Repository.init_at repo, :bare
|
174
|
-
rescue => create_error
|
164
|
+
rescue StandardError => create_error
|
175
165
|
raise GitError, "first '#{open_error.message}' was raised while opening git repo, then '#{create_error.message}' was while trying to create git repo"
|
176
166
|
end
|
177
167
|
retry
|
178
168
|
end
|
179
169
|
end
|
180
170
|
|
181
|
-
def update_repo
|
171
|
+
def update_repo(repo, file, data)
|
182
172
|
oid_old = repo.blob_at(repo.head.target_id, file) rescue nil
|
183
|
-
return false if oid_old
|
173
|
+
return false if oid_old && (oid_old.content.b == data.b)
|
184
174
|
|
185
175
|
oid = repo.write data, :blob
|
186
176
|
index = repo.index
|
187
|
-
index.add path: file, oid: oid, mode:
|
177
|
+
index.add path: file, oid: oid, mode: 0o100644
|
188
178
|
|
189
179
|
repo.config['user.name'] = @user
|
190
180
|
repo.config['user.email'] = @email
|