oxidized 0.25.1 → 0.26.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +30 -9
  3. data/.rubocop_todo.yml +16 -637
  4. data/.travis.yml +2 -3
  5. data/CHANGELOG.md +14 -0
  6. data/Dockerfile +7 -5
  7. data/README.md +18 -14
  8. data/Rakefile +2 -2
  9. data/bin/console +1 -1
  10. data/bin/oxidized +2 -2
  11. data/docs/Configuration.md +6 -0
  12. data/docs/Model-Notes/README.md +1 -0
  13. data/docs/Model-Notes/SmartAX-Huawei.md +35 -0
  14. data/docs/Supported-OS-Types.md +12 -0
  15. data/extra/nagios_check_failing_nodes.rb +1 -1
  16. data/extra/rest_client.rb +6 -8
  17. data/extra/syslog.rb +33 -33
  18. data/lib/oxidized/cli.rb +25 -26
  19. data/lib/oxidized/config.rb +9 -9
  20. data/lib/oxidized/config/vars.rb +3 -7
  21. data/lib/oxidized/core.rb +4 -7
  22. data/lib/oxidized/hook.rb +16 -17
  23. data/lib/oxidized/hook/awssns.rb +4 -4
  24. data/lib/oxidized/hook/exec.rb +16 -20
  25. data/lib/oxidized/hook/githubrepo.rb +8 -14
  26. data/lib/oxidized/hook/noophook.rb +1 -1
  27. data/lib/oxidized/hook/xmppdiff.rb +1 -1
  28. data/lib/oxidized/input/cli.rb +12 -12
  29. data/lib/oxidized/input/ftp.rb +8 -8
  30. data/lib/oxidized/input/http.rb +37 -14
  31. data/lib/oxidized/input/input.rb +6 -6
  32. data/lib/oxidized/input/ssh.rb +31 -31
  33. data/lib/oxidized/input/telnet.rb +24 -24
  34. data/lib/oxidized/input/tftp.rb +9 -10
  35. data/lib/oxidized/jobs.rb +7 -7
  36. data/lib/oxidized/manager.rb +13 -13
  37. data/lib/oxidized/model/acos.rb +2 -2
  38. data/lib/oxidized/model/aireos.rb +3 -3
  39. data/lib/oxidized/model/aos7.rb +1 -1
  40. data/lib/oxidized/model/aosw.rb +12 -14
  41. data/lib/oxidized/model/apc_aos.rb +1 -1
  42. data/lib/oxidized/model/aricentiss.rb +6 -8
  43. data/lib/oxidized/model/asa.rb +1 -1
  44. data/lib/oxidized/model/audiocodesmp.rb +28 -0
  45. data/lib/oxidized/model/awplus.rb +9 -9
  46. data/lib/oxidized/model/boss.rb +1 -1
  47. data/lib/oxidized/model/ciscosmb.rb +1 -1
  48. data/lib/oxidized/model/ciscovpn3k.rb +11 -0
  49. data/lib/oxidized/model/comware.rb +1 -1
  50. data/lib/oxidized/model/cumulus.rb +3 -1
  51. data/lib/oxidized/model/dellx.rb +5 -5
  52. data/lib/oxidized/model/edgeos.rb +1 -1
  53. data/lib/oxidized/model/edgeswitch.rb +1 -1
  54. data/lib/oxidized/model/fabricos.rb +1 -1
  55. data/lib/oxidized/model/fortios.rb +5 -5
  56. data/lib/oxidized/model/ftos.rb +1 -1
  57. data/lib/oxidized/model/gcombnps.rb +7 -7
  58. data/lib/oxidized/model/grandstream.rb +9 -0
  59. data/lib/oxidized/model/hatteras.rb +8 -8
  60. data/lib/oxidized/model/ios.rb +22 -40
  61. data/lib/oxidized/model/ironware.rb +1 -1
  62. data/lib/oxidized/model/junos.rb +1 -1
  63. data/lib/oxidized/model/mlnxos.rb +1 -1
  64. data/lib/oxidized/model/model.rb +32 -38
  65. data/lib/oxidized/model/netgearxs716.rb +23 -0
  66. data/lib/oxidized/model/netonix.rb +1 -1
  67. data/lib/oxidized/model/netscaler.rb +1 -1
  68. data/lib/oxidized/model/nos.rb +2 -2
  69. data/lib/oxidized/model/nxos.rb +1 -1
  70. data/lib/oxidized/model/openbsd.rb +3 -2
  71. data/lib/oxidized/model/outputs.rb +4 -4
  72. data/lib/oxidized/model/planet.rb +4 -4
  73. data/lib/oxidized/model/powerconnect.rb +8 -8
  74. data/lib/oxidized/model/procurve.rb +2 -1
  75. data/lib/oxidized/model/quantaos.rb +3 -3
  76. data/lib/oxidized/model/raisecom.rb +19 -0
  77. data/lib/oxidized/model/siklu.rb +1 -1
  78. data/lib/oxidized/model/slxos.rb +1 -1
  79. data/lib/oxidized/model/smartax.rb +25 -0
  80. data/lib/oxidized/model/sros.rb +4 -4
  81. data/lib/oxidized/model/tdre.rb +30 -0
  82. data/lib/oxidized/model/tmos.rb +3 -0
  83. data/lib/oxidized/model/trango.rb +17 -37
  84. data/lib/oxidized/model/voltaire.rb +1 -1
  85. data/lib/oxidized/model/voss.rb +1 -1
  86. data/lib/oxidized/model/vyatta.rb +1 -1
  87. data/lib/oxidized/model/xos.rb +1 -1
  88. data/lib/oxidized/model/zhoneolt.rb +1 -1
  89. data/lib/oxidized/node.rb +42 -46
  90. data/lib/oxidized/node/stats.rb +6 -6
  91. data/lib/oxidized/nodes.rb +42 -42
  92. data/lib/oxidized/output/file.rb +16 -20
  93. data/lib/oxidized/output/git.rb +68 -78
  94. data/lib/oxidized/output/gitcrypt.rb +77 -91
  95. data/lib/oxidized/output/http.rb +17 -19
  96. data/lib/oxidized/output/output.rb +1 -1
  97. data/lib/oxidized/source/csv.rb +3 -3
  98. data/lib/oxidized/source/http.rb +11 -14
  99. data/lib/oxidized/source/source.rb +3 -3
  100. data/lib/oxidized/source/sql.rb +16 -18
  101. data/lib/oxidized/string.rb +10 -10
  102. data/lib/oxidized/version.rb +4 -4
  103. data/lib/oxidized/worker.rb +15 -15
  104. data/oxidized.gemspec +6 -9
  105. metadata +32 -25
