svn_command_helper 0.9.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a26bdb93ca25d73f166efbdab7bb537138cfa7d
4
- data.tar.gz: a155eb28315c094d96623fc1b03081e93b399d25
3
+ metadata.gz: 4bd488641380cfe1d865592138ab3b4a3ec3ed5f
4
+ data.tar.gz: def3e7693fabd85377e0a35dc060df7a9b117e57
5
5
  SHA512:
6
- metadata.gz: 0abb87870bdb2169eb1c6885a071b9914904d0b28f87380e58bc7ca15dd2b09fa71c2fd7c59dabd91551dc955c1a9e8e69430431b3fdca76e602061e38257449
7
- data.tar.gz: e05bd7035308a8b3a95f69148dcba2d8a5426ab3e29b8a6910a1a62627ad3dbdb2de8f4e5b6a82a56149ff5225d5502a9849f8e0d57208b3bdb46aea9d8f12ff
6
+ metadata.gz: 7b2f374ade28eab78bf98678c7ff189a2a926a802b16ad688b56dd78b7f2230ec6403232b52173dce525a80af8191899cbd225553c3409994ffb624a7e6f8897
7
+ data.tar.gz: 1319216bde21b959d49ff296904b44abc1b270229585dc5b699d6c7b5de185b11d813191bf261c2dca98ff53c678950198dffdb6d21540ed47448cce074badda
@@ -1,4 +1,4 @@
1
1
  module SvnCommandHelper
2
2
  # version
3
- VERSION = "0.9.2"
3
+ VERSION = "1.0.0"
4
4
  end
@@ -36,8 +36,17 @@ module SvnCommandHelper
36
36
  if @list_cache && @list_cache[uri]
37
37
  @list_cache[uri]
38
38
  else
39
- list = cap("svn list #{recursive ? '-R' : ''} #{uri}").split(/\n/).compact
40
- .reject {|path| path.empty?}
39
+ list_str = cap("svn list --xml #{recursive ? '-R' : ''} #{uri}")
40
+ list = REXML::Document.new(list_str).elements.collect("/lists/list/entry") do |entry|
41
+ commit = entry.elements["commit"]
42
+ OpenStruct.new({
43
+ kind: entry.attribute("kind").value,
44
+ path: entry.elements["name"].text,
45
+ revision: commit.attribute("revision").value.to_i,
46
+ author: commit.elements["author"].text,
47
+ date: Time.iso8601(commit.elements["date"].text),
48
+ })
49
+ end
41
50
  @list_cache[uri] = list if @list_cache
42
51
  list
43
52
  end
@@ -55,7 +64,7 @@ module SvnCommandHelper
55
64
  # @param [Boolean] recursive --recursive
56
65
  # @return [Array<String>] file paths
57
66
  def list_files(uri, recursive = false)
58
- list(uri, recursive).reject {|path| path.end_with?("/")} # dir
67
+ list(uri, recursive).select {|entry| entry.kind == "file"}
59
68
  end
60
69
 
61
70
  # svn list --recursive -> grep only files
@@ -77,7 +86,7 @@ module SvnCommandHelper
77
86
  # @return [Boolean] true if exists
78
87
  def exist?(uri)
79
88
  basename = File.basename(uri)
80
- list(File.dirname(uri)).find{|_basename| File.fnmatch(basename, _basename.sub(/\/$/, ''))}
89
+ !list(File.dirname(uri)).find{|entry| File.fnmatch(basename, entry.path)}.nil?
81
90
  end
82
91
 
83
92
  # check svn uri file exists or not
@@ -85,7 +94,7 @@ module SvnCommandHelper
85
94
  # @return [Boolean] true if exists
86
95
  def exist_file?(uri)
87
96
  file = File.basename(uri)
88
- list_files(File.dirname(uri)).find{|_file| File.fnmatch(file, _file)}
97
+ !list_files(File.dirname(uri)).find{|entry| File.fnmatch(file, entry.path)}.nil?
89
98
  end
90
99
 
91
100
  # svn update
@@ -276,8 +285,8 @@ module SvnCommandHelper
276
285
  def copy_single(transaction, message, recursive = false)
277
286
  transactions = transaction.glob_transactions(recursive)
278
287
  raise "copy_single: #{transaction.from} not exists" if transactions.empty?
279
- to_exist_transactions = Svn.list_files(transaction.to_base).map do |_file|
280
- transactions.find {|_transaction| _transaction.file == _file}
288
+ to_exist_transactions = Svn.list_files(transaction.to_base).map do |entry|
289
+ transactions.find {|_transaction| _transaction.file == entry.path}
281
290
  end.compact
282
291
  only_from_transactions = transactions - to_exist_transactions
283
292
  if to_exist_transactions.empty? # toにファイルがない
@@ -384,8 +393,8 @@ module SvnCommandHelper
384
393
  # @return [Array<SvnFileCopyTransaction>] transactions
385
394
  def glob_transactions(recursive = false)
386
395
  Svn.list_files(@from_base, recursive)
387
- .select{|_file| File.fnmatch(@file, _file)}
388
- .map{|_file| SvnFileCopyTransaction.new(from_base: @from_base, to_base: @to_base, file: _file)}
396
+ .select{|entry| File.fnmatch(@file, entry.path)}
397
+ .map{|entry| SvnFileCopyTransaction.new(from_base: @from_base, to_base: @to_base, file: entry.path)}
389
398
  end
390
399
 
391
400
  # from uri exists?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svn_command_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Narazaka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-21 00:00:00.000000000 Z
11
+ date: 2016-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: system_command_helper