between_meals 0.0.11 → 0.0.13
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 +4 -4
- data/README.md +1 -3
- data/lib/between_meals/changes/change.rb +16 -3
- data/lib/between_meals/changes/cookbook.rb +4 -6
- data/lib/between_meals/changes/databag.rb +3 -4
- data/lib/between_meals/changes/role.rb +2 -4
- data/lib/between_meals/changeset.rb +2 -3
- data/lib/between_meals/cmd.rb +3 -4
- data/lib/between_meals/knife.rb +8 -8
- data/lib/between_meals/repo/git/cmd.rb +7 -5
- data/lib/between_meals/repo/git.rb +10 -6
- data/lib/between_meals/repo/hg/cmd.rb +2 -4
- data/lib/between_meals/repo/hg.rb +1 -3
- data/lib/between_meals/repo/svn/cmd.rb +2 -4
- data/lib/between_meals/repo/svn.rb +3 -5
- data/lib/between_meals/repo.rb +23 -21
- data/lib/between_meals/util.rb +24 -26
- metadata +9 -94
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 514d9473b739b4589c6692a739cb10e7fbfa8d2d87fa86e975579d7e2756bc9c
|
|
4
|
+
data.tar.gz: f4984b471c7856b51f60f1fadf7b4b21f684482f2f123d9babab02445c87d102
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a889b6ae00ddb079948b0e6a04cb2e2888ccff57e7fdf685facecc11baee5f0d7cd4bc8b4c730f4fdfdde924d0c358b5e06b06fb0ec5ad30d7edd793e16288f6
|
|
7
|
+
data.tar.gz: cbf64fb976eb7ed143b8024c7048595feec9967f65b37fb62c0b7195ee35db1a7a35f2c33715a36f5abbe88be0694fcee1edc64d4b3f98bccfe01410cd6a012a
|
data/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# Between Meals
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://circleci.com/gh/facebook/between-meals)
|
|
3
|
+

