Class: Rudy::SCM::SVN
- Inherits:
-
Object
- Object
- Rudy::SCM::SVN
- Defined in:
- lib/rudy/scm/svn.rb
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
Returns the value of attribute base_uri.
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
Class Method Summary collapse
-
.clean_working_copy?(path = Dir.pwd) ⇒ Boolean
Are all local changes committed?.
- .working_copy?(path = Dir.pwd) ⇒ Boolean
Instance Method Summary collapse
- #clean_working_copy? ⇒ Boolean
- #create_release(username = nil, msg = nil) ⇒ Object
- #engine ⇒ Object
-
#find_next_rtag(username = nil) ⇒ Object
rel-2009-03-05-user-rev.
-
#initialize(args = {}) ⇒ SVN
constructor
A new instance of SVN.
- #liner_note ⇒ Object
- #local_info ⇒ Object
- #raise_early_exceptions ⇒ Object
- #switch_working_copy(tag) ⇒ Object
- #valid_rtag?(uri) ⇒ Boolean
- #working_copy? ⇒ Boolean
Constructor Details
#initialize(args = {}) ⇒ SVN
Returns a new instance of SVN.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rudy/scm/svn.rb', line 11 def initialize(args={}) args = { :privatekey => nil, :base_uri => nil, :user => :root, :changes => :enforce, :path => nil }.merge(args) @base_uri, @path = args[:base_uri], args[:path] @user, @pkey, @changes = args[:user], args[:privatekey], args[:changes] end |
Instance Attribute Details
#base_uri ⇒ Object
Returns the value of attribute base_uri.
7 8 9 |
# File 'lib/rudy/scm/svn.rb', line 7 def base_uri @base_uri end |
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
9 10 11 |
# File 'lib/rudy/scm/svn.rb', line 9 def changes @changes end |
Class Method Details
.clean_working_copy?(path = Dir.pwd) ⇒ Boolean
Are all local changes committed?
80 81 82 |
# File 'lib/rudy/scm/svn.rb', line 80 def self.clean_working_copy?(path=Dir.pwd) Rye.shell(:svn, 'diff', '.').stdout == [] end |
.working_copy?(path = Dir.pwd) ⇒ Boolean
85 86 87 |
# File 'lib/rudy/scm/svn.rb', line 85 def self.working_copy?(path=Dir.pwd) (File.exists?(File.join(path, '.svn'))) end |
Instance Method Details
#clean_working_copy? ⇒ Boolean
83 |
# File 'lib/rudy/scm/svn.rb', line 83 def clean_working_copy?; SVN.clean_working_copy?; end |
#create_release(username = nil, msg = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rudy/scm/svn.rb', line 29 def create_release(username=nil, msg=nil) local_uri, local_revision = local_info rtag = find_next_rtag(username) release_uri = "#{@base_uri}/#{rtag}" msg ||= 'Another Release by Rudy!' msg.tr!("'", "\\'") cmd = "svn copy -m '#{msg}' #{local_uri} #{release_uri}" `#{cmd} 2>&1` release_uri end |
#engine ⇒ Object
23 |
# File 'lib/rudy/scm/svn.rb', line 23 def engine; :svn; end |
#find_next_rtag(username = nil) ⇒ Object
rel-2009-03-05-user-rev
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rudy/scm/svn.rb', line 48 def find_next_rtag(username=nil) now = Time.now mon = now.mon.to_s.rjust(2, '0') day = now.day.to_s.rjust(2, '0') rev = "01" criteria = ['rel', now.year, mon, day, rev] criteria.insert(-2, username) if username tag = criteria.join(Rudy::DELIM) # Keep incrementing the revision number until we find the next one. tag.succ! while (valid_rtag?("#{@base_uri}/#{tag}")) tag end |
#liner_note ⇒ Object
25 26 27 |
# File 'lib/rudy/scm/svn.rb', line 25 def liner_note "%-40s (svn:%s:%s)" % [@rtag, @base_uri, @branch] end |
#local_info ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/rudy/scm/svn.rb', line 61 def local_info ret = Rye.shell(:svn, "info").join # URL: http://some/uri/path # Repository Root: http://some/uri # Repository UUID: c5abe49d-53e4-4ea3-9314-89e1e25aa7e1 # Revision: 921 ret.scan(/URL: (http:.+?)\s*\n.+Revision: (\d+)/m).flatten end |
#raise_early_exceptions ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/rudy/scm/svn.rb', line 91 def raise_early_exceptions raise NotAWorkingCopy, :svn unless working_copy? raise DirtyWorkingCopy, :svn unless @changes.to_s == 'ignore' || clean_working_copy? #raise NoRemoteURI, "remote.#{@remote}.url not set" if get_remote_uri.nil? raise NoRemotePath, :svn if @path.nil? raise PrivateKeyNotFound, @pkey if @pkey && !File.exists?(@pkey) find_next_rtag # will raise exception is there's a problem # We can't check stuff that requires access to the machine b/c the # machine may not be running yet. These include: # * Remote checkout path already exists # * No git available # ... # If create_remote_checkout should fail, it should print a message # about the release that was created and how to install it manually end |
#switch_working_copy(tag) ⇒ Object
42 43 44 45 |
# File 'lib/rudy/scm/svn.rb', line 42 def switch_working_copy(tag) raise "Invalid release tag (#{tag})." unless valid_rtag?(tag) `svn switch #{tag}` end |
#valid_rtag?(uri) ⇒ Boolean
74 75 76 77 |
# File 'lib/rudy/scm/svn.rb', line 74 def valid_rtag?(uri) ret = `svn info #{uri} 2>&1` || '' # Valid SVN URIs will return some info (ret =~ /Repository UUID/) ? true : false end |
#working_copy? ⇒ Boolean
70 71 72 |
# File 'lib/rudy/scm/svn.rb', line 70 def working_copy?(path) (File.exists?(File.join(path, '.svn'))) end |