@@ -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 job
9
+ def add(job)
10
10
  stat = {
11
- :start => job.start,
12
- :end => job.end,
13
- :time => job.time,
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 status = nil
23
+ def get(status = nil)
24
24
  status ? @stats[status] : @stats
25
25
  end
26
26
 
27
- def get_counter counter = nil
27
+ def get_counter(counter = nil)
28
28
  counter ? @stats[:counter][counter] : @stats[:counter]
29
29
  end
30
30
 
@@ -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 :put :unshift
9
- def load node_want = nil
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) or raise(MethodNotFound, "cannot load node source '#{@source}', not found")
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
- _node = Node.new node
22
- new.push _node
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 == 0 ? replace(new) : update_nodes(new)
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? node_want, node
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 and node_want_ip == node[:name]
39
+ if name_is_ip && (node_want_ip == node[:name])
40
40
  true
41
- elsif node[:ip] and node_want_ip == 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 node
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 node_name, group
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 node, opt = {}
69
- if waiting.find_node_index(node)
70
- with_lock do
71
- n = del node
72
- n.user = opt['user']
73
- n.email = opt['email']
74
- n.msg = opt['msg']
75
- n.from = opt['from']
76
- # set last job to nil so that the node is picked for immediate update
77
- n.last = nil
78
- put n
79
- jobs.want += 1 if Oxidized.config.next_adds_job?
80
- end
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 :top :next
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 node
95
- find_index node or raise Oxidized::NodeNotFound, "unable to find '#{node}'"
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 node_name, group
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 node_name, group, oid
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 node_name, group, oid1, oid2
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 opts = {}
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 &block
129
+ def with_lock(&block)
130
130
  @mutex.synchronize(&block)