|
|
5
4
|
|
|
6
5
|
## Intro
|
|
7
6
|
Ohai!
|
|
@@ -19,7 +18,6 @@ functions.
|
|
|
19
18
|
## Dependencies
|
|
20
19
|
|
|
21
20
|
* Colorize
|
|
22
|
-
* JSON
|
|
23
21
|
* Mixlib::ShellOut
|
|
24
22
|
* Rugged
|
|
25
23
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -24,12 +22,27 @@ module BetweenMeals
|
|
|
24
22
|
module Changes
|
|
25
23
|
# Common functionality
|
|
26
24
|
class Change
|
|
25
|
+
# Since we either need to upload or delete, we only accept two statuses.
|
|
26
|
+
# VCSs will differentiate between various kinds of modifies, adds, etc.
|
|
27
|
+
# so instead of handling all possibilities here, we expect the caller to
|
|
28
|
+
# collapse them into `:modified` or `:deleted`.
|
|
29
|
+
ALLOWED_STATUSES = [:modified, :deleted].freeze #: Array[Symbol]
|
|
27
30
|
@@logger = nil
|
|
28
|
-
attr_accessor :name
|
|
31
|
+
attr_accessor :name
|
|
32
|
+
attr_reader :status
|
|
33
|
+
|
|
34
|
+
#: () -> String
|
|
29
35
|
def to_s
|
|
30
36
|
@name
|
|
31
37
|
end
|
|
32
38
|
|
|
39
|
+
def status=(value)
|
|
40
|
+
unless ALLOWED_STATUSES.include?(value)
|
|
41
|
+
fail "#{self.class} status attribute can only be one of #{ALLOWED_STATUSES} not #{value}"
|
|
42
|
+
end
|
|
43
|
+
@status = value
|
|
44
|
+
end
|
|
45
|
+
|
|
33
46
|
# People who use us through find() can just pass in logger,
|
|
34
47
|
# for everyone else, here's a setter
|
|
35
48
|
def logger=(log)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -42,7 +40,7 @@ module BetweenMeals
|
|
|
42
40
|
# For each symlink get the source path, if any files have changed under
|
|
43
41
|
# the source path, fake them as coming from the symlink path. This
|
|
44
42
|
# allows the normal cookbook logic to just work.
|
|
45
|
-
symlinks = {}
|
|
43
|
+
symlinks = {} #: Hash[String, Hash[String, String]]
|
|
46
44
|
@cookbook_dirs.each do |dir|
|
|
47
45
|
dir = File.join(@repo_dir, dir)
|
|
48
46
|
# Find symlinks in each cookbook_dir
|
|
@@ -66,7 +64,7 @@ module BetweenMeals
|
|
|
66
64
|
# Create the file hash expected for each file that is a link or coming
|
|
67
65
|
# from a linked directory but fake the source path as a symlink path.
|
|
68
66
|
# Hacky but works :)
|
|
69
|
-
links_to_append = []
|
|
67
|
+
links_to_append = [] #: Array[untyped]
|
|
70
68
|
symlinks.each_value do |lrp| # link_abs_path, link_relative_path
|
|
71
69
|
files.each do |f|
|
|
72
70
|
# a symlink will never have trailing '/', add one.
|
|
@@ -119,9 +117,9 @@ module BetweenMeals
|
|
|
119
117
|
%{^(#{cookbook_dirs.join('|')})/[^/]+/metadata\.(rb|json)$},
|
|
120
118
|
)
|
|
121
119
|
end.none?
|
|
122
|
-
|
|
120
|
+
self.status = :deleted
|
|
123
121
|
else
|
|
124
|
-
|
|
122
|
+
self.status = :modified
|
|
125
123
|
end
|
|
126
124
|
end
|
|
127
125
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -19,6 +17,7 @@ module BetweenMeals
|
|
|
19
17
|
# Changeset aware databag
|
|
20
18
|
class Databag < Change
|
|
21
19
|
attr_accessor :item
|
|
20
|
+
|
|
22
21
|
def self.name_from_path(path, databag_dir)
|
|
23
22
|
re = %r{^#{databag_dir}/([^/]+)/([^/]+)\.json}
|
|
24
23
|
debug("[databag] Matching #{path} against #{re}")
|
|
@@ -31,8 +30,8 @@ module BetweenMeals
|
|
|
31
30
|
end
|
|
32
31
|
|
|
33
32
|
def initialize(file, databag_dir)
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
self.status = file[:status] == :deleted ? :deleted : :modified
|
|
34
|
+
self.name, self.item = self.class.name_from_path(file[:path], databag_dir)
|
|
36
35
|
end
|
|
37
36
|
|
|
38
37
|
def self.find(list, databag_dir, logger)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -30,8 +28,8 @@ module BetweenMeals
|
|
|
30
28
|
end
|
|
31
29
|
|
|
32
30
|
def initialize(file, role_dir)
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
self.status = file[:status] == :deleted ? :deleted : :modified
|
|
32
|
+
self.name = self.class.name_from_path(file[:path], role_dir)
|
|
35
33
|
end
|
|
36
34
|
|
|
37
35
|
# Given a list of changed files
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -29,6 +27,7 @@ module BetweenMeals
|
|
|
29
27
|
class Changeset
|
|
30
28
|
class ReferenceError < RuntimeError
|
|
31
29
|
end
|
|
30
|
+
|
|
32
31
|
# rubocop:disable Metrics/ParameterLists
|
|
33
32
|
def initialize(
|
|
34
33
|
logger, repo, start_ref, end_ref, locations, track_symlinks = false
|
|
@@ -43,7 +42,7 @@ module BetweenMeals
|
|
|
43
42
|
# Figure out which files changed if refs provided
|
|
44
43
|
# or return all files (full upload) otherwise
|
|
45
44
|
if start_ref
|
|
46
|
-
@files = []
|
|
45
|
+
@files = [] #: Array[untyped]
|
|
47
46
|
@repo.changes(start_ref, end_ref).each do |file|
|
|
48
47
|
@files << file
|
|
49
48
|
end
|
data/lib/between_meals/cmd.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -26,7 +24,7 @@ module BetweenMeals
|
|
|
26
24
|
@logger = params[:logger] || Logger.new(STDOUT)
|
|
27
25
|
end
|
|
28
26
|
|
|
29
|
-
def cmd(params, cwd = nil)
|
|
27
|
+
def cmd(params, cwd = nil, nofail = false)
|
|
30
28
|
cwd ||= File.expand_path(@cwd)
|
|
31
29
|
cmd = "#{@bin} #{params}"
|
|
32
30
|
@logger.info("Running \"#{cmd}\"")
|
|
@@ -40,7 +38,8 @@ module BetweenMeals
|
|
|
40
38
|
},
|
|
41
39
|
)
|
|
42
40
|
c.run_command
|
|
43
|
-
|
|
41
|
+
# If the user asked us not to fail, let them handle error reporting
|
|
42
|
+
if c.error? && !nofail
|
|
44
43
|
# Let's make sure the error goes to the logs
|
|
45
44
|
@logger.error("#{@bin} failed: #{c.format_for_exception}")
|
|
46
45
|
# if our logger is STDOUT, we'll double log when we throw
|
data/lib/between_meals/knife.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -61,7 +59,7 @@ module BetweenMeals
|
|
|
61
59
|
end
|
|
62
60
|
|
|
63
61
|
def role_upload_all
|
|
64
|
-
if File.
|
|
62
|
+
if File.exist?(@role_dir)
|
|
65
63
|
roles = File.join(@role_dir, "*.#{@role_type}")
|
|
66
64
|
exec!("#{@knife} role from file #{roles} #{@knife_verb_option} " +
|
|
67
65
|
"-c #{@config}", @logger)
|
|
@@ -123,7 +121,7 @@ module BetweenMeals
|
|
|
123
121
|
if cookbooks.any?
|
|
124
122
|
@cookbook_dirs.each do |path|
|
|
125
123
|
cookbooks.each do |cb|
|
|
126
|
-
next unless File.
|
|
124
|
+
next unless File.exist?("#{path}/#{cb}")
|
|
127
125
|
|
|
128
126
|
@logger.warn("Running berkshelf on cookbook: #{cb}")
|
|
129
127
|
exec!("cd #{path}/#{cb} && #{@berks} install #{berks_config} && " +
|
|
@@ -205,7 +203,7 @@ BLOCK
|
|
|
205
203
|
# not an error if it's already there.
|
|
206
204
|
nil
|
|
207
205
|
end
|
|
208
|
-
if !File.
|
|
206
|
+
if !File.exist?(@config) ||
|
|
209
207
|
::Digest::MD5.hexdigest(cfg) !=
|
|
210
208
|
::Digest::MD5.hexdigest(File.read(@config))
|
|
211
209
|
@logger.info("Generating #{@config}")
|
|
@@ -251,7 +249,7 @@ IAMAEpsWX2s2A6phgMCx7kH6wMmoZn3hb7Thh9+PfR8Jtp2/7k+ibCeF4gEWUCs5
|
|
|
251
249
|
nil
|
|
252
250
|
end
|
|
253
251
|
|
|
254
|
-
unless File.
|
|
252
|
+
unless File.exist?(@pem)
|
|
255
253
|
@logger.info("Generating #{@pem}")
|
|
256
254
|
File.write(@pem, pem)
|
|
257
255
|
end
|
|
@@ -261,8 +259,10 @@ IAMAEpsWX2s2A6phgMCx7kH6wMmoZn3hb7Thh9+PfR8Jtp2/7k+ibCeF4gEWUCs5
|
|
|
261
259
|
|
|
262
260
|
def create_databag_if_missing(databag)
|
|
263
261
|
s = Mixlib::ShellOut.new("#{@knife} data bag list" +
|
|
264
|
-
|
|
262
|
+
' --format json ' +
|
|
265
263
|
"-c #{@config}").run_command
|
|
264
|
+
|
|
265
|
+
s.stdout.gsub!(/^[A-Z].*\n/, '')
|
|
266
266
|
s.error!
|
|
267
267
|
db = JSON.parse(s.stdout)
|
|
268
268
|
unless db.include?(databag)
|
|
@@ -272,7 +272,7 @@ IAMAEpsWX2s2A6phgMCx7kH6wMmoZn3hb7Thh9+PfR8Jtp2/7k+ibCeF4gEWUCs5
|
|
|
272
272
|
end
|
|
273
273
|
|
|
274
274
|
def delete_databag_if_empty(databag)
|
|
275
|
-
s = Mixlib::ShellOut.new("#{@knife} data bag show #{databag}" +
|
|
275
|
+
s = Mixlib::ShellOut.new("#{@knife} data bag show #{databag}" + # steep:ignore
|
|
276
276
|
" --format json #{@knife_verb_option} " +
|
|
277
277
|
"-c #{@config}").run_command
|
|
278
278
|
s.error!
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -18,10 +16,14 @@ require 'between_meals/cmd'
|
|
|
18
16
|
|
|
19
17
|
module BetweenMeals
|
|
20
18
|
class Repo
|
|
21
|
-
class Git < BetweenMeals::Repo
|
|
22
|
-
class Cmd < BetweenMeals::Cmd
|
|
19
|
+
class Git < ::BetweenMeals::Repo
|
|
20
|
+
class Cmd < ::BetweenMeals::Cmd
|
|
23
21
|
def config(key)
|
|
24
|
-
cmd("config #{key}")
|
|
22
|
+
s = cmd("config #{key}", nil, true)
|
|
23
|
+
unless [0, 1].include?(s.exitstatus)
|
|
24
|
+
s.error!
|
|
25
|
+
end
|
|
26
|
+
s
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
def clone(url, repo_path)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -26,9 +24,9 @@ module BetweenMeals
|
|
|
26
24
|
class Repo
|
|
27
25
|
class Git < BetweenMeals::Repo
|
|
28
26
|
def setup
|
|
29
|
-
if File.
|
|
27
|
+
if File.exist?(File.expand_path(@repo_path))
|
|
30
28
|
begin
|
|
31
|
-
@repo = Rugged::Repository.new(File.expand_path(@repo_path))
|
|
29
|
+
@repo = Rugged::Repository.new(File.expand_path(@repo_path)) # steep:ignore
|
|
32
30
|
rescue StandardError
|
|
33
31
|
@repo = nil
|
|
34
32
|
end
|
|
@@ -43,6 +41,12 @@ module BetweenMeals
|
|
|
43
41
|
)
|
|
44
42
|
end
|
|
45
43
|
|
|
44
|
+
# Allow people to get access to the underlying Rugged
|
|
45
|
+
# object for their hooks
|
|
46
|
+
def repo_object
|
|
47
|
+
@repo
|
|
48
|
+
end
|
|
49
|
+
|
|
46
50
|
def exists?
|
|
47
51
|
!@repo.nil?
|
|
48
52
|
end
|
|
@@ -76,7 +80,7 @@ module BetweenMeals
|
|
|
76
80
|
|
|
77
81
|
def checkout(url)
|
|
78
82
|
@cmd.clone(url, @repo_path)
|
|
79
|
-
@repo = Rugged::Repository.new(File.expand_path(@repo_path))
|
|
83
|
+
@repo = Rugged::Repository.new(File.expand_path(@repo_path)) # steep:ignore
|
|
80
84
|
end
|
|
81
85
|
|
|
82
86
|
# Return files changed between two revisions
|
|
@@ -108,7 +112,7 @@ module BetweenMeals
|
|
|
108
112
|
@repo.index.map { |x| { :path => x[:path], :status => :created } }
|
|
109
113
|
end
|
|
110
114
|
|
|
111
|
-
def upstream?(rev, master = '
|
|
115
|
+
def upstream?(rev, master = 'upstream/master')
|
|
112
116
|
if @cmd.merge_base(rev, master).stdout.strip == rev
|
|
113
117
|
return true
|
|
114
118
|
end
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -19,8 +17,8 @@ require 'tempfile'
|
|
|
19
17
|
|
|
20
18
|
module BetweenMeals
|
|
21
19
|
class Repo
|
|
22
|
-
class Hg < BetweenMeals::Repo
|
|
23
|
-
class Cmd < BetweenMeals::Cmd
|
|
20
|
+
class Hg < ::BetweenMeals::Repo
|
|
21
|
+
class Cmd < ::BetweenMeals::Cmd
|
|
24
22
|
def rev(rev)
|
|
25
23
|
cmd("log -r #{rev}")
|
|
26
24
|
end
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -32,7 +30,7 @@ module BetweenMeals
|
|
|
32
30
|
end
|
|
33
31
|
|
|
34
32
|
def exists?
|
|
35
|
-
Dir.
|
|
33
|
+
Dir.exist?(Pathname.new(@repo_path).join('.hg'))
|
|
36
34
|
end
|
|
37
35
|
|
|
38
36
|
def head_rev
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -17,8 +15,8 @@
|
|
|
17
15
|
require 'between_meals/cmd'
|
|
18
16
|
module BetweenMeals
|
|
19
17
|
class Repo
|
|
20
|
-
class Svn < BetweenMeals::Repo
|
|
21
|
-
class Cmd < BetweenMeals::Cmd
|
|
18
|
+
class Svn < ::BetweenMeals::Repo
|
|
19
|
+
class Cmd < ::BetweenMeals::Cmd
|
|
22
20
|
def diff(start_ref, end_ref, repo_path)
|
|
23
21
|
cmd("diff -r #{start_ref}:#{end_ref} --summarize #{repo_path}")
|
|
24
22
|
end
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -33,7 +31,7 @@ module BetweenMeals
|
|
|
33
31
|
end
|
|
34
32
|
|
|
35
33
|
def exists?
|
|
36
|
-
Dir.
|
|
34
|
+
Dir.exist?(Pathname.new(@repo_path).join('.svn'))
|
|
37
35
|
end
|
|
38
36
|
|
|
39
37
|
def head_rev
|
|
@@ -69,7 +67,7 @@ module BetweenMeals
|
|
|
69
67
|
'Something went wrong. Please report this output.',
|
|
70
68
|
)
|
|
71
69
|
@logger.error(e)
|
|
72
|
-
|
|
70
|
+
changes.lines.each do |line|
|
|
73
71
|
@logger.error(line.strip)
|
|
74
72
|
end
|
|
75
73
|
exit(1)
|
|
@@ -105,7 +103,7 @@ module BetweenMeals
|
|
|
105
103
|
when /^([\w ])\w?\s+(.+)$/
|
|
106
104
|
{
|
|
107
105
|
:status => Regexp.last_match(1) == 'D' ? :deleted : :modified,
|
|
108
|
-
:path => Regexp.last_match(2).sub("#{@repo_path}/", ''),
|
|
106
|
+
:path => Regexp.last_match(2).to_s.sub("#{@repo_path}/", ''),
|
|
109
107
|
}
|
|
110
108
|
else
|
|
111
109
|
fail 'Failed to parse repo diff line.'
|
data/lib/between_meals/repo.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -40,35 +38,33 @@ module BetweenMeals
|
|
|
40
38
|
exit(1)
|
|
41
39
|
end
|
|
42
40
|
logger.info('Trying to detect repo type')
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
BetweenMeals::Repo
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
logger.info("Repo found to be #{klass.to_s.split('::').last}")
|
|
55
|
-
return r
|
|
56
|
-
end
|
|
57
|
-
rescue StandardError
|
|
58
|
-
logger.debug("Skipping #{klass}")
|
|
41
|
+
{
|
|
42
|
+
'Hg' => 'between_meals/repo/hg',
|
|
43
|
+
'Svn' => 'between_meals/repo/svn',
|
|
44
|
+
'Git' => 'between_meals/repo/git',
|
|
45
|
+
}.each do |klass_name, req|
|
|
46
|
+
require req
|
|
47
|
+
klass = BetweenMeals::Repo.const_get(klass_name)
|
|
48
|
+
r = klass.new(repo_path, logger)
|
|
49
|
+
if r.exists?
|
|
50
|
+
logger.info("Repo found to be #{klass.to_s.split('::').last}")
|
|
51
|
+
return r
|
|
59
52
|
end
|
|
53
|
+
rescue StandardError
|
|
54
|
+
logger.debug("Skipping #{klass}")
|
|
55
|
+
|
|
60
56
|
end
|
|
61
57
|
logger.warn("Failed detecting repo type at #{repo_path}")
|
|
62
58
|
exit(1)
|
|
59
|
+
when 'hg'
|
|
60
|
+
require 'between_meals/repo/hg'
|
|
61
|
+
BetweenMeals::Repo::Hg.new(repo_path, logger)
|
|
63
62
|
when 'svn'
|
|
64
63
|
require 'between_meals/repo/svn'
|
|
65
64
|
BetweenMeals::Repo::Svn.new(repo_path, logger)
|
|
66
65
|
when 'git'
|
|
67
66
|
require 'between_meals/repo/git'
|
|
68
67
|
BetweenMeals::Repo::Git.new(repo_path, logger)
|
|
69
|
-
when 'hg'
|
|
70
|
-
require 'between_meals/repo/hg'
|
|
71
|
-
BetweenMeals::Repo::Hg.new(repo_path, logger)
|
|
72
68
|
else
|
|
73
69
|
fail "Do not know repo type #{type}"
|
|
74
70
|
end
|
|
@@ -87,6 +83,12 @@ module BetweenMeals
|
|
|
87
83
|
fail "#{__method__} not implemented"
|
|
88
84
|
end
|
|
89
85
|
|
|
86
|
+
# Only interesting in the case of git where we have an underlying
|
|
87
|
+
# repo object courtesy of Rugged.
|
|
88
|
+
def repo_object
|
|
89
|
+
fail "#{__method__} not implemented"
|
|
90
|
+
end
|
|
91
|
+
|
|
90
92
|
# This method *must* succeed in the case of no repo directory so that
|
|
91
93
|
# users can call `checkout`. Users may call `exists?` to find out if
|
|
92
94
|
# we have an underlying repo yet.
|
data/lib/between_meals/util.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
|
2
|
-
|
|
3
1
|
# Copyright 2013-present Facebook
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -34,7 +32,7 @@ module BetweenMeals
|
|
|
34
32
|
def time(logger = nil)
|
|
35
33
|
@@logger = logger if logger
|
|
36
34
|
t0 = Time.now
|
|
37
|
-
yield
|
|
35
|
+
yield # steep:ignore
|
|
38
36
|
info("Executed in #{format('%.2f', Time.now - t0)}s")
|
|
39
37
|
end
|
|
40
38
|
|
|
@@ -60,7 +58,7 @@ module BetweenMeals
|
|
|
60
58
|
|
|
61
59
|
def execute(command, stream)
|
|
62
60
|
info("Running: #{command}")
|
|
63
|
-
c = Mixlib::ShellOut.new(command, :live_stream => stream)
|
|
61
|
+
c = Mixlib::ShellOut.new(command, :live_stream => stream) # steep:ignore
|
|
64
62
|
c.run_command
|
|
65
63
|
c.stdout.lines.each do |line|
|
|
66
64
|
info("STDOUT: #{line.strip}")
|
|
@@ -73,38 +71,38 @@ module BetweenMeals
|
|
|
73
71
|
|
|
74
72
|
def port_open?(port)
|
|
75
73
|
ips = Socket.ip_address_list
|
|
76
|
-
ips.map
|
|
74
|
+
ips = ips.map { |i| i.ip_address.to_s }
|
|
77
75
|
ips.each do |ip|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
next
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
rescue Timeout::Error
|
|
76
|
+
|
|
77
|
+
Timeout.timeout(1) do
|
|
78
|
+
|
|
79
|
+
s = TCPSocket.new(ip, port)
|
|
80
|
+
s.close
|
|
81
|
+
return true
|
|
82
|
+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
|
|
89
83
|
next
|
|
84
|
+
|
|
90
85
|
end
|
|
86
|
+
rescue Timeout::Error
|
|
87
|
+
next
|
|
88
|
+
|
|
91
89
|
end
|
|
92
90
|
return false
|
|
93
91
|
end
|
|
94
92
|
|
|
95
93
|
def chef_zero_running?(port, use_ssl)
|
|
96
94
|
Timeout.timeout(1) do
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
end
|
|
103
|
-
res = http.get('/')
|
|
104
|
-
return res['Server'] == 'chef-zero'
|
|
105
|
-
rescue StandardError
|
|
106
|
-
return false
|
|
95
|
+
|
|
96
|
+
http = Net::HTTP.new('localhost', port)
|
|
97
|
+
if use_ssl
|
|
98
|
+
http.use_ssl = true
|
|
99
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
107
100
|
end
|
|
101
|
+
res = http.get('/')
|
|
102
|
+
return res['Server'] == 'chef-zero'
|
|
103
|
+
rescue StandardError
|
|
104
|
+
return false
|
|
105
|
+
|
|
108
106
|
end
|
|
109
107
|
rescue Timeout::Error
|
|
110
108
|
return false
|
metadata
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: between_meals
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.13
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Phil Dibowitz
|
|
8
8
|
- Marcin Sawicki
|
|
9
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2026-02-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: colorize
|
|
@@ -39,92 +39,8 @@ dependencies:
|
|
|
39
39
|
- - ">="
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
41
|
version: '0'
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
|
45
|
-
requirements:
|
|
46
|
-
- - ">="
|
|
47
|
-
- !ruby/object:Gem::Version
|
|
48
|
-
version: '0'
|
|
49
|
-
type: :runtime
|
|
50
|
-
prerelease: false
|
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
-
requirements:
|
|
53
|
-
- - ">="
|
|
54
|
-
- !ruby/object:Gem::Version
|
|
55
|
-
version: '0'
|
|
56
|
-
- !ruby/object:Gem::Dependency
|
|
57
|
-
name: rspec-core
|
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
|
59
|
-
requirements:
|
|
60
|
-
- - ">="
|
|
61
|
-
- !ruby/object:Gem::Version
|
|
62
|
-
version: '0'
|
|
63
|
-
type: :development
|
|
64
|
-
prerelease: false
|
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
-
requirements:
|
|
67
|
-
- - ">="
|
|
68
|
-
- !ruby/object:Gem::Version
|
|
69
|
-
version: '0'
|
|
70
|
-
- !ruby/object:Gem::Dependency
|
|
71
|
-
name: rspec-expectations
|
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
|
73
|
-
requirements:
|
|
74
|
-
- - ">="
|
|
75
|
-
- !ruby/object:Gem::Version
|
|
76
|
-
version: '0'
|
|
77
|
-
type: :development
|
|
78
|
-
prerelease: false
|
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
-
requirements:
|
|
81
|
-
- - ">="
|
|
82
|
-
- !ruby/object:Gem::Version
|
|
83
|
-
version: '0'
|
|
84
|
-
- !ruby/object:Gem::Dependency
|
|
85
|
-
name: rspec-mocks
|
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
|
87
|
-
requirements:
|
|
88
|
-
- - ">="
|
|
89
|
-
- !ruby/object:Gem::Version
|
|
90
|
-
version: '0'
|
|
91
|
-
type: :development
|
|
92
|
-
prerelease: false
|
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
94
|
-
requirements:
|
|
95
|
-
- - ">="
|
|
96
|
-
- !ruby/object:Gem::Version
|
|
97
|
-
version: '0'
|
|
98
|
-
- !ruby/object:Gem::Dependency
|
|
99
|
-
name: simplecov
|
|
100
|
-
requirement: !ruby/object:Gem::Requirement
|
|
101
|
-
requirements:
|
|
102
|
-
- - ">="
|
|
103
|
-
- !ruby/object:Gem::Version
|
|
104
|
-
version: '0'
|
|
105
|
-
type: :development
|
|
106
|
-
prerelease: false
|
|
107
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
108
|
-
requirements:
|
|
109
|
-
- - ">="
|
|
110
|
-
- !ruby/object:Gem::Version
|
|
111
|
-
version: '0'
|
|
112
|
-
- !ruby/object:Gem::Dependency
|
|
113
|
-
name: rubocop
|
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
|
115
|
-
requirements:
|
|
116
|
-
- - '='
|
|
117
|
-
- !ruby/object:Gem::Version
|
|
118
|
-
version: 0.49.1
|
|
119
|
-
type: :development
|
|
120
|
-
prerelease: false
|
|
121
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
122
|
-
requirements:
|
|
123
|
-
- - '='
|
|
124
|
-
- !ruby/object:Gem::Version
|
|
125
|
-
version: 0.49.1
|
|
126
|
-
description: Library for calculation Chef differences between revisions
|
|
127
|
-
email:
|
|
42
|
+
description: Library for calculating Chef differences between revisions
|
|
43
|
+
email:
|
|
128
44
|
executables: []
|
|
129
45
|
extensions: []
|
|
130
46
|
extra_rdoc_files:
|
|
@@ -152,7 +68,7 @@ homepage: https://github.com/facebook/between-meals
|
|
|
152
68
|
licenses:
|
|
153
69
|
- Apache-2.0
|
|
154
70
|
metadata: {}
|
|
155
|
-
post_install_message:
|
|
71
|
+
post_install_message:
|
|
156
72
|
rdoc_options: []
|
|
157
73
|
require_paths:
|
|
158
74
|
- lib
|
|
@@ -160,16 +76,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
160
76
|
requirements:
|
|
161
77
|
- - ">="
|
|
162
78
|
- !ruby/object:Gem::Version
|
|
163
|
-
version:
|
|
79
|
+
version: 2.7.0
|
|
164
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
81
|
requirements:
|
|
166
82
|
- - ">="
|
|
167
83
|
- !ruby/object:Gem::Version
|
|
168
84
|
version: '0'
|
|
169
85
|
requirements: []
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
signing_key:
|
|
86
|
+
rubygems_version: 3.5.22
|
|
87
|
+
signing_key:
|
|
173
88
|
specification_version: 4
|
|
174
89
|
summary: Between Meals
|
|
175
90
|
test_files: []
|