multipush 0.0.1

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/.gemtest ADDED
File without changes
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ === 0.0.1 2012-10-23
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/README.rdoc ADDED
@@ -0,0 +1,70 @@
1
+ = multipush
2
+
3
+ * http://github.com/cmdjohnson/multipush
4
+
5
+ == DESCRIPTION:
6
+
7
+ This is multipush, a nifty tool to safely back up your source code from multiple Git repos to one or more remotes.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ Push multiple Git repos to one or more remotes.
12
+
13
+ == SYNOPSIS:
14
+
15
+ $ multipush
16
+
17
+ == REQUIREMENTS:
18
+
19
+ - ruby
20
+
21
+ == INSTALL:
22
+
23
+ Create a config file multipush.yml in the directory above the directories that contain your source code.
24
+ E.g. if you like to keep all your Ruby/Rails stuff in a folder called "ruby", place the multipush.yml in that folder.
25
+
26
+ - ruby <--- put multipush.yml here
27
+ \-- my_rails_project
28
+ \-- my_ruby_project
29
+ \-- another_git_project
30
+
31
+ For an example on how to set up the config file, check out the example file multipush.yml in the examples directory.
32
+
33
+ Make sure your source code hosting has all the right repos set up before you invoke multipush.
34
+
35
+ So if you have three repos named john, bear and super88, make sure your local and remote are mirrored:
36
+
37
+ LOCAL:
38
+ - john
39
+ - bear
40
+ - super88
41
+
42
+ REMOTE:
43
+ - john
44
+ - bear
45
+ - super88
46
+
47
+ == LICENSE:
48
+
49
+ (The MIT License)
50
+
51
+ Copyright (c) 2012 Commander Johnson <commanderjohnson@gmail.com>
52
+
53
+ Permission is hereby granted, free of charge, to any person obtaining
54
+ a copy of this software and associated documentation files (the
55
+ 'Software'), to deal in the Software without restriction, including
56
+ without limitation the rights to use, copy, modify, merge, publish,
57
+ distribute, sublicense, and/or sell copies of the Software, and to
58
+ permit persons to whom the Software is furnished to do so, subject to
59
+ the following conditions:
60
+
61
+ The above copyright notice and this permission notice shall be
62
+ included in all copies or substantial portions of the Software.
63
+
64
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
65
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
66
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
67
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
68
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
69
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
70
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/multipush'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'multipush' do
14
+ self.developer 'Commander Johnson', 'commanderjohnson@gmail.com'
15
+ #self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
+ self.rubyforge_name = self.name # TODO this is default value
17
+ # self.extra_deps = [['activesupport','>= 2.0.2']]
18
+
19
+ end
20
+
21
+ require 'newgem/tasks'
22
+ Dir['tasks/**/*.rake'].each { |t| load t }
23
+
24
+ # TODO - want other tests/tasks run by default? Add them to the list
25
+ # remove_task :default
26
+ # task :default => [:spec, :features]
data/bin/multipush ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created on 2012-10-23.
4
+ # Copyright (c) 2012. All rights reserved.
5
+
6
+ require 'rubygems'
7
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/multipush")
8
+ require "multipush/base"
9
+
10
+ Multipush::Base.new.go!
@@ -0,0 +1,15 @@
1
+ # config file for multipush, a nifty tool that backups multiple git repositories.
2
+
3
+ # which dirs do you want to include?
4
+ dirs:
5
+ - ruby
6
+ - rails
7
+
8
+ # which remotes do you want to add?
9
+ # The remotes will be prefixed with multipush_
10
+ # e.g. if you specify a remote name "backup1", multipush will add a remote called
11
+ # "multipush_backup1"
12
+
13
+ remotes:
14
+ backup1: "ssh://myuser@myserver.com/home/git"
15
+ backup2: "ssh://pete@workserver.com/home/pete"
@@ -0,0 +1,99 @@
1
+ require 'yaml'
2
+
3
+ # this is multipush, a nifty tool to safely back up your source code from multiple Git repos to one or more remotes.
4
+ # create a config file multipush.yml in the directory that contains your source code.
5
+ # also, make sure your source code hosting has all the right repos set up before you invoke multipush.
6
+
7
+ # will not run on Windows. sorry.
8
+ module Multipush
9
+ class Base
10
+ def log(str)
11
+ str = " [#{Time.now}] #{str}"
12
+
13
+ puts str
14
+ system("echo '#{str}' >> multipush.log")
15
+ end
16
+
17
+ def my_system(cmd)
18
+ #puts cmd
19
+ # Don't print stderror, log that as well.
20
+ #output = `#{cmd} 2>&1`
21
+ #system("echo #{output} >> multipush.log")
22
+ system(cmd)
23
+ end
24
+
25
+ def go!(params = {})
26
+ # clear log file
27
+ system("cat /dev/null > multipush.log")
28
+
29
+ git_cmd = "git"
30
+ remote_prefix = "multipush_"
31
+ config_file_name = "multipush.yml"
32
+ config = nil
33
+
34
+ raise "Could not find config file #{config_file_name}" unless File.exists?(config_file_name)
35
+
36
+ begin
37
+ config = YAML::load(File.new(config_file_name))
38
+ rescue => e
39
+ raise "Error loading config file #{config_file_name}: #{e}"
40
+ end
41
+
42
+ # do some config checks
43
+ raise "dirs must be an Array" unless config["dirs"].is_a?(Array)
44
+ raise "remotes must be a Hash" unless config["remotes"].is_a?(Hash)
45
+
46
+ # the remotes have been defined. good.
47
+ # let's go.
48
+ # apply the list of remotes to every repo.
49
+
50
+ repo_count = 0
51
+
52
+ for dir in config["dirs"]
53
+ oldest_dir = Dir.pwd
54
+ # change
55
+ Dir.chdir dir
56
+ # get all subdirs
57
+ subdirs = Dir["*/"]
58
+ # gogo
59
+ for subdir in subdirs
60
+ olddir = Dir.pwd
61
+ #puts subdir
62
+ # change to the dir
63
+ Dir.chdir subdir
64
+
65
+ # verbose
66
+ log(subdir)
67
+
68
+ repo_count += 1
69
+
70
+ ############################################################################
71
+ # apply the list of remotes to every repo
72
+ ############################################################################
73
+
74
+ config["remotes"].each do |remote, endpoint|
75
+ the_remote = "#{remote_prefix}#{remote}"
76
+ # remove the remote, just to make sure
77
+ # this allows the user to change remote location in the multipush config file
78
+ # instead of having to manage different git repo's.
79
+ my_system("#{git_cmd} remote rm #{the_remote}")
80
+ # now re-add it again
81
+ my_system("#{git_cmd} remote add #{the_remote} #{endpoint}/#{subdir}")
82
+ # let's push
83
+ my_system("#{git_cmd} push #{the_remote} --all")
84
+ end
85
+
86
+ ############################################################################
87
+ # cleanup
88
+ ############################################################################
89
+
90
+ Dir.chdir olddir
91
+ end
92
+
93
+ Dir.chdir oldest_dir
94
+ end
95
+
96
+ log("Done. Processed #{repo_count} repos.")
97
+ end
98
+ end
99
+ end
data/lib/multipush.rb ADDED
@@ -0,0 +1,11 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'multipush/base'
5
+
6
+ module Multipush
7
+ VERSION = '0.0.1'
8
+ end
9
+
10
+ # gogogogogogogogogogogo
11
+ #Multipush::Base.new.go!
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/multipush.rb'}"
9
+ puts "Loading multipush gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/multipush'
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestMultipush < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: multipush
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Commander Johnson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rdoc
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.10'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.10'
30
+ - !ruby/object:Gem::Dependency
31
+ name: newgem
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 1.5.3
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: 1.5.3
46
+ - !ruby/object:Gem::Dependency
47
+ name: hoe
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '3.1'
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: '3.1'
62
+ description: This is multipush, a nifty tool to safely back up your source code from
63
+ multiple Git repos to one or more remotes.
64
+ email:
65
+ - commanderjohnson@gmail.com
66
+ executables:
67
+ - multipush
68
+ extensions: []
69
+ extra_rdoc_files:
70
+ - History.txt
71
+ - README.rdoc
72
+ files:
73
+ - History.txt
74
+ - README.rdoc
75
+ - Rakefile
76
+ - lib/multipush.rb
77
+ - lib/multipush/base.rb
78
+ - script/console
79
+ - script/destroy
80
+ - script/generate
81
+ - test/test_helper.rb
82
+ - test/test_multipush.rb
83
+ - examples/multipush.yml
84
+ - bin/multipush
85
+ - .gemtest
86
+ homepage: http://github.com/cmdjohnson/multipush
87
+ licenses: []
88
+ post_install_message:
89
+ rdoc_options:
90
+ - --main
91
+ - README.rdoc
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project: multipush
108
+ rubygems_version: 1.8.23
109
+ signing_key:
110
+ specification_version: 3
111
+ summary: This is multipush, a nifty tool to safely back up your source code from multiple
112
+ Git repos to one or more remotes.
113
+ test_files:
114
+ - test/test_multipush.rb
115
+ - test/test_helper.rb