between_meals 0.0.5 → 0.0.6
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.
- data/README.md +2 -2
- data/lib/between_meals/changes/change.rb +3 -3
- data/lib/between_meals/changes/cookbook.rb +8 -8
- data/lib/between_meals/changes/databag.rb +3 -3
- data/lib/between_meals/changes/role.rb +4 -4
- data/lib/between_meals/changeset.rb +3 -3
- data/lib/between_meals/cmd.rb +44 -0
- data/lib/between_meals/knife.rb +52 -13
- data/lib/between_meals/repo.rb +74 -30
- data/lib/between_meals/repo/git.rb +49 -49
- data/lib/between_meals/repo/git/cmd.rb +49 -0
- data/lib/between_meals/repo/hg.rb +214 -0
- data/lib/between_meals/repo/hg/cmd.rb +72 -0
- data/lib/between_meals/repo/svn.rb +51 -68
- data/lib/between_meals/repo/svn/cmd.rb +56 -0
- data/lib/between_meals/util.rb +3 -3
- metadata +41 -8
@@ -1,134 +1,117 @@
|
|
1
1
|
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
2
2
|
|
3
3
|
# Copyright 2013-present Facebook
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
7
7
|
# You may obtain a copy of the License at
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# Unless required by applicable law or agreed to in writing, software
|
12
12
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
+
require 'pathname'
|
17
18
|
require 'between_meals/repo'
|
18
19
|
require 'between_meals/changeset'
|
19
20
|
require 'mixlib/shellout'
|
21
|
+
require 'between_meals/repo/svn/cmd'
|
20
22
|
|
21
23
|
module BetweenMeals
|
22
|
-
# Local checkout wrapper
|
23
24
|
class Repo
|
24
|
-
# SVN implementation
|
25
25
|
class Svn < BetweenMeals::Repo
|
26
26
|
def setup
|
27
27
|
@bin = 'svn'
|
28
|
+
@cmd = BetweenMeals::Repo::Svn::Cmd.new(
|
29
|
+
:bin => @bin,
|
30
|
+
:cwd => '/tmp',
|
31
|
+
:logger => @logger,
|
32
|
+
)
|
28
33
|
end
|
29
34
|
|
30
35
|
def exists?
|
31
|
-
|
32
|
-
Dir.exists?(@repo_path)
|
36
|
+
Dir.exists?(Pathname.new(@repo_path).join('.svn'))
|
33
37
|
end
|
34
38
|
|
35
39
|
def head_rev
|
36
|
-
|
37
|
-
s.error!
|
38
|
-
s.stdout.each_line do |line|
|
40
|
+
@cmd.info(@repo_path).stdout.each_line do |line|
|
39
41
|
m = line.match(/Last Changed Rev: (\d+)$/)
|
40
42
|
return m[1] if m
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
46
|
def latest_revision
|
45
|
-
|
46
|
-
s.error!
|
47
|
-
s.stdout.each do |line|
|
47
|
+
@cmd.info(@repo_path).stdout.each_line do |line|
|
48
48
|
m = line.match(/Revision: (\d+)$/)
|
49
49
|
return m[1] if m
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
def checkout(url)
|
54
|
-
|
55
|
-
"#{@bin} co --ignore-externals #{url} #{@repo_path}").run_command
|
56
|
-
s.error!
|
54
|
+
@cmd.co(url, @repo_path)
|
57
55
|
end
|
58
56
|
|
59
57
|
# Return files changed between two revisions
|
60
58
|
def changes(start_ref, end_ref)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
s.run_command.error!
|
59
|
+
valid_ref?(start_ref)
|
60
|
+
valid_ref?(end_ref) if end_ref
|
61
|
+
|
65
62
|
@logger.info("Diff between #{start_ref} and #{end_ref}")
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
63
|
+
changes = @cmd.diff(start_ref, end_ref, @repo_path).stdout
|
64
|
+
|
65
|
+
begin
|
66
|
+
parse_status(changes).compact
|
67
|
+
rescue => e
|
68
|
+
@logger.error(
|
69
|
+
'Something went wrong. Please please report this output.'
|
70
|
+
)
|
71
|
+
@logger.error(e)
|
72
|
+
stdout.lines.each do |line|
|
73
|
+
@logger.error(line.strip)
|
74
|
+
end
|
75
|
+
exit(1)
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
77
79
|
def update
|
78
|
-
cleanup
|
79
|
-
revert
|
80
|
-
|
80
|
+
@cmd.cleanup(@repo_path)
|
81
|
+
@cmd.revert(@repo_path)
|
82
|
+
@cmd.update(@repo_path)
|
81
83
|
end
|
82
84
|
|
83
|
-
# Return all files
|
84
85
|
def files
|
85
|
-
|
86
|
-
s.run_command
|
87
|
-
s.error!
|
88
|
-
s.stdout.split("\n").map do |x|
|
86
|
+
@cmd.ls.stdout.split("\n").map do |x|
|
89
87
|
{ :path => x, :status => :created }
|
90
88
|
end
|
91
89
|
end
|
92
90
|
|
93
|
-
|
94
|
-
|
95
|
-
def run(cmd)
|
96
|
-
Mixlib::ShellOut.new(cmd).run_command.error!
|
97
|
-
end
|
98
|
-
|
99
|
-
def revert
|
100
|
-
run("#{@bin} revert -R #{@repo_path}")
|
101
|
-
end
|
102
|
-
|
103
|
-
def up
|
104
|
-
run("#{@bin} update #{@repo_path}")
|
91
|
+
def upstream?
|
105
92
|
end
|
106
93
|
|
107
|
-
def
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
def first_revision
|
112
|
-
0
|
94
|
+
def valid_ref?(ref)
|
95
|
+
@cmd.info_r(ref, @repo_path)
|
96
|
+
rescue
|
97
|
+
raise Changeset::ReferenceError
|
113
98
|
end
|
114
99
|
|
115
100
|
private
|
116
101
|
|
117
|
-
def
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
102
|
+
def parse_status(changes)
|
103
|
+
# http://svnbook.red-bean.com/en/1.0/re26.html
|
104
|
+
changes.lines.map do |line|
|
105
|
+
case line
|
106
|
+
when (/^([\w ])\w?\s+(\S+)$/)
|
107
|
+
{
|
108
|
+
:status => Regexp.last_match(1) == 'D' ? :deleted : :modified,
|
109
|
+
:path => Regexp.last_match(2).sub("#{@repo_path}/", ''),
|
110
|
+
}
|
111
|
+
else
|
112
|
+
fail 'No match'
|
113
|
+
end
|
129
114
|
end
|
130
|
-
rescue
|
131
|
-
raise Changeset::ReferenceError
|
132
115
|
end
|
133
116
|
end
|
134
117
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
2
|
+
|
3
|
+
# Copyright 2013-present Facebook
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'between_meals/cmd'
|
18
|
+
module BetweenMeals
|
19
|
+
class Repo
|
20
|
+
class Svn < BetweenMeals::Repo
|
21
|
+
class Cmd < BetweenMeals::Cmd
|
22
|
+
def diff(start_ref, end_ref, repo_path)
|
23
|
+
cmd("diff -r #{start_ref}:#{end_ref} --summarize #{repo_path}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def info(repo_path)
|
27
|
+
cmd("info #{repo_path}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def info_r(ref, repo_path)
|
31
|
+
cmd("info -r #{ref} #{repo_path}")
|
32
|
+
end
|
33
|
+
|
34
|
+
def co(url, repo_path)
|
35
|
+
cmd("co --ignore-externals #{url} #{repo_path}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def revert(repo_path)
|
39
|
+
cmd("revert -R #{repo_path}")
|
40
|
+
end
|
41
|
+
|
42
|
+
def update(repo_path)
|
43
|
+
cmd("update #{repo_path}")
|
44
|
+
end
|
45
|
+
|
46
|
+
def cleanup(repo_path)
|
47
|
+
cmd("cleanup #{repo_path}")
|
48
|
+
end
|
49
|
+
|
50
|
+
def ls(repo_path)
|
51
|
+
cmd("ls --depth infinity #{repo_path}")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/between_meals/util.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
|
2
2
|
|
3
3
|
# Copyright 2013-present Facebook
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
7
7
|
# You may obtain a copy of the License at
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# Unless required by applicable law or agreed to in writing, software
|
12
12
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: between_meals
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Phil Dibowitz
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2015-
|
19
|
+
date: 2015-11-26 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: colorize
|
@@ -116,6 +116,34 @@ dependencies:
|
|
116
116
|
version: "0"
|
117
117
|
type: :development
|
118
118
|
version_requirements: *id007
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: rubocop
|
121
|
+
prerelease: false
|
122
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
hash: 3
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
version: "0"
|
131
|
+
type: :development
|
132
|
+
version_requirements: *id008
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: simplecov
|
135
|
+
prerelease: false
|
136
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
hash: 3
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
version: "0"
|
145
|
+
type: :development
|
146
|
+
version_requirements: *id009
|
119
147
|
description: Library for calculation Chef differences between revisions
|
120
148
|
email:
|
121
149
|
executables: []
|
@@ -128,16 +156,21 @@ extra_rdoc_files:
|
|
128
156
|
files:
|
129
157
|
- README.md
|
130
158
|
- LICENSE
|
131
|
-
- lib/between_meals/changeset.rb
|
132
|
-
- lib/between_meals/repo.rb
|
133
|
-
- lib/between_meals/util.rb
|
134
159
|
- lib/between_meals/knife.rb
|
135
|
-
- lib/between_meals/
|
160
|
+
- lib/between_meals/cmd.rb
|
161
|
+
- lib/between_meals/util.rb
|
162
|
+
- lib/between_meals/repo.rb
|
163
|
+
- lib/between_meals/changeset.rb
|
136
164
|
- lib/between_meals/changes/change.rb
|
165
|
+
- lib/between_meals/changes/role.rb
|
137
166
|
- lib/between_meals/changes/cookbook.rb
|
138
167
|
- lib/between_meals/changes/databag.rb
|
168
|
+
- lib/between_meals/repo/svn/cmd.rb
|
169
|
+
- lib/between_meals/repo/hg/cmd.rb
|
170
|
+
- lib/between_meals/repo/git/cmd.rb
|
139
171
|
- lib/between_meals/repo/svn.rb
|
140
172
|
- lib/between_meals/repo/git.rb
|
173
|
+
- lib/between_meals/repo/hg.rb
|
141
174
|
homepage: https://github.com/facebook/between-meals
|
142
175
|
licenses:
|
143
176
|
- Apache
|