Permalink
Browse files

Rakefile: Add a task to easly update all submodules.

  • Loading branch information...
1 parent d210761 commit 357dbd4d3e9fbebdd60ead0a01f8474fd5bf1f11 @kalbasit kalbasit committed Nov 2, 2011
Showing with 32 additions and 0 deletions.
  1. +32 −0 Rakefile
View
@@ -6,6 +6,38 @@ task expand("~/.vimrc") => "vimrc" do
sh "ln -s ~/.vim/vimrc ~/.vimrc"
end
+# Get a list of submodules
+#
+# @return [Array] of submodules
+def submodules
+ `git submodule`.split("\n").collect { |s| s.split(" ")[1] }
+end
+
+# Update a submodule
+#
+# @param [String] The submodule to update (relative path)
+# @param [String] The branch we're tracking
+def update_submodule(submodule, branch = "master")
+ Dir.chdir submodule do
+ puts
+ puts "*" * 40
+ puts "*#{"Updating #{submodule}".center(38)}*"
+ puts "*" * 40
+ puts
+ sh "git checkout #{branch}"
+ sh "git pull"
+ end
+end
+
+namespace :dev do
+ desc "Update submodules"
+ task :update_submodules do
+ submodules.each do |submodule|
+ update_submodule(submodule)
+ end
+ end
+end
+
task expand("~/.gvimrc") => "gvimrc" do
sh "ln -s ~/.vim/gvimrc ~/.gvimrc"
end

0 comments on commit 357dbd4

Please sign in to comment.