contribulator 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/contribulator +90 -0
  2. metadata +95 -0
data/bin/contribulator ADDED
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env ruby
2
+ # 1.9 adds realpath to resolve symlinks; 1.8 doesn't
3
+ # have this method, so we add it so we get resolved symlinks
4
+ # and compatibility
5
+ unless File.respond_to? :realpath
6
+ class File #:nodoc:
7
+ def self.realpath path
8
+ return realpath(File.readlink(path)) if symlink?(path)
9
+ path
10
+ end
11
+ end
12
+ end
13
+ $: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
14
+ require 'rubygems'
15
+ require 'gli'
16
+ require 'digest'
17
+ require 'contribulator_version'
18
+
19
+ include GLI
20
+
21
+ program_desc 'Publish changes from one repo to another'
22
+
23
+ version Contribulator.version
24
+
25
+ desc "Publish a repo's master branch to another repo with force"
26
+ command :publish do |c|
27
+ c.desc "Resetup the repositories locally before publishing"
28
+ c.switch :fresh
29
+
30
+ c.action do |global_options, options, args|
31
+ exit_now! 'you must provide the source repo as the first argument', 0 if args.empty?
32
+
33
+ source_repo = args[0]
34
+ destination_repo = if args[1]
35
+ args[1]
36
+ else
37
+ stripped_source_repo = source_repo[-4..-1] == '.git' ? source_repo[0..-5] : source_repo
38
+ "#{stripped_source_repo}_contrib"
39
+ end
40
+ tmp_dir = File.expand_path("../../tmp/#{Digest::SHA256.hexdigest("#{source_repo}_#{destination_repo}")[0..10]}", __FILE__)
41
+
42
+
43
+ if options[:fresh]
44
+ puts "Removing the local clones for this publication\n\n"
45
+ FileUtils.rm_r(tmp_dir)
46
+ end
47
+
48
+ fetch_and_push_command = %(
49
+ git fetch &&
50
+ git push contrib origin/master:master &&
51
+ git push contrib --tags
52
+ )
53
+
54
+ if(File.exists?(tmp_dir))
55
+ puts "Repos already setup to fetch and push"
56
+ setup_command = "cd #{tmp_dir} &&"
57
+ command = setup_command + fetch_and_push_command
58
+ else
59
+ puts "Setting up repos to fetch and push"
60
+ setup_command = %(
61
+ mkdir -p #{tmp_dir} &&
62
+ cd #{tmp_dir} &&
63
+ git init . &&
64
+ git remote add origin #{source_repo} &&
65
+ git remote add contrib #{destination_repo} &&
66
+ )
67
+ command = setup_command + fetch_and_push_command
68
+ end
69
+
70
+ puts %(
71
+ Executing command:
72
+ ------------------------------------------
73
+
74
+ #{command}
75
+ ------------------------------------------)
76
+
77
+ puts %(
78
+ Output of the command:
79
+ ------------------------------------------
80
+
81
+ )
82
+ puts `#{command}`
83
+ puts %(------------------------------------------
84
+
85
+ Command Finished.
86
+ )
87
+ end
88
+ end
89
+
90
+ exit GLI.run(ARGV)
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: contribulator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Matt Simpson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gli
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description:
63
+ email: matt.simpson@asolutions.com
64
+ executables:
65
+ - contribulator
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - bin/contribulator
70
+ homepage: http://github.com/ionicmobile/contribulator
71
+ licenses: []
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 1.8.24
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: Publish changes from one repo to another
95
+ test_files: []