diff --git a/bin/rbpkg b/bin/rbpkg
index 9e4db14..7bbc485 100755
--- a/bin/rbpkg
+++ b/bin/rbpkg
@@ -53,6 +53,8 @@ def rbpkg(args)
Rbpkg.clean_sources(args[1..])
when "fetch"
Rbpkg.fetch(args[1..])
+ when "pull"
+ Rbpkg.pull(args[1..])
when "info"
Rbpkg.info(args[1..])
else
diff --git a/lib/rbpkg.rb b/lib/rbpkg.rb
index 326bfa8..0f467b4 100644
--- a/lib/rbpkg.rb
+++ b/lib/rbpkg.rb
@@ -79,6 +79,12 @@ module Rbpkg
"#{log_dir}/#{name}_#{date}_#{$$}.log"
end
+ def self.pull(repos)
+ repos.each do |name|
+ Repos.repo(name).pull()
+ end
+ end
+
def self.src_dir
"#{dir}/src"
end
diff --git a/lib/rbpkg/repo.rb b/lib/rbpkg/repo.rb
index 1a47dba..7678748 100644
--- a/lib/rbpkg/repo.rb
+++ b/lib/rbpkg/repo.rb
@@ -16,8 +16,7 @@ class Rbpkg::Repo
end
def fetch
- raise "must clone first" unless File.directory?(src_dir)
- cmd "cd #{sh_quote(src_dir)} && git fetch"
+ cmd "cd #{sh_quote(src_dir!)} && git fetch"
end
def git_clone
@@ -49,10 +48,20 @@ class Rbpkg::Repo
self.class.name.to_s.downcase.scan(/::([^:]*)$/)[0][0]
end
+ def pull
+ cmd "cd #{sh_quote(src_dir!)} && git pull"
+ end
+
def src_dir
"#{Rbpkg.src_dir}/#{dir}"
end
+ def src_dir!
+ path = src_dir
+ raise "must clone first" unless File.directory?(path)
+ path
+ end
+
def src_parent_dir
File.dirname(src_dir)
end