Skip to content

Commit

Permalink
Protocol version 30 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua B. Bussdieker committed Mar 30, 2015
1 parent 60932c5 commit e93e997
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--color
--format doc --color
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ script: 'rake spec'
matrix:
fast_finish: true
include:
# - rvm: 1.9.3
# env: RSYNC_VERSION="2.6.9"
- rvm: 1.9.3
env: RSYNC_VERSION="2.6.9"
- rvm: 1.9.3
env: RSYNC_VERSION="3.0.9"
- rvm: 1.9.3
env: RSYNC_VERSION="3.1.1"

# - rvm: 2.0.0
# env: RSYNC_VERSION="2.6.9"
- rvm: 2.0.0
env: RSYNC_VERSION="2.6.9"
- rvm: 2.0.0
env: RSYNC_VERSION="3.0.9"
- rvm: 2.0.0
env: RSYNC_VERSION="3.1.1"

# - rvm: 2.1.2
# env: RSYNC_VERSION="2.6.9"
- rvm: 2.1.2
env: RSYNC_VERSION="2.6.9"
- rvm: 2.1.2
env: RSYNC_VERSION="3.0.9"
- rvm: 2.1.2
Expand Down
12 changes: 12 additions & 0 deletions lib/rsync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@ def self.run(source, destination, args = [], &block)
yield(result) if block_given?
result
end

def self.protocol
result = Command.run(nil, nil, "--version")
result.instance_eval { @raw }.split("\n").first.match(/protocol version (\d+)/)
$1
end

def self.version
result = Command.run(nil, nil, "--version")
result.instance_eval { @raw }.split("\n").first.match(/(\d+\.\d+\.\d+)/)
$1
end
end
17 changes: 13 additions & 4 deletions lib/rsync/change.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ module Rsync
# :unknown
# :changed
class Change
def initialize(data)
def initialize(data, version = 30)
@data = data
@version = version
end

# The filename associated with this change.
# @return [String]
def filename
@data[12..-1]
if @version > 29
@data[12..-1]
else
@data[10..-1]
end
end

# Whether the file was changed or not.
Expand Down Expand Up @@ -92,13 +97,17 @@ def group
# The change, if any, to the file ACL.
# @return [Symbol]
def acl
attribute_prop(9)
if @version > 29
attribute_prop(9)
end
end

# The change, if any, to the file's extended attributes.
# @return [Symbol]
def ext_attr
attribute_prop(10)
if @version > 29
attribute_prop(10)
end
end

# @!endgroup
Expand Down
5 changes: 4 additions & 1 deletion lib/rsync/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ def change_list
@raw.split("\n").each do |line|
#if line =~ /^([<>ch.*][fdLDS][ .+\?cstTpoguax]{9}) (.*)$/
if line =~ /^([<>ch+\.\*].{10}) (.*)$/
detail = Change.new(line)
detail = Change.new(line, 30)
list << detail if detail.changed?
elsif line =~ /^([<>ch+\.\*].{8}) (.*)$/
detail = Change.new(line, 29)
list << detail if detail.changed?
end
end
Expand Down
23 changes: 18 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@
spec.before(:suite) do
if ENV["RSYNC_VERSION"]
version = ENV["RSYNC_VERSION"] || "2.6.9"
puts `rm -rf tmp && mkdir tmp`
puts `cd tmp && wget https://download.samba.org/pub/rsync/src/rsync-#{version}.tar.gz`
puts `cd tmp && tar zxvf rsync-#{version}.tar.gz`
puts `cd tmp/rsync-#{version} && ./configure`
puts `cd tmp/rsync-#{version} && make`

unless File.exists? "tmp"
puts `mkdir -p tmp`
end

unless File.exists? "tmp/rsync-#{version}.tar.gz"
puts `cd tmp && wget https://download.samba.org/pub/rsync/src/rsync-#{version}.tar.gz`
end

unless File.exists? "tmp/rsync-#{version}"
puts `cd tmp && tar zxvf rsync-#{version}.tar.gz`
end

unless File.exists? "tmp/rsync-#{version}/rsync"
puts `cd tmp/rsync-#{version} && ./configure`
puts `cd tmp/rsync-#{version} && make`
end

puts `tmp/rsync-#{version}/rsync --version`
Rsync::Command.command = "tmp/rsync-#{version}/rsync"
end
Expand Down

0 comments on commit e93e997

Please sign in to comment.