131
131
  end
132
132
 
133
- def find_index node
134
- index { |e| e.name == node or e.ip == node }
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 node
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 :nodes => select { |node| node.running? }
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 :nodes => select { |node| not node.running? }
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 nodes
159
- old = self.dup
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 }
@@ -9,49 +9,45 @@ module Oxidized
9
9
  end
10
10
 
11
11
  def setup
12
- if @cfg.empty?
13
- Oxidized.asetus.user.output.file.directory = File.join(Config::Root, 'configs')
14
- Oxidized.asetus.save :user
15
- raise NoConfig, 'no output file config, edit ~/.config/oxidized/config'
16
- end
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 node, outputs, opt = {}
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 node, group
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
- if File.exists? File.join(cfg_dir, node_name) # node configuration file is stored on base directory
39
- File.read File.join(cfg_dir, node_name)
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
- return nil
42
+ nil
47
43
  end
48
44
 
49
- def version node, group
45
+ def version(_node, _group)
50
46
  # not supported
51
47
  []
52
48
  end
53
49
 
54
- def get_version node, group, oid
50
+ def get_version(_node, _group, _oid)
55
51
  'not supported'
56
52
  end
57
53
  end
@@ -31,10 +31,10 @@ module Oxidized
31
31
  end
32
32
  end
33
33
 
34
- def store file, outputs, opt = {}
34
+ def store(file, outputs, opt = {})
35
35
  @msg = opt[:msg]
36
- @user = (opt[:user] or @cfg.user)
37
- @email = (opt[:email] or @cfg.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) if not output.name
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 node, group
61
- begin
62
- repo, path = yield_repo_and_path(node, group)
63
- repo = Rugged::Repository.new repo
64
- index = repo.index
65
- index.read_tree repo.head.target.tree unless repo.empty?
66
- repo.read(index.get(path)[:oid]).data
67
- rescue
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 node, group
74
- begin
75
- repo, path = yield_repo_and_path(node, group)
76
-
77
- repo = Rugged::Repository.new repo
78
- walker = Rugged::Walker.new(repo)
79
- walker.sorting(Rugged::SORT_DATE)
80
- walker.push(repo.head.target)
81
- i = -1
82
- tab = []
83
- walker.each do |commit|
84
- if commit.diff(paths: [path]).size > 0
85
- hash = {}
86
- hash[:date] = commit.time.to_s
87
- hash[:oid] = commit.oid
88
- hash[:author] = commit.author
89
- hash[:message] = commit.message
90
- tab[i += 1] = hash
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 node, group, oid
102
- begin
103
- repo, path = yield_repo_and_path(node, group)
104
- repo = Rugged::Repository.new repo
105
- repo.blob_at(oid, path).content
106
- rescue
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 node, group, oid1, oid2
113
- begin
114
- diff_commits = nil
115
- repo, _ = yield_repo_and_path(node, group)
116
- repo = Rugged::Repository.new repo
117
- commit = repo.lookup(oid1)
118
-
119
- if oid2
120
- commit_old = repo.lookup(oid2)
121
- diff = repo.diff(commit_old, commit)
122
- diff.each do |patch|
123
- if /#{node.name}\s+/.match(patch.to_s.lines.first)
124
- diff_commits = { :patch => patch.to_s, :stat => patch.stat }
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
- diff_commits
136
- rescue
137
- 'no diffs'
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 and @cfg.single_repo?
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 repo, file, data
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 repo, file, data
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 and oid_old.content == data
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: 0100644
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