Class: Sunshine::SvnRepo
Overview
Simple scm wrapper for subversion control.
Constant Summary collapse
- NAME_MATCH =
/([^\/]+\/)+([^\/]+)\/(trunk|branches|tags)/
Instance Attribute Summary
Attributes inherited from Repo
Class Method Summary collapse
-
.get_info(path = ".", shell = nil) ⇒ Object
Get the repo info from the path to a checked out svn repo.
-
.get_svn_url(path, shell) ⇒ Object
Get the svn url from a svn or git-svn checkout.
-
.git_svn?(path = ".") ⇒ Boolean
Check if this is a git-svn repo.
-
.svn_log(path, shell) ⇒ Object
Returns the svn logs as xml.
-
.valid?(path = ".") ⇒ Boolean
Check if this is an svn repo.
Instance Method Summary collapse
Methods inherited from Repo
#checkout_to, detect, #get_repo_info, inherited, #initialize, new_of_type, #scm_flags
Constructor Details
This class inherits a constructor from Sunshine::Repo
Class Method Details
.get_info(path = ".", shell = nil) ⇒ Object
Get the repo info from the path to a checked out svn repo
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sunshine/repos/svn_repo.rb', line 19 def self.get_info path=".", shell=nil shell ||= Sunshine.shell svn_url = get_svn_url path, shell response = svn_log svn_url, shell info = {} info[:url] = svn_url info[:revision] = response.match(/revision="(.*)">/)[1] info[:committer] = response.match(/<author>(.*)<\/author>/)[1] info[:date] = Time.parse response.match(/<date>(.*)<\/date>/)[1] info[:message] = response.match(/<msg>(.*)<\/msg>/m)[1] info[:branch] = svn_url.split("/").last info rescue => e raise RepoError, e end |
.get_svn_url(path, shell) ⇒ Object
Get the svn url from a svn or git-svn checkout.
59 60 61 62 |
# File 'lib/sunshine/repos/svn_repo.rb', line 59 def self.get_svn_url path, shell cmd = git_svn?(path) ? "git svn" : "svn" shell.call("cd #{path} && #{cmd} info | grep ^URL:").split(" ")[1] end |
.git_svn?(path = ".") ⇒ Boolean
Check if this is a git-svn repo.
51 52 53 |
# File 'lib/sunshine/repos/svn_repo.rb', line 51 def self.git_svn? path="." File.exist? File.join(path, ".git/svn") end |
.svn_log(path, shell) ⇒ Object
Returns the svn logs as xml.
43 44 45 |
# File 'lib/sunshine/repos/svn_repo.rb', line 43 def self.svn_log path, shell shell.call "svn log #{path} --limit 1 --xml" end |
.valid?(path = ".") ⇒ Boolean
Check if this is an svn repo
11 12 13 |
# File 'lib/sunshine/repos/svn_repo.rb', line 11 def self.valid? path="." git_svn?(path) || File.exist?(File.join(path, ".svn")) end |
Instance Method Details
#do_checkout(path, shell) ⇒ Object
65 66 67 |
# File 'lib/sunshine/repos/svn_repo.rb', line 65 def do_checkout path, shell shell.call "svn checkout #{scm_flags} #{@url} #{path}" end |
#name ⇒ Object
72 73 74 75 76 |
# File 'lib/sunshine/repos/svn_repo.rb', line 72 def name @url.match(NAME_MATCH)[2] rescue raise RepoError, "Svn url must match #{NAME_MATCH.inspect}" end |