revans-git_tools 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +18 -0
- data/README.markdown +69 -0
- data/Rakefile +0 -0
- data/lib/git_tools.rb +9 -0
- data/lib/git_tools/config/submodules.yml +13 -0
- data/lib/git_tools/submodules.rb +62 -0
- metadata +61 -0
data/LICENSE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright (c) 2009 Robert R Evans, Code Wranglers, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
7
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
8
|
+
subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
15
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
16
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Git_tools
|
2
|
+
|
3
|
+
## How to use
|
4
|
+
|
5
|
+
Create a yaml file in your config/ directory and name it submodules.yml.
|
6
|
+
|
7
|
+
Add the git submodules that you want to want to use in your application like so:
|
8
|
+
|
9
|
+
<pre>
|
10
|
+
submodules:
|
11
|
+
rspec: git://github.com/dchelimsky/rspec.git
|
12
|
+
rspec_rails: git://github.com/dchelimsky/rspec-rails.git
|
13
|
+
geokit: git://github.com/ptb/geokit.git
|
14
|
+
asset_packager: git://github.com/sbecker/asset_packager.git
|
15
|
+
paperclip: git://github.com/thoughtbot/paperclip.git
|
16
|
+
will_paginate: git://github.com/mislav/will_paginate.git
|
17
|
+
exception_notification: git://github.com/rails/exception_notification.git
|
18
|
+
cucumber: git://github.com/aslakhellesoy/cucumber.git
|
19
|
+
ssl_requirement: git://github.com/rails/ssl_requirement.git
|
20
|
+
rails: git://github.com/rails/rails.git
|
21
|
+
active_merchant: git://github.com/Shopify/active_merchant.git
|
22
|
+
</pre>
|
23
|
+
|
24
|
+
A couple of things, it needs to follow the structure above with the name submodules and defining each below it. Use the name
|
25
|
+
that you want the plugin to be named when checking out. Put the git location as the value.
|
26
|
+
|
27
|
+
Now, create a new Rake task in lib/tasks directory. I call mine submodules.rake. Here is what my file looks like:
|
28
|
+
|
29
|
+
<pre>
|
30
|
+
require 'git_tools'
|
31
|
+
|
32
|
+
@configration = File.join(RAILS_ROOT, "config/submodules.yml")
|
33
|
+
|
34
|
+
namespace :git do
|
35
|
+
|
36
|
+
namespace :submodule do
|
37
|
+
|
38
|
+
desc "Setup Submodules on checkout"
|
39
|
+
task :setup do
|
40
|
+
GitTools::Submodule.checkout
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Remove Submodule cache"
|
44
|
+
task :remove, :submodule do |task, args|
|
45
|
+
GitTools::Submodule.remove(args.submodule)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
namespace :update do
|
52
|
+
|
53
|
+
desc "Update all Submodules"
|
54
|
+
task :all => :environment do
|
55
|
+
GitTools::Submodule.update_all(@configration)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
GitTools::Submodule.individual_tasks(@configration) do |name|
|
60
|
+
desc "Update #{name} submodule"
|
61
|
+
task name.to_sym => :environment do
|
62
|
+
GitTools::Submodule.submodule_update("#{name}")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
</pre>
|
data/Rakefile
ADDED
File without changes
|
data/lib/git_tools.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
submodules:
|
2
|
+
rspec: git://github.com/dchelimsky/rspec.git
|
3
|
+
rspec_rails: git://github.com/dchelimsky/rspec-rails.git
|
4
|
+
geokit: git://github.com/ptb/geokit.git
|
5
|
+
asset_packager: git://github.com/sbecker/asset_packager.git
|
6
|
+
paperclip: git://github.com/thoughtbot/paperclip.git
|
7
|
+
will_paginate: git://github.com/mislav/will_paginate.git
|
8
|
+
ultrasphinx: git://github.com/fauna/ultrasphinx.git
|
9
|
+
exception_notification: git://github.com/rails/exception_notification.git
|
10
|
+
open_id_authentication: git://github.com/rails/open_id_authentication.git
|
11
|
+
cucumber: git://github.com/aslakhellesoy/cucumber.git
|
12
|
+
ssl_requirement: git://github.com/rails/ssl_requirement.git
|
13
|
+
rails: git://github.com/rails/rails.git
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module GitTools
|
2
|
+
|
3
|
+
class Submodule
|
4
|
+
|
5
|
+
def self.update_all(yaml)
|
6
|
+
@config = load_yaml(yaml)
|
7
|
+
@config.each_key do |name|
|
8
|
+
message(name) { submodule_update(name) }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.install_all(yaml)
|
13
|
+
@config = load_yaml(yaml)
|
14
|
+
@config.each { |plugin, repo| add(repo, plugin) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.add(repo, location)
|
18
|
+
system("git submodule add #{repo} #{location}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.init
|
22
|
+
system("git submodule init")
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.update
|
26
|
+
system("git submodule update")
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.checkout
|
30
|
+
init
|
31
|
+
update
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.remove(submodule)
|
35
|
+
system("git rm --cache vendor/plugins/#{submodule}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.submodule_update(name)
|
39
|
+
dir = name == "rails" ? "vendor/rails/" : "vendor/plugins/#{name}"
|
40
|
+
system("cd #{dir} && git remote update && git merge origin/master")
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.load_yaml(yaml)
|
44
|
+
YAML::load(File.open(yaml))['submodules']
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def self.message(name, &block)
|
49
|
+
puts "Updating #{name.to_s}"
|
50
|
+
yield
|
51
|
+
puts "\n"
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def self.individual_tasks(yaml, &block)
|
56
|
+
@config = load_yaml(yaml)
|
57
|
+
@config.each_key { |name| yield name }
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: revans-git_tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert R Evans
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-21 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: An easy way to manage your git submodules in a Rails Application.
|
17
|
+
email: robert@codewranglers.org
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.markdown
|
24
|
+
- ChangeLog.rdoc
|
25
|
+
- LICENSE
|
26
|
+
files:
|
27
|
+
- README.markdown
|
28
|
+
- LICENSE
|
29
|
+
- ChangeLog.rdoc
|
30
|
+
- Rakefile
|
31
|
+
- lib/git_tools.rb
|
32
|
+
- lib/git_tools/submodules.rb
|
33
|
+
- lib/git_tools/config/submodules.yml
|
34
|
+
has_rdoc: true
|
35
|
+
homepage: http://codewranglers.org
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
53
|
+
requirements: []
|
54
|
+
|
55
|
+
rubyforge_project: git_tools
|
56
|
+
rubygems_version: 1.2.0
|
57
|
+
signing_key:
|
58
|
+
specification_version: 2
|
59
|
+
summary: An easy way to manage your git submodules in a Rails Application.
|
60
|
+
test_files: []
|
61
|
+
|