opskeleton 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23dd029f2dfd870048e84db9f1697b4e70345807
4
- data.tar.gz: aad74fe64226e511e7f4e81510cee8a7daa4d120
3
+ metadata.gz: a682d5b86347ac3071cf2c08eadf86a29616f52b
4
+ data.tar.gz: 10a8db6e1b3899892d40316f89baf1a2b6f23bb3
5
5
  SHA512:
6
- metadata.gz: eba347ecad77000f8de4708550b9cb2f19db7fddc1bd36974d68c4b705b3e46c5c6a7a05b6314d69293c4aed69e1678d66bfba8771c9a515e18239beeebd320a
7
- data.tar.gz: a275be5c7b3b534ebd522463a030d4ea8c2e1c16fe4aa265993486949873a7c2be8a467bf36a57d9cd4cd459e01ab008797196e6976ba8c55ea4f5dca36683bc
6
+ metadata.gz: 4e08fad418737ff4af9a1ef1e071a8ed97668144ad50119ff1a69c34f7f9ecd9b4e6c6d1c2704fcbcaed14df75ac6141198385b051eebba3f8bd3a5f759b03da
7
+ data.tar.gz: dd8f1d5e8d5dddb8033febd2cdc51d4d01c23ded91aa5fb77a03733222747034aa80a3d5f53bc1e67f5c1214ffd45f5710373c176e10064b9e0bc1108e8cb343
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opskeleton (0.9.4)
4
+ opskeleton (0.9.5)
5
5
  aws-sdk (~> 2)
6
6
  bintray_deploy
7
7
  git
@@ -123,7 +123,7 @@ GEM
123
123
  librarianp (0.6.3)
124
124
  thor (~> 0.15)
125
125
  libyajl2 (1.2.0)
126
- listen (3.0.2)
126
+ listen (3.0.3)
127
127
  rb-fsevent (>= 0.9.3)
128
128
  rb-inotify (>= 0.9)
129
129
  lumberjack (1.0.9)
@@ -1,41 +1,6 @@
1
1
 
2
2
 
3
3
  module Opsk
4
- class CommitGit
5
- def initialize(d,options,thor)
6
- @g = Git.init(d)
7
- @options = options
8
- @thor = thor
9
- end
10
-
11
- def changed?
12
- @g.status.changed.keys.length > 0
13
- end
14
-
15
- def report
16
- %i(changed added untracked).each do |state|
17
- @thor.say "#{state} files:\n\n"
18
- @g.status.send(state).each do |k,v|
19
- @thor.say "- #{k}"
20
- end
21
- @thor.say "\n"
22
- end
23
- end
24
-
25
- def master_commit(d)
26
- resp = @thor.yes? "Commit the changes under #{d}? (y/n)" unless @options['all']
27
- if(@options['all'] or resp)
28
- @g.checkout('master')
29
- if @options['message']
30
- @g.commit_all(@options['message'])
31
- else
32
- @thor.say 'Commit message:'
33
- @g.commit_all(STDIN.gets.chomp)
34
- end
35
- end
36
-
37
- end
38
- end
39
4
 
40
5
  class Commit < Thor::Group
41
6
  include Thorable, Thor::Actions
@@ -47,16 +12,15 @@ module Opsk
47
12
  check_root
48
13
  end
49
14
 
50
-
51
15
  def commit
52
16
  Dir["modules/*"].reject{|o| not File.directory?(o)}.each do |d|
53
17
  if File.exists?("#{d}/.git")
54
18
  begin
55
- cg = Opsk::CommitGit.new(d,options,self)
56
- if cg.changed?
19
+ git = Opsk::Git.new(d,self)
20
+ if git.changed?
57
21
  say "Listing changes for #{d}:\n\n"
58
- cg.report
59
- cg.master_commit(d)
22
+ git.report
23
+ git.master_commit(d,options)
60
24
  end
61
25
  rescue => e
62
26
  say "Failed to commit #{d} due to #{e}"
@@ -0,0 +1,66 @@
1
+ require 'git_clone_url'
2
+
3
+ module Opsk
4
+ class Git
5
+ extend Forwardable
6
+
7
+
8
+ def initialize(d,thor)
9
+ @g = ::Git.open(d)
10
+ @thor = thor
11
+ end
12
+
13
+ def_delegator :@g, :push, :push
14
+ def_delegator :@g, :pull, :pull
15
+
16
+ def changed?
17
+ @g.status.changed.keys.length > 0
18
+ end
19
+
20
+ def report
21
+ %i(changed added untracked).each do |state|
22
+ @thor.say "#{state} files:\n\n"
23
+ @g.status.send(state).each do |k,v|
24
+ @thor.say "- #{k}"
25
+ end
26
+ @thor.say "\n"
27
+ end
28
+ end
29
+
30
+ def master_commit(d,options)
31
+ resp = @thor.yes? "Commit the changes under #{d}? (y/n)" unless options['all']
32
+ if(options['all'] or resp)
33
+ @g.checkout('master')
34
+ if options['message']
35
+ @g.commit_all(options['message'])
36
+ else
37
+ @thor.say 'Commit message:'
38
+ @g.commit_all(STDIN.gets.chomp)
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ def normalize_url(readonly,options)
45
+ url = GitCloneUrl.parse(readonly)
46
+ proto = options['protocol'] || 'ssh'
47
+ port = options['port']? ":#{options['port']}" : ''
48
+ user = options['user']? "#{options['user']}@" : ''
49
+ "#{proto}://#{user}#{url.host}#{port}#{url.path}"
50
+ end
51
+
52
+ def add_writable(options)
53
+ readonly = @g.remotes.find{|r|r.name.eql?('origin')}.url
54
+ writable = normalize_url(readonly,options)
55
+ remote_exists = @g.remotes.map {|r| r.name}.include?('writable')
56
+ unless readonly.eql?(writable) or remote_exists
57
+ @g.add_remote('writable',writable)
58
+ end
59
+ end
60
+
61
+ # ruby-git cannot do this (lame)
62
+ def local_ahead?
63
+ %x{git --git-dir=#{@d}/.git --work-tree=#{@d}}.include?('ahead')
64
+ end
65
+ end
66
+ end
@@ -1,27 +1,4 @@
1
1
 
2
- require 'git_clone_url'
3
-
4
- def normalize_url(readonly,options)
5
- url = GitCloneUrl.parse(readonly)
6
- proto = options['protocol'] || 'ssh'
7
- port = options['port']? ":#{options['port']}" : ''
8
- user = options['user']? "#{options['user']}@" : ''
9
- "#{proto}://#{user}#{url.host}#{port}#{url.path}"
10
- end
11
-
12
- def add_writable(g,options)
13
- readonly = g.remotes.find{|r|r.name.eql?('origin')}.url
14
- writable = normalize_url(readonly,options)
15
- remote_exists = g.remotes.map {|r| r.name}.include?('writable')
16
- unless readonly.eql?(writable) or remote_exists
17
- g.add_remote('writable',writable)
18
- end
19
- end
20
-
21
- # ruby-git cannot do this (lame)
22
- def local_ahead?(d)
23
- %x{git --git-dir=#{d}/.git --work-tree=#{d}}.include?('ahead')
24
- end
25
2
 
26
3
  module Opsk
27
4
  class Push < Thor::Group
@@ -42,14 +19,14 @@ module Opsk
42
19
  Dir["modules/*"].reject{|o| not File.directory?(o)}.each do |d|
43
20
  begin
44
21
  if File.exists?("#{d}/.git")
45
- g = Git.open(d)
46
- add_writable(g,options)
47
- if !options['dry'] and local_ahead?(d)
22
+ git = Opsk::Git.new(d,self)
23
+ git.add_writable(options)
24
+ if !options['dry'] and git.local_ahead?
48
25
  resp = yes?("Push #{d}? (y/n)") unless options['all']
49
26
  if(options['all'] or resp)
50
27
  say "pushing #{d} .."
51
- g.push('writable')
52
- g.pull
28
+ git.push('writable')
29
+ git.pull
53
30
  end
54
31
  end
55
32
  end
@@ -1,3 +1,3 @@
1
1
  module Opskeleton
2
- VERSION = '0.9.4'
2
+ VERSION = '0.9.5'
3
3
  end
data/lib/opskeleton.rb CHANGED
@@ -18,4 +18,5 @@ require 'opskeleton/module'
18
18
  require 'opskeleton/commit'
19
19
  require 'opskeleton/uncommited'
20
20
  require 'opskeleton/push'
21
+ require 'opskeleton/git'
21
22
 
data/test/git_test.rb CHANGED
@@ -49,12 +49,13 @@ class GitTest < MiniTest::Unit::TestCase
49
49
  end
50
50
 
51
51
  def test_urls
52
+ git = Opsk::Git.new('.',nil)
52
53
  readonly = 'git://github.com/pulling-strings/puppet-jdk.git'
53
- norm = normalize_url(readonly,{})
54
+ norm = git.normalize_url(readonly,{})
54
55
  assert norm == 'ssh://github.com/pulling-strings/puppet-jdk.git'
55
- norm = normalize_url(readonly,{'protocol' => 'https','port' => '1234'})
56
+ norm = git.normalize_url(readonly,{'protocol' => 'https','port' => '1234'})
56
57
  assert norm == 'https://github.com:1234/pulling-strings/puppet-jdk.git'
57
- norm = normalize_url(readonly,{'user' => 'ronen', 'protocol' => 'ssh','port' => '1234'})
58
+ norm = git.normalize_url(readonly,{'user' => 'ronen', 'protocol' => 'ssh','port' => '1234'})
58
59
  assert norm == 'ssh://ronen@github.com:1234/pulling-strings/puppet-jdk.git'
59
60
  end
60
61
  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.9.4
4
+ version: 0.9.5
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-22 00:00:00.000000000 Z
11
+ date: 2015-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -289,6 +289,7 @@ files:
289
289
  - lib/opskeleton/dockerize.rb
290
290
  - lib/opskeleton/generate_chef.rb
291
291
  - lib/opskeleton/generate_puppet.rb
292
+ - lib/opskeleton/git.rb
292
293
  - lib/opskeleton/module.rb
293
294
  - lib/opskeleton/package.rb
294
295
  - lib/opskeleton/push.rb