Class: SvnAuto::SvnExternals
- Inherits:
-
Object
- Object
- SvnAuto::SvnExternals
- Defined in:
- lib/svnauto/svn_externals.rb
Constant Summary collapse
- SVN_EXT =
'svn:externals'
- SVNAUTO_LOCKED =
'sc:locked'
Instance Attribute Summary collapse
-
#locked ⇒ Object
readonly
Returns the value of attribute locked.
-
#unlocked ⇒ Object
readonly
Returns the value of attribute unlocked.
Instance Method Summary collapse
-
#initialize(directories = [], recursive = true) ⇒ SvnExternals
constructor
A new instance of SvnExternals.
- #lock ⇒ Object
- #unlock ⇒ Object
Constructor Details
#initialize(directories = [], recursive = true) ⇒ SvnExternals
Returns a new instance of SvnExternals.
39 40 41 42 43 44 45 46 |
# File 'lib/svnauto/svn_externals.rb', line 39 def initialize (directories=[], recursive=true) if directories.empty? Dir.foreach('.') {|f| directories << f if f[0,1] != '.' and File.directory?(f)} end fetch_unlocked(directories, recursive) fetch_locked(directories, recursive) end |
Instance Attribute Details
#locked ⇒ Object (readonly)
Returns the value of attribute locked.
36 37 38 |
# File 'lib/svnauto/svn_externals.rb', line 36 def locked @locked end |
#unlocked ⇒ Object (readonly)
Returns the value of attribute unlocked.
35 36 37 |
# File 'lib/svnauto/svn_externals.rb', line 35 def unlocked @unlocked end |
Instance Method Details
#lock ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/svnauto/svn_externals.rb', line 49 def lock affected_parents = Set.new @unlocked.each do |external| affected_parents << File.dirname(external.path) @locked << external FileUtils.rm_r(external.path) Svn.export('-r', external.revision, external.url, external.path) Svn.add(external.path) end @unlocked.clear update_properties_for(affected_parents) short_parents = affected_parents.to_a Svn.commit('-m', "#{Constants::ME}: updated lock properties for #{short_parents.join(', ')}", *short_parents) end |
#unlock ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/svnauto/svn_externals.rb', line 69 def unlock affected_parents = Set.new @locked.each do |external| affected_parents << File.dirname(external.path) @unlocked << external Svn.delete(external.path) Svn.commit('-m', "#{Constants::ME}: switch #{external.path} from locked to unlocked", external.path) FileUtils.rm_rf(external.path) end @locked.clear update_properties_for(affected_parents) short_parents = affected_parents.to_a Svn.update(*short_parents) Svn.commit('-m', "#{Constants::ME}: updated lock properties for #{short_parents.join(', ')}", *short_parents) end |