opskeleton 0.8.12 → 0.9.0
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/.travis.yml +2 -0
- data/CHANGES.md +4 -0
- data/bin/opsk +3 -0
- data/lib/opskeleton/commit.rb +17 -8
- data/lib/opskeleton/push.rb +52 -0
- data/lib/opskeleton/version.rb +1 -1
- data/lib/opskeleton.rb +1 -0
- data/test/{commit_test.rb → git_test.rb} +11 -2
- data/test/test_helper.rb +1 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 508174515b38f87c8e376b887939b4d15e6c5b7d
|
4
|
+
data.tar.gz: a06b48dcaf9022a15330ceb46aef1325a87f5fd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52409252bfa751e825d48f429da25bcf868c65c896508781dc5e205ae0c33d9efe780373287e51d356e6b17665456de95905c99f95eb3bfd81bb6659231f26e3
|
7
|
+
data.tar.gz: 024cf29ff87a4773f384c47a887bdeb589d7642c1ca47c5f37572992b8de3026eb216a954ccbf5cf434b287d8863f0e3c74062b4e38a9bdda569de51ff26e010
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
data/bin/opsk
CHANGED
@@ -21,6 +21,7 @@ module Opsk
|
|
21
21
|
register Opsk::Package, 'package', 'package', 'packages current module for celestial'
|
22
22
|
register Opsk::Dockerize, 'dockerize', 'dockerize [from] [os_type]', 'Creates a docker image from the current sandbox'
|
23
23
|
register Opsk::Commit, 'commit', 'commit [message]', 'commit each changed puppet module under modules folder'
|
24
|
+
register Opsk::Push, 'push', 'push', 'push each changed puppet module under modules folder'
|
24
25
|
register Opsk::Clean, 'clean', 'clean', 'cleans up packaging products'
|
25
26
|
register Opsk::Bump, 'bump', 'bump', 'bumps up version (clearing old version also)'
|
26
27
|
register Opsk::DeployBintray, 'deploy_bintray', 'deploy_bintray [repo]', 'deploy packge into bintray.com'
|
@@ -37,5 +38,7 @@ end
|
|
37
38
|
# not sure that this is the cleanest way
|
38
39
|
Opsk::Root.tasks['generate_puppet'].options = Opsk::GeneratePuppet.class_options
|
39
40
|
Opsk::Root.tasks['generate_chef'].options = Opsk::GenerateChef.class_options
|
41
|
+
Opsk::Root.tasks['push'].options = Opsk::Push.class_options
|
42
|
+
Opsk::Root.tasks['commit'].options = Opsk::Commit.class_options
|
40
43
|
|
41
44
|
Opsk::Root.start ARGV
|
data/lib/opskeleton/commit.rb
CHANGED
@@ -1,31 +1,40 @@
|
|
1
|
+
|
1
2
|
module Opsk
|
2
3
|
class Commit < Thor::Group
|
3
4
|
include Thorable, Thor::Actions
|
4
5
|
|
5
6
|
class_option :message, :type=> :string, :desc => 'optional commit message'
|
7
|
+
class_option :all, :type=> :boolean, :desc => 'commit all', :default => false
|
6
8
|
|
7
9
|
def validate
|
8
10
|
check_root
|
9
11
|
end
|
10
12
|
|
13
|
+
|
11
14
|
def commit
|
12
15
|
Dir["modules/*"].reject{|o| not File.directory?(o)}.each do |d|
|
13
16
|
if File.exists?("#{d}/.git")
|
14
17
|
g = Git.init(d)
|
15
18
|
if g.status.changed.keys.length > 0
|
16
|
-
puts "
|
17
|
-
puts "#{g.show}\n"
|
18
|
-
|
19
|
-
if
|
20
|
-
g.
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
puts "Listing changes for #{d}:\n\n"
|
20
|
+
puts "#{g.show}\n\n"
|
21
|
+
puts "Commit the changes under #{d}? (y/n)\n\n" unless options['all']
|
22
|
+
if(options['all'] or STDIN.gets.chomp.eql?('y'))
|
23
|
+
g.checkout('master')
|
24
|
+
if options['message']
|
25
|
+
g.commit_all(options['message'])
|
26
|
+
else
|
27
|
+
puts 'Please provide commit message:\n'
|
28
|
+
g.commit_all(STDIN.gets.chomp)
|
29
|
+
end
|
24
30
|
end
|
31
|
+
else
|
32
|
+
puts 'no changes detected'
|
25
33
|
end
|
26
34
|
end
|
27
35
|
end
|
28
36
|
end
|
29
37
|
|
38
|
+
|
30
39
|
end
|
31
40
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
GIT_PROTO = { ssh:'git@', https: 'https://' }
|
3
|
+
|
4
|
+
def add_pre(url)
|
5
|
+
res = url.split('/')
|
6
|
+
res[0] = "#{res[0]}:"
|
7
|
+
res.join('/')
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_writable(g,proto)
|
11
|
+
readonly = g.remotes.find{|r|r.name.eql?('origin')}.url
|
12
|
+
writable = readonly.gsub(/git\:\/\//,GIT_PROTO[proto])
|
13
|
+
writable = add_pre(writable) if proto.eql?(:ssh)
|
14
|
+
remote_exists = g.remotes.map {|r| r.name}.include?('writable')
|
15
|
+
unless readonly.eql?(writable) or remote_exists
|
16
|
+
g.add_remote('writable',writable)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module Opsk
|
21
|
+
class Push < Thor::Group
|
22
|
+
include Thorable, Thor::Actions
|
23
|
+
|
24
|
+
class_option :protocol, :type=> :string, :desc => 'remote ssh protocol (https or ssh)', :default => 'ssh'
|
25
|
+
class_option :dry, :type=> :boolean, :desc => 'dry mode', :default => false
|
26
|
+
class_option :all, :type=> :boolean, :desc => 'push all without asking', :default => false
|
27
|
+
|
28
|
+
def validate
|
29
|
+
check_root
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def push
|
34
|
+
Dir["modules/*"].reject{|o| not File.directory?(o)}.each do |d|
|
35
|
+
if File.exists?("#{d}/.git")
|
36
|
+
g = Git.init(d)
|
37
|
+
add_writable(g,options['protocol'].to_sym)
|
38
|
+
if !options['dry'] and g.diff('origin').stats[:files].keys.length > 0
|
39
|
+
puts "push #{d}? (y/n)" unless options['all']
|
40
|
+
if(options['all'] or STDIN.gets.chomp.eql?('y'))
|
41
|
+
puts "Pushing #{d} .."
|
42
|
+
g.push('writable')
|
43
|
+
g.pull
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
data/lib/opskeleton/version.rb
CHANGED
data/lib/opskeleton.rb
CHANGED
@@ -7,7 +7,7 @@ require 'git'
|
|
7
7
|
|
8
8
|
SANDBOX = 'commit'
|
9
9
|
ROOT = "#{SANDBOX}-sandbox/modules/foo"
|
10
|
-
class
|
10
|
+
class GitTest < MiniTest::Unit::TestCase
|
11
11
|
include FileUtils
|
12
12
|
|
13
13
|
def setup
|
@@ -15,6 +15,7 @@ class CommitTest < MiniTest::Unit::TestCase
|
|
15
15
|
mkdir_p(ROOT)
|
16
16
|
mkdir_p("#{SANDBOX}-sandbox/modules/non-git")
|
17
17
|
g = Git.init(ROOT)
|
18
|
+
g.add_remote('origin','git://github.com/foo/bar.git')
|
18
19
|
touch("#{ROOT}/bla.txt")
|
19
20
|
g.add('bla.txt')
|
20
21
|
g.commit_all('message')
|
@@ -33,9 +34,17 @@ class CommitTest < MiniTest::Unit::TestCase
|
|
33
34
|
|
34
35
|
def test_commit
|
35
36
|
with_cwd "#{SANDBOX}-sandbox" do
|
36
|
-
Opsk::Root.start ['commit', '--message', 'some message']
|
37
|
+
Opsk::Root.start ['commit', '--message', 'some message', '--all', 'true']
|
37
38
|
end
|
38
39
|
g = Git.init(ROOT)
|
39
40
|
assert g.show.include? 'some message'
|
40
41
|
end
|
42
|
+
|
43
|
+
def test_writeable
|
44
|
+
with_cwd "#{SANDBOX}-sandbox" do
|
45
|
+
Opsk::Root.start ['push', '--dry', 'true']
|
46
|
+
end
|
47
|
+
g = Git.init(ROOT)
|
48
|
+
assert g.remotes.length == 2
|
49
|
+
end
|
41
50
|
end
|
data/test/test_helper.rb
CHANGED
@@ -10,6 +10,7 @@ module Opsk
|
|
10
10
|
register Opsk::GenerateChef, 'generate_chef', 'generate_chef [name] [box]', 'generates opskelaton project structure'
|
11
11
|
register Opsk::Package, 'package', 'package', 'packages current module for celestial'
|
12
12
|
register Opsk::Commit, 'commit', 'commit', 'commits current module for celestial'
|
13
|
+
register Opsk::Push, 'push', 'push', 'push changed repos'
|
13
14
|
|
14
15
|
end
|
15
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opskeleton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- narkisr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -204,6 +204,7 @@ files:
|
|
204
204
|
- lib/opskeleton/generate_puppet.rb
|
205
205
|
- lib/opskeleton/module.rb
|
206
206
|
- lib/opskeleton/package.rb
|
207
|
+
- lib/opskeleton/push.rb
|
207
208
|
- lib/opskeleton/thorable.rb
|
208
209
|
- lib/opskeleton/version.rb
|
209
210
|
- opskeleton.gemspec
|
@@ -249,7 +250,7 @@ files:
|
|
249
250
|
- templates/ruby-version.erb
|
250
251
|
- templates/spec.erb
|
251
252
|
- test/chef_package_test.rb
|
252
|
-
- test/
|
253
|
+
- test/git_test.rb
|
253
254
|
- test/puppet_package_test.rb
|
254
255
|
- test/test_helper.rb
|
255
256
|
homepage: https://github.com/narkisr/opskeleton
|
@@ -271,12 +272,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
272
|
version: '0'
|
272
273
|
requirements: []
|
273
274
|
rubyforge_project:
|
274
|
-
rubygems_version: 2.
|
275
|
+
rubygems_version: 2.2.2
|
275
276
|
signing_key:
|
276
277
|
specification_version: 4
|
277
278
|
summary: A generator for ops projects that include vagrant puppet and fpm
|
278
279
|
test_files:
|
279
280
|
- test/chef_package_test.rb
|
280
|
-
- test/
|
281
|
+
- test/git_test.rb
|
281
282
|
- test/puppet_package_test.rb
|
282
283
|
- test/test_helper.rb
|