svn_command_helper 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/svn_command_helper.rb +52 -13
- data/lib/svn_command_helper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59081bc6e3dc4a9dd6ea552f99923714a875c4cb
|
4
|
+
data.tar.gz: 1a9e7d17a23e855f54c4c25f61138a93f4144949
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19d200ce20613cc3e9bf8ae0653a5956f489a7bd3f14c4dd464be8b7ee7230f3a5d2404b5e4dd40dc1ec5d6abc2b2ecf7801657d35ca9f018971d38a8c02a743
|
7
|
+
data.tar.gz: 38b2e7071caf9f4c9cbedc7b7e2570a783c0b137f14adda9bbd60b45f1473715c712c9db1527d1d89ec9053aac1b6b20fc3a7f4b7b9237d215c9406a870572e9
|
data/lib/svn_command_helper.rb
CHANGED
@@ -3,7 +3,6 @@ require 'pathname'
|
|
3
3
|
require 'yaml'
|
4
4
|
require 'time'
|
5
5
|
require 'tmpdir'
|
6
|
-
require 'ostruct'
|
7
6
|
require 'libxml'
|
8
7
|
require "system_command_helper"
|
9
8
|
|
@@ -31,7 +30,7 @@ module SvnCommandHelper
|
|
31
30
|
# svn list
|
32
31
|
# @param [uri string like] uri target uri
|
33
32
|
# @param [Boolean] recursive --recursive
|
34
|
-
# @return [Array<
|
33
|
+
# @return [Array<ListItem>] paths
|
35
34
|
def list(uri, recursive = false)
|
36
35
|
if @list_cache && @list_cache[recursive][uri]
|
37
36
|
@list_cache[recursive][uri]
|
@@ -39,19 +38,30 @@ module SvnCommandHelper
|
|
39
38
|
list_str = cap("svn list --xml #{recursive ? '-R' : ''} #{uri}")
|
40
39
|
list = LibXML::XML::Document.string(list_str).find("//lists/list/entry").map do |entry|
|
41
40
|
commit = entry.find_first("commit")
|
42
|
-
|
41
|
+
ListItem.new(
|
43
42
|
kind: entry["kind"],
|
44
43
|
path: entry.find_first("name").content,
|
45
44
|
revision: commit["revision"].to_i,
|
46
45
|
author: commit.find_first("author").content,
|
47
|
-
date: Time.iso8601(commit.find_first("date").content)
|
48
|
-
|
46
|
+
date: Time.iso8601(commit.find_first("date").content)
|
47
|
+
)
|
49
48
|
end
|
50
49
|
@list_cache[recursive][uri] = list if @list_cache
|
51
50
|
list
|
52
51
|
end
|
53
52
|
end
|
54
53
|
|
54
|
+
class ListItem
|
55
|
+
attr_reader :kind, :path, :revision, :author, :date
|
56
|
+
def initialize(kind:, path:, revision:, author:, date:)
|
57
|
+
@kind = kind
|
58
|
+
@path = path
|
59
|
+
@revision = revision
|
60
|
+
@author = author
|
61
|
+
@date = date
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
55
65
|
# svn list --recursive
|
56
66
|
# @param [uri string like] uri target uri
|
57
67
|
# @return [Array<String>] paths
|
@@ -108,19 +118,29 @@ module SvnCommandHelper
|
|
108
118
|
# @param [uri string like] uri target uri
|
109
119
|
# @param [Integer] limit --limit
|
110
120
|
# @param [Boolean] stop_on_copy --stop-on-copy
|
111
|
-
# @return [Array<
|
121
|
+
# @return [Array<LogItem>] log (old to new order)
|
112
122
|
def log(uri = ".", limit: nil, stop_on_copy: false)
|
113
123
|
log = cap "svn log --xml #{limit ? "--limit #{limit}" : ""} #{stop_on_copy ? "--stop-on-copy" : ""} #{uri}"
|
114
124
|
LibXML::XML::Document.string(log).find("//log/logentry").map do |entry|
|
115
|
-
|
125
|
+
LogItem.new(
|
116
126
|
revision: entry["revision"].to_i,
|
117
127
|
author: entry.find_first("author").content,
|
118
128
|
date: Time.iso8601(entry.find_first("date").content),
|
119
|
-
msg: entry.find_first("msg").content
|
120
|
-
|
129
|
+
msg: entry.find_first("msg").content
|
130
|
+
)
|
121
131
|
end.reverse
|
122
132
|
end
|
123
133
|
|
134
|
+
class LogItem
|
135
|
+
attr_reader :revision, :author, :date, :msg
|
136
|
+
def initialize(revision:, author:, date:, msg:)
|
137
|
+
@revision = revision
|
138
|
+
@author = author
|
139
|
+
@date = date
|
140
|
+
@msg = msg
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
124
144
|
# head revision of uri
|
125
145
|
# @param [uri string like] uri target uri
|
126
146
|
# return [Integer] revision number
|
@@ -208,7 +228,15 @@ module SvnCommandHelper
|
|
208
228
|
def merge_dry_run(command)
|
209
229
|
cap("#{command} --dry-run")
|
210
230
|
.each_line.map(&:chomp).reject {|line| line[4] != " "}
|
211
|
-
.map {|line|
|
231
|
+
.map {|line| MergeStatusItem.new(status: line[0...4], path: line[5..-1])}
|
232
|
+
end
|
233
|
+
|
234
|
+
class MergeStatusItem
|
235
|
+
attr_reader :status, :path
|
236
|
+
def initialize(status:, path:)
|
237
|
+
@status = status
|
238
|
+
@path = path
|
239
|
+
end
|
212
240
|
end
|
213
241
|
|
214
242
|
# svn merge branch to trunk with detecting revision range
|
@@ -298,12 +326,12 @@ module SvnCommandHelper
|
|
298
326
|
|
299
327
|
diff_str = cap("svn diff --xml --summarize #{from_uri} #{to_uri} #{options.join(' ')}")
|
300
328
|
diff_list = LibXML::XML::Document.string(diff_str).find("//diff/paths/path").map do |path|
|
301
|
-
|
329
|
+
DiffItem.new(
|
302
330
|
kind: path["kind"],
|
303
331
|
item: path["item"],
|
304
332
|
props: path["props"],
|
305
|
-
path: path.content
|
306
|
-
|
333
|
+
path: path.content
|
334
|
+
)
|
307
335
|
end
|
308
336
|
if ignore_properties
|
309
337
|
diff_list.reject! {|diff| diff.item == "none"}
|
@@ -323,6 +351,17 @@ module SvnCommandHelper
|
|
323
351
|
diff_list
|
324
352
|
end
|
325
353
|
|
354
|
+
class DiffItem
|
355
|
+
attr_reader :kind, :item, :props, :path
|
356
|
+
attr_accessor :from, :to
|
357
|
+
def initialize(kind:, item:, props:, path:)
|
358
|
+
@kind = kind
|
359
|
+
@item = item
|
360
|
+
@props = props
|
361
|
+
@path = path
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
326
365
|
# copy single transaction
|
327
366
|
# @param [SvnFileCopyTransaction] transaction from and to info
|
328
367
|
# @param [String] message commit message
|