svn_command_helper 0.2.1 → 0.3.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: b45cbe266b3a6d3c4fc40a117ac61f4f19e0dd35
4
- data.tar.gz: 29ce35786e269289f29ce2305c18d3629e75b43d
3
+ metadata.gz: 08e6ecccdfe2018f71d749bc767719708883b5b3
4
+ data.tar.gz: 2641caaef4a51f1642e4de3ae3978fbffe8c52ea
5
5
  SHA512:
6
- metadata.gz: 2676ee2fc987e8ef387dadaffe7de5867381705e0e57900ba268ba24775fe6c7a727b79dae4287bcaa9d04293c2bbba10a32e6cb379e240f86bf62b5dfc52386
7
- data.tar.gz: 17a536322cd7e7926f71be69bd48268bf6f3ddd74f43f06312b61a18a2920086df0ae693dbe35360045b99319bb52372a292dc13a538f324471b7f28af73366c
6
+ metadata.gz: 2a042a4d4246f38e2a7a0999ab118131608d94720c2c15d6b62c7775d1b2e2f8c29cae8d1460a97eb36266cf7424e3f913e0c8c9fa1cf82616496e07d4a5314e
7
+ data.tar.gz: a6dd2895b0cde7d0538c8e1fc5cda120aa6e465127fe45dbb9f838ee77eb4fef587f7d1fc0ee8e15341c0c177fce55b944da690f8bcdfe7efcf165a266d6ee71
@@ -1,4 +1,4 @@
1
1
  module SvnCommandHelper
2
2
  # version
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
@@ -1,6 +1,9 @@
1
1
  require "svn_command_helper/version"
2
2
  require 'pathname'
3
3
  require 'yaml'
4
+ require 'time'
5
+ require 'ostruct'
6
+ require 'rexml/document'
4
7
  require "system_command_helper"
5
8
 
6
9
  # Subversion command helper
@@ -78,6 +81,37 @@ module SvnCommandHelper
78
81
  sys "svn update #{depth ? "--set-depth #{depth}" : ""} #{path}"
79
82
  end
80
83
 
84
+ # svn log
85
+ # @param [uri string like] uri target uri
86
+ # @param [Integer] limit --limit
87
+ # @param [Boolean] stop_on_copy --stop-on-copy
88
+ # @return [Array<OpenStruct>] log (old to new order)
89
+ def log(uri = ".", limit: nil, stop_on_copy: false)
90
+ log = cap "svn log --xml #{limit ? "--limit #{limit}" : ""} #{stop_on_copy ? "--stop-on-copy" : ""} #{uri}"
91
+ REXML::Document.new(log).elements.collect("/log/logentry") do |entry|
92
+ OpenStruct.new({
93
+ revision: entry.attribute("revision").value.to_i,
94
+ author: entry.elements["author"].text,
95
+ date: Time.iso8601(entry.elements["date"].text),
96
+ msg: entry.elements["msg"].text,
97
+ })
98
+ end.reverse
99
+ end
100
+
101
+ # head revision of uri
102
+ # @param [uri string like] uri target uri
103
+ # return [Integer] revision number
104
+ def revision(uri = ".")
105
+ log(uri, limit: 1).last.revision
106
+ end
107
+
108
+ # stop-on-copy revision of uri
109
+ # @param [uri string like] uri target uri
110
+ # return [Integer] revision number
111
+ def copied_revision(uri = ".")
112
+ log(uri, stop_on_copy: true).first.revision
113
+ end
114
+
81
115
  # svn update to deep path recursive
82
116
  # @param [path string like] path target path
83
117
  # @param [depth] depth --set-depth for only new updated dirs
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.2.1
4
+ version: 0.3.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-05-20 00:00:00.000000000 Z
11
+ date: 2016-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: system_command_helper