svn_project 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +12 -0
- data/README +79 -0
- data/Rakefile +14 -0
- data/lib/svn/project.rb +210 -0
- data/lib/svn/rake/svntask.rb +125 -0
- data/lib/svn/release_tag.rb +78 -0
- data/lib/svn.rb +14 -0
- data/spec/svn_integration_spec.rb +63 -0
- data/spec/svn_project_spec.rb +116 -0
- data/spec/svn_release_tag_spec.rb +85 -0
- data/spec/svn_spec.rb +16 -0
- data/svn_project.gemspec +34 -0
- data/tasks/svn_project.rake +10 -0
- metadata +84 -0
data/Manifest
ADDED
data/README
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
= SVN::Project
|
2
|
+
|
3
|
+
Class encapsulating methods for various svn:tags Rake tasks.
|
4
|
+
|
5
|
+
To use these methods, add the below directives to your rakefile. This library assumes
|
6
|
+
that you are working with a project that has already been checked into svn.
|
7
|
+
|
8
|
+
|
9
|
+
require 'svn/rake/svntask'
|
10
|
+
Rake::SVN::ProjectTasks.new() do |s|
|
11
|
+
s.method = "http"
|
12
|
+
s.username = "jeff"
|
13
|
+
s.project_url = "/one/two/three/go"
|
14
|
+
s.svn_cmd = "/path/to/svn" # optional
|
15
|
+
s.always_update_current = true # optional (maintains a tag 'current' pointing to your most numerically recent tag)
|
16
|
+
s.current_name = "some_name" # options (uses 'some_name' as the name of your 'current' tag)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
You can now use the following tasks in your svn project:
|
21
|
+
|
22
|
+
|
23
|
+
- svn:project:current_version #=> Display most current version of the project
|
24
|
+
- svn:project:tags_url #=> Display URL for the project's TAGS dir
|
25
|
+
- svn:project:trunk_url #=> Display URL for the project's TRUNK dir
|
26
|
+
- svn:project:url #=> Displays URL for project
|
27
|
+
- svn:tags:create_fix #=> Create tag for a fix release
|
28
|
+
- svn:tags:create_major #=> Create tag for a major release
|
29
|
+
- svn:tags:create_minor #=> Create tag for a minor release
|
30
|
+
- svn:tags:current #=> Current release tag
|
31
|
+
- svn:tags:list #=> Display all release tags in the tags dir
|
32
|
+
- svn:tags:list_all #=> Display all tags in the tags dir
|
33
|
+
- svn:tags:list_releases #=> Display all release tags in the tags dir
|
34
|
+
- svn:tags:ls #=> Display all release tags in the tags dir
|
35
|
+
- svn:tags:next_fix #=> Display next fix release tag
|
36
|
+
- svn:tags:next_major #=> Display next major release tag
|
37
|
+
- svn:tags:next_minor #=> Display next minor release tag
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
== Example Usage
|
42
|
+
To get the current release tag:
|
43
|
+
|
44
|
+
rake svn:tags:current #=> rel-0.0.1
|
45
|
+
|
46
|
+
To get the current version
|
47
|
+
|
48
|
+
rake svn:project:current_version #=> 0.0.1
|
49
|
+
|
50
|
+
To create a new minor release:
|
51
|
+
|
52
|
+
rake svn:tags:create_minor
|
53
|
+
#=> Created rel-0.1.0 tag
|
54
|
+
|
55
|
+
To see all the tags:
|
56
|
+
|
57
|
+
rake svn:tags:ls
|
58
|
+
#=> rel-0.0.1
|
59
|
+
rel-0.1.0
|
60
|
+
rel-1.0.0
|
61
|
+
|
62
|
+
|
63
|
+
== Version Numbering
|
64
|
+
|
65
|
+
Versions are of the form major.minor.fix
|
66
|
+
|
67
|
+
* a fix version does not add functionality, but corrrects some defect
|
68
|
+
* a minor version adds a small amount of functionality
|
69
|
+
* a major version adds a relatively large amount of functionallity
|
70
|
+
|
71
|
+
The difference between major and minor is subjective and will usually be
|
72
|
+
determined by the customer.
|
73
|
+
|
74
|
+
When minor or major are incremented, all numbers to the right are set to "0"
|
75
|
+
|
76
|
+
The version after 1.0.9 is 1.0.10
|
77
|
+
|
78
|
+
The task svn:tags:ls sorts release tags correctly.
|
79
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('svn_project', '0.6.1') do |p|
|
6
|
+
p.description = "Adds rake tasks for viewing/creating svn tags"
|
7
|
+
p.url = "http://http://svnproj.rubyforge.org"
|
8
|
+
p.author = "Steven Hansen"
|
9
|
+
p.email = "runner@berkeley.edu"
|
10
|
+
p.ignore_pattern = ["svn_user.yml", "svn_project.rake"]
|
11
|
+
p.project = "svnproj"
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/lib/svn/project.rb
ADDED
@@ -0,0 +1,210 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module SVN
|
4
|
+
class Project
|
5
|
+
|
6
|
+
class MissingConnectionParamException < Exception; end
|
7
|
+
class MissingSVNClientException < Exception; end
|
8
|
+
|
9
|
+
REQUIRED_CONNECTION_PARAMS = [:project_url, :username, :method]
|
10
|
+
VERSION_FILE_NAME = "version.yml"
|
11
|
+
|
12
|
+
attr_accessor :project_url, :method, :username, :svn_cmd
|
13
|
+
attr_writer :always_update_current, :current_name
|
14
|
+
|
15
|
+
|
16
|
+
def initialize()
|
17
|
+
if block_given?
|
18
|
+
yield(self)
|
19
|
+
self.validate_connection_params!
|
20
|
+
else
|
21
|
+
self.try_auto_configure!
|
22
|
+
end
|
23
|
+
|
24
|
+
raise_if_svn_cmd_not_available!
|
25
|
+
end
|
26
|
+
|
27
|
+
def always_update_current?
|
28
|
+
@always_update_current ||= false
|
29
|
+
end
|
30
|
+
|
31
|
+
def current_name
|
32
|
+
@current_name ||= "current"
|
33
|
+
end
|
34
|
+
|
35
|
+
def svn_cmd
|
36
|
+
@svn_cmd ||= SVN.svn_cmd
|
37
|
+
end
|
38
|
+
|
39
|
+
def trunk_url
|
40
|
+
@trunk_url ||= "#{project_url}/trunk"
|
41
|
+
end
|
42
|
+
|
43
|
+
def tags_url
|
44
|
+
@tags_url ||= "#{project_url}/tags"
|
45
|
+
end
|
46
|
+
|
47
|
+
# displays a list of 'release' tags in the tags_url directory
|
48
|
+
def list_release_tags
|
49
|
+
release_tags
|
50
|
+
end
|
51
|
+
alias :list_tags :list_release_tags
|
52
|
+
alias :ls :list_release_tags
|
53
|
+
|
54
|
+
# returns an array of ReleaseTag objects from the tags_url directory
|
55
|
+
def release_tags
|
56
|
+
tags = retrieve_tags.select { |tag| SVN::ReleaseTag.release_tag?(tag) }
|
57
|
+
tags = tags.map { |tag| SVN::ReleaseTag.new(tag) }.sort
|
58
|
+
tags = [SVN::ReleaseTag.new("rel-0.0.0")] if tags.empty?
|
59
|
+
tags
|
60
|
+
end
|
61
|
+
|
62
|
+
# displays a list of 'all' the tags in the tags_url directory
|
63
|
+
def list_all_tags
|
64
|
+
retrieve_tags
|
65
|
+
end
|
66
|
+
|
67
|
+
# Display the current version of the project
|
68
|
+
def current_version
|
69
|
+
current_tag.name.delete("rel-")
|
70
|
+
end
|
71
|
+
|
72
|
+
# Display the current tag
|
73
|
+
def current_tag
|
74
|
+
release_tags.last
|
75
|
+
end
|
76
|
+
|
77
|
+
# Display the next major release tag
|
78
|
+
#
|
79
|
+
# rake svn:current_tag #=> rel-1.1.1
|
80
|
+
# rake svn:next_major_tag # => rel-2.0.0
|
81
|
+
def next_major_tag
|
82
|
+
current_tag.next_major
|
83
|
+
end
|
84
|
+
|
85
|
+
# Display the next minor release tag
|
86
|
+
#
|
87
|
+
# rake svn:current_tag #=> rel-1.1.1
|
88
|
+
# rake svn:next_minor_tag # => rel-1.2.0
|
89
|
+
def next_minor_tag
|
90
|
+
current_tag.next_minor
|
91
|
+
end
|
92
|
+
|
93
|
+
# Display the next fix release tag
|
94
|
+
#
|
95
|
+
# rake svn:current_tag #=> rel-1.1.1
|
96
|
+
# rake svn:next_fix_tag # => rel-1.1.2
|
97
|
+
def next_fix_tag
|
98
|
+
current_tag.next_fix
|
99
|
+
end
|
100
|
+
|
101
|
+
# Create the next major release tag
|
102
|
+
#
|
103
|
+
# rake svn:current_tag #=> rel-1.1.1
|
104
|
+
# rake svn:next_major_tag # => rel-2.0.0
|
105
|
+
# rake svn:create_major_tag
|
106
|
+
# rake svn:current_tag #=> rel-2.0.0
|
107
|
+
def create_major_tag
|
108
|
+
create_tag(current_tag.next_major)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Create the next minor release tag
|
112
|
+
#
|
113
|
+
# rake svn:current_tag #=> rel-1.1.1
|
114
|
+
# rake svn:next_minor_tag # => rel-1.2.0
|
115
|
+
# rake svn:create_minor_tag
|
116
|
+
# rake svn:current_tag #=> rel-1.2.0
|
117
|
+
def create_minor_tag
|
118
|
+
create_tag(current_tag.next_minor)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Create the next fix release tag
|
122
|
+
#
|
123
|
+
# rake svn:current_tag #=> rel-1.1.1
|
124
|
+
# rake svn:next_fix_tag # => rel-1.1.2
|
125
|
+
# rake svn:create_fix_tag
|
126
|
+
# rake svn:current_tag #=> rel-1.1.2
|
127
|
+
def create_fix_tag
|
128
|
+
create_tag(current_tag.next_fix)
|
129
|
+
end
|
130
|
+
|
131
|
+
def validate_connection_params!
|
132
|
+
REQUIRED_CONNECTION_PARAMS.each do |param|
|
133
|
+
raise MissingConnectionParamException, "Missing required config parameter: #{param}" if self.send(param).nil?
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def try_auto_configure!
|
138
|
+
url = `#{SVN.svn_cmd} info`.split("\n")[1].split(" ")[1]
|
139
|
+
# extremely inefficient regular expression!
|
140
|
+
/(\S+):\/\/(\S+)@(\S+)\/trunk\S*/ =~ url
|
141
|
+
|
142
|
+
self.method = $1
|
143
|
+
self.username = $2
|
144
|
+
self.project_url = $3
|
145
|
+
self.validate_connection_params!
|
146
|
+
end
|
147
|
+
|
148
|
+
def svn_cmd_available?
|
149
|
+
if SVN.win32?
|
150
|
+
system("#{svn_cmd} --version") ? true : false
|
151
|
+
else
|
152
|
+
system("#{svn_cmd} --version > /dev/null 2>&1") ? true : false
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def raise_if_svn_cmd_not_available!
|
157
|
+
raise MissingSVNClientException, "#{self.svn_cmd} command not found" unless self.svn_cmd_available?
|
158
|
+
end
|
159
|
+
|
160
|
+
private unless $TESTING
|
161
|
+
def write_version_file(tag_name)
|
162
|
+
File.open(VERSION_FILE_NAME, "w") { |f| f.puts "version: '#{tag_name}'" }
|
163
|
+
end
|
164
|
+
|
165
|
+
def init_version_file
|
166
|
+
unless File.exists?(VERSION_FILE_NAME)
|
167
|
+
FileUtils.touch(VERSION_FILE_NAME)
|
168
|
+
cmd = "#{svn_cmd} add #{VERSION_FILE_NAME}"
|
169
|
+
`#{cmd}`
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def write_version_file_and_commit(tag_name)
|
174
|
+
init_version_file
|
175
|
+
write_version_file(tag_name)
|
176
|
+
cmd = "#{svn_cmd} ci -m 'updated #{VERSION_FILE_NAME} to #{tag_name}'"
|
177
|
+
`#{cmd}`
|
178
|
+
end
|
179
|
+
|
180
|
+
def update_current_tag(tag_name)
|
181
|
+
destroy_tag(current_name) if list_all_tags.include?(current_name)
|
182
|
+
cmd = "#{svn_cmd} -m 'updated #{tag_name} to current tag' cp #{connection_str(tags_url)}/#{tag_name} #{connection_str(tags_url)}/#{current_name}"
|
183
|
+
`#{cmd}`
|
184
|
+
end
|
185
|
+
|
186
|
+
def retrieve_tags
|
187
|
+
`#{svn_cmd} ls #{connection_str(tags_url)}`.split("\n").map do |tag|
|
188
|
+
tag.chomp('/')
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def connection_str(url)
|
193
|
+
"#{method}://#{username}@#{url}"
|
194
|
+
end
|
195
|
+
|
196
|
+
def create_tag(tag_name)
|
197
|
+
write_version_file_and_commit(tag_name)
|
198
|
+
cmd = "#{svn_cmd} -m 'tagged #{tag_name} for testing' cp #{connection_str(trunk_url)} #{connection_str(tags_url)}/#{tag_name}"
|
199
|
+
`#{cmd}`
|
200
|
+
update_current_tag(current_tag.to_s) if always_update_current?
|
201
|
+
end
|
202
|
+
|
203
|
+
def destroy_tag(tag_name)
|
204
|
+
cmd = "#{svn_cmd} -m 'removed tag #{tag_name} for testing' rm #{connection_str(tags_url)}/#{tag_name}"
|
205
|
+
`#{cmd}`
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
@@ -0,0 +1,125 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'rake/tasklib'
|
5
|
+
require 'svn'
|
6
|
+
|
7
|
+
|
8
|
+
module Rake
|
9
|
+
module SVN
|
10
|
+
|
11
|
+
class ProjectTask < TaskLib
|
12
|
+
# Name of the main, top level task. (default is :svn)
|
13
|
+
attr_accessor :name
|
14
|
+
|
15
|
+
attr_accessor :svn
|
16
|
+
|
17
|
+
# Create an SVN task named <em>svn</em>. Default task name is +svn+.
|
18
|
+
def initialize(name=:svn) # :yield: self
|
19
|
+
@name = name
|
20
|
+
if block_given?
|
21
|
+
@svn = ::SVN::Project.new { |s| yield(s) }
|
22
|
+
else
|
23
|
+
@svn = ::SVN::Project.new
|
24
|
+
end
|
25
|
+
|
26
|
+
define()
|
27
|
+
end
|
28
|
+
|
29
|
+
def svn_project
|
30
|
+
@svn
|
31
|
+
end
|
32
|
+
|
33
|
+
# Create the tasks defined by this task lib.
|
34
|
+
def define
|
35
|
+
namespace :svn do
|
36
|
+
namespace :project do
|
37
|
+
|
38
|
+
desc "Displays URL for project"
|
39
|
+
task :url do
|
40
|
+
puts svn.project_url
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Display URL for the project's TRUNK dir"
|
44
|
+
task :trunk_url do
|
45
|
+
puts svn.trunk_url
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "Display URL for the project's TAGS dir"
|
49
|
+
task :tags_url do
|
50
|
+
puts svn.tags_url
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Display most current version of the project"
|
54
|
+
task :current_version do
|
55
|
+
puts svn.current_version
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
namespace :tags do
|
60
|
+
desc "Create tag for a fix release"
|
61
|
+
task :create_fix do
|
62
|
+
svn.create_fix_tag
|
63
|
+
puts "Created #{svn.current_tag.name} tag"
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "Create tag for a minor release"
|
67
|
+
task :create_minor do
|
68
|
+
svn.create_minor_tag
|
69
|
+
puts "Created #{svn.current_tag.name} tag"
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "Create tag for a major release"
|
73
|
+
task :create_major do
|
74
|
+
svn.create_major_tag
|
75
|
+
puts "Created #{svn.current_tag.name} tag"
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "Current release tag"
|
79
|
+
task :current do
|
80
|
+
puts svn.current_tag
|
81
|
+
end
|
82
|
+
|
83
|
+
desc "Display next major release tag"
|
84
|
+
task :next_major do
|
85
|
+
puts svn.next_major_tag
|
86
|
+
end
|
87
|
+
|
88
|
+
desc "Display next minor release tag"
|
89
|
+
task :next_minor do
|
90
|
+
puts svn.next_minor_tag
|
91
|
+
end
|
92
|
+
|
93
|
+
desc "Display next fix release tag"
|
94
|
+
task :next_fix do
|
95
|
+
puts svn.next_fix_tag
|
96
|
+
end
|
97
|
+
|
98
|
+
desc "Display all tags in the tags dir"
|
99
|
+
task :list_all do
|
100
|
+
puts svn.list_all_tags
|
101
|
+
end
|
102
|
+
|
103
|
+
desc "Display all release tags in the tags dir"
|
104
|
+
task :ls do
|
105
|
+
puts svn.list_tags
|
106
|
+
end
|
107
|
+
|
108
|
+
desc "Display all release tags in the tags dir"
|
109
|
+
task :list_releases do
|
110
|
+
puts svn.list_release_tags
|
111
|
+
end
|
112
|
+
|
113
|
+
desc "Display all release tags in the tags dir"
|
114
|
+
task :list do
|
115
|
+
puts svn.list_tags
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
self
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
|
2
|
+
module SVN
|
3
|
+
class ReleaseTag
|
4
|
+
|
5
|
+
include Comparable
|
6
|
+
|
7
|
+
attr_accessor :name, :major, :minor, :fix
|
8
|
+
|
9
|
+
def initialize(tag_name)
|
10
|
+
self.class.raise_if_not_recognized_release_tag!(tag_name)
|
11
|
+
@name = tag_name
|
12
|
+
|
13
|
+
components = self.name.delete("rel-").split(".")
|
14
|
+
@major = components[0].to_i
|
15
|
+
@minor = components[1].to_i
|
16
|
+
@fix = components[2].to_i
|
17
|
+
@components = [major, minor, fix]
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
name
|
22
|
+
end
|
23
|
+
|
24
|
+
def next_major
|
25
|
+
"rel-#{next_major_component}.0.0"
|
26
|
+
end
|
27
|
+
|
28
|
+
def next_minor
|
29
|
+
"rel-#{major}.#{next_minor_component}.0"
|
30
|
+
end
|
31
|
+
|
32
|
+
def next_fix
|
33
|
+
"rel-#{major}.#{minor}.#{next_fix_component}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def <=>(other_tag)
|
37
|
+
self.class.compare_components(self.components, other_tag.components)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.compare_components(current, other)
|
41
|
+
return 0 if current.empty?
|
42
|
+
return -1 if current.first < other.first
|
43
|
+
return 1 if current.first > other.first
|
44
|
+
|
45
|
+
current.shift
|
46
|
+
other.shift
|
47
|
+
self.compare_components(current, other)
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.release_tag?(tag_name)
|
51
|
+
pattern = /^rel-\d+\.\d+\.\d+$/
|
52
|
+
pattern.match(tag_name).nil? ? false : true
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.raise_if_not_recognized_release_tag!(tag_name)
|
56
|
+
raise Exception, "Tag name does not have valid release tag format" unless release_tag?(tag_name)
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
protected unless $TESTING
|
61
|
+
def components
|
62
|
+
@components.dup
|
63
|
+
end
|
64
|
+
|
65
|
+
def next_major_component
|
66
|
+
self.major + 1
|
67
|
+
end
|
68
|
+
|
69
|
+
def next_minor_component
|
70
|
+
self.minor + 1
|
71
|
+
end
|
72
|
+
|
73
|
+
def next_fix_component
|
74
|
+
self.fix + 1
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
data/lib/svn.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
$TESTING = true
|
3
|
+
|
4
|
+
require 'svn'
|
5
|
+
|
6
|
+
describe "SVN::Project Integration Test" do
|
7
|
+
|
8
|
+
it "should list the ReleaseTags in asc order" do
|
9
|
+
svn = SVN::Project.new()
|
10
|
+
svn.stub!(:tags_url).and_return("#{svn.project_url}/test_tags")
|
11
|
+
|
12
|
+
svn.release_tags.last.to_s.should == 'rel-1.1.0'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should create the requested tag" do
|
16
|
+
svn = SVN::Project.new()
|
17
|
+
svn.stub!(:tags_url).and_return("#{svn.project_url}/test_tags")
|
18
|
+
|
19
|
+
next_fix_tag = 'rel-1.1.1'
|
20
|
+
next_fix_tag.should == svn.current_tag.next_fix
|
21
|
+
svn.release_tags.select { |tag| tag.to_s == next_fix_tag }.should be_empty
|
22
|
+
svn.create_tag(next_fix_tag)
|
23
|
+
svn.release_tags.select { |tag| tag.to_s == next_fix_tag }.should_not be_empty
|
24
|
+
|
25
|
+
next_minor_tag = 'rel-1.2.0'
|
26
|
+
next_minor_tag.should == svn.current_tag.next_minor
|
27
|
+
svn.release_tags.select { |tag| tag.to_s == next_minor_tag }.should be_empty
|
28
|
+
svn.create_tag(next_minor_tag)
|
29
|
+
svn.release_tags.select { |tag| tag.to_s == next_minor_tag }.should_not be_empty
|
30
|
+
|
31
|
+
svn.destroy_tag(next_fix_tag)
|
32
|
+
svn.release_tags.select { |tag| tag.to_s == next_fix_tag }.should be_empty
|
33
|
+
svn.destroy_tag(next_minor_tag)
|
34
|
+
svn.release_tags.select { |tag| tag.to_s == next_minor_tag }.should be_empty
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should not create a 'current' tag by default" do
|
38
|
+
svn = SVN::Project.new()
|
39
|
+
svn.stub!(:tags_url).and_return("#{svn.project_url}/test_tags")
|
40
|
+
svn.always_update_current?.should be_false
|
41
|
+
|
42
|
+
next_major_tag = svn.current_tag.next_major
|
43
|
+
svn.create_tag(next_major_tag)
|
44
|
+
svn.list_all_tags.include?('current').should be_false
|
45
|
+
|
46
|
+
svn.destroy_tag(next_major_tag)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should create a 'current' tag if 'always_update_current' is true" do
|
50
|
+
svn = SVN::Project.new()
|
51
|
+
svn.stub!(:tags_url).and_return("#{svn.project_url}/test_tags")
|
52
|
+
svn.always_update_current = true
|
53
|
+
svn.always_update_current?.should be_true
|
54
|
+
|
55
|
+
next_major_tag = svn.current_tag.next_major
|
56
|
+
|
57
|
+
svn.create_tag(next_major_tag)
|
58
|
+
svn.list_all_tags.include?('current').should be_true
|
59
|
+
|
60
|
+
svn.destroy_tag(next_major_tag)
|
61
|
+
svn.destroy_tag('current')
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
$TESTING = true
|
3
|
+
|
4
|
+
require 'svn'
|
5
|
+
|
6
|
+
describe "SVN::Project" do
|
7
|
+
before(:each) do
|
8
|
+
@bad_tag = "bad_tag-A.B.C"
|
9
|
+
@first_tag = "rel-0.0.1"
|
10
|
+
@second_tag = "rel-0.1.0"
|
11
|
+
@third_tag = "rel-1.0.0"
|
12
|
+
@svn_tags = [@first_tag, @second_tag, @bad_tag, @third_tag]
|
13
|
+
end
|
14
|
+
|
15
|
+
it "will accept a block for setting the connection parameters" do
|
16
|
+
username = "runner"
|
17
|
+
project_url = "svn.berkeley.edu/svn/ist-svn/berkeley/projects/commons/ruby/svn_tags"
|
18
|
+
method = "svn+ssh"
|
19
|
+
|
20
|
+
svn = SVN::Project.new() do |s|
|
21
|
+
s.username = username
|
22
|
+
s.project_url = project_url
|
23
|
+
s.method = method
|
24
|
+
end
|
25
|
+
|
26
|
+
svn.username.should == username
|
27
|
+
svn.method.should == method
|
28
|
+
svn.project_url.should == project_url
|
29
|
+
end
|
30
|
+
|
31
|
+
it "will raise an MissingConnectionParamException if a connection parameter is not specified in the block" do
|
32
|
+
username = "runner"
|
33
|
+
project_url = "svn.berkeley.edu/svn/ist-svn/berkeley/projects/commons/ruby/svn_tags"
|
34
|
+
method = "svn+ssh"
|
35
|
+
|
36
|
+
lambda {
|
37
|
+
SVN::Project.new() do |s|
|
38
|
+
s.username = username
|
39
|
+
s.project_url = project_url
|
40
|
+
end
|
41
|
+
}.should raise_error(SVN::Project::MissingConnectionParamException)
|
42
|
+
|
43
|
+
lambda {
|
44
|
+
SVN::Project.new() do |s|
|
45
|
+
s.username = username
|
46
|
+
s.method = method
|
47
|
+
end
|
48
|
+
}.should raise_error(SVN::Project::MissingConnectionParamException)
|
49
|
+
|
50
|
+
lambda {
|
51
|
+
SVN::Project.new() do |s|
|
52
|
+
s.method = method
|
53
|
+
s.project_url = project_url
|
54
|
+
end
|
55
|
+
}.should raise_error(SVN::Project::MissingConnectionParamException)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "list_all_tags should list 'all' tags in the tags_url directory" do
|
59
|
+
svn = SVN::Project.new()
|
60
|
+
svn.stub!(:retrieve_tags).and_return(@svn_tags)
|
61
|
+
svn.list_all_tags().should == @svn_tags
|
62
|
+
end
|
63
|
+
|
64
|
+
it "list_release_tags should only show release_tags" do
|
65
|
+
svn = SVN::Project.new()
|
66
|
+
svn.stub!(:retrieve_tags).and_return(@svn_tags.dup)
|
67
|
+
|
68
|
+
svn.list_release_tags.map { |tag| tag.to_s }.should == [@first_tag, @second_tag, @third_tag]
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should determine the next 'major' tag" do
|
72
|
+
svn = SVN::Project.new()
|
73
|
+
svn.stub!(:retrieve_tags).and_return(@svn_tags.dup)
|
74
|
+
|
75
|
+
svn.next_major_tag.should == 'rel-2.0.0'
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should determine the next 'minor' tag" do
|
79
|
+
svn = SVN::Project.new()
|
80
|
+
svn.stub!(:retrieve_tags).and_return(@svn_tags.dup)
|
81
|
+
|
82
|
+
svn.next_minor_tag.should == 'rel-1.1.0'
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should determine the next 'fix' tag" do
|
86
|
+
svn = SVN::Project.new()
|
87
|
+
svn.stub!(:retrieve_tags).and_return(@svn_tags.dup)
|
88
|
+
|
89
|
+
svn.next_fix_tag.should == 'rel-1.0.1'
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should determin the 'current' tag" do
|
93
|
+
svn = SVN::Project.new()
|
94
|
+
svn.stub!(:retrieve_tags).and_return(@svn_tags.dup)
|
95
|
+
|
96
|
+
svn.current_tag.to_s.should == 'rel-1.0.0'
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
it "should allow the svn_cmd to be set from the block" do
|
101
|
+
lambda {
|
102
|
+
SVN::Project.new() do |s|
|
103
|
+
s.username = "runner"
|
104
|
+
s.project_url = "svn.berkeley.edu/svn/ist-svn/berkeley/projects/commons/ruby/svn_tags"
|
105
|
+
s.method = "svn+ssh"
|
106
|
+
s.svn_cmd = "tmp"
|
107
|
+
end
|
108
|
+
}.should raise_error(SVN::Project::MissingSVNClientException)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should return a dummy tag--rel-0.0.0--if no tags exist" do
|
112
|
+
svn = SVN::Project.new()
|
113
|
+
svn.stub!(:retrieve_tags).and_return([])
|
114
|
+
svn.current_tag.to_s.should == 'rel-0.0.0'
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib/')
|
2
|
+
$TESTING = true
|
3
|
+
|
4
|
+
require 'svn'
|
5
|
+
|
6
|
+
|
7
|
+
describe "SVN::ReleaseTag" do
|
8
|
+
|
9
|
+
before(:all) do
|
10
|
+
@valid_tag_name = "rel-3.2.1"
|
11
|
+
@invalid_tag_name = "crap-A.B.C"
|
12
|
+
@release_tag = SVN::ReleaseTag.new(@valid_tag_name)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should recognize a valid ReleaseTag name" do
|
16
|
+
valid_tag_names = ["rel-0.1.3", "rel-1.2.60", "rel-22.22.99"]
|
17
|
+
valid_tag_names.each { |tag| SVN::ReleaseTag.release_tag?(tag).should be_true }
|
18
|
+
|
19
|
+
invalid_tag_names = ["crap-0.0.0", "rel-A.B.C", "rel-1_2_3"]
|
20
|
+
invalid_tag_names.each { |tag| SVN::ReleaseTag.release_tag?(tag).should be_false }
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should raise and exception if the name of the ReleaseTag is invalid" do
|
24
|
+
lambda { SVN::ReleaseTag.new(@invalid_tag_name)}.should raise_error(Exception)
|
25
|
+
lambda { SVN::ReleaseTag.new(@valid_tag_name)}.should_not raise_error(Exception)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should set the 'major' component of the release_tag" do
|
29
|
+
tag = SVN::ReleaseTag.new(@valid_tag_name)
|
30
|
+
tag.major.should == 3
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should set the 'minor' component of the release_tag" do
|
34
|
+
tag = SVN::ReleaseTag.new(@valid_tag_name)
|
35
|
+
tag.minor.should == 2
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should set the 'fix' component of the release_tag" do
|
39
|
+
tag = SVN::ReleaseTag.new(@valid_tag_name)
|
40
|
+
tag.fix.should == 1
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should determine if one release tag is 'greater than', 'less than' or 'equal' to anothe release tag" do
|
44
|
+
SVN::ReleaseTag.compare_components([1,1,1], [1,1,1]).should == 0
|
45
|
+
SVN::ReleaseTag.compare_components([4,1,12], [5,0,0]).should == -1
|
46
|
+
SVN::ReleaseTag.compare_components([5,4,199], [0,0,1]).should == 1
|
47
|
+
SVN::ReleaseTag.compare_components([0,1,0], [0,1,0]).should == 0
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should sort an array of ReleaseTags" do
|
51
|
+
first = SVN::ReleaseTag.new("rel-0.0.1")
|
52
|
+
second = SVN::ReleaseTag.new("rel-0.1.1")
|
53
|
+
third = SVN::ReleaseTag.new("rel-1.0.0")
|
54
|
+
fourth = SVN::ReleaseTag.new("rel-5.0.0")
|
55
|
+
fifth = SVN::ReleaseTag.new("rel-7.7.1")
|
56
|
+
sixth = SVN::ReleaseTag.new("rel-9.0.0")
|
57
|
+
|
58
|
+
[second, third, first, sixth, fourth, fifth].sort.to_s.should == [first, second, third, fourth, fifth, sixth].to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should determine the next 'major' component" do
|
62
|
+
@release_tag.next_major_component.should == 4
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should determine the next 'minor' component" do
|
66
|
+
@release_tag.next_minor_component.should == 3
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should determine the next 'fix' componenet" do
|
70
|
+
@release_tag.next_fix_component.should == 2
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should determine the next 'major' release tag" do
|
74
|
+
@release_tag.next_major.should == 'rel-4.0.0'
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should determine the next 'minor' release tag" do
|
78
|
+
@release_tag.next_minor.should == 'rel-3.3.0'
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should determine the next 'fix' release tag" do
|
82
|
+
@release_tag.next_fix.should == 'rel-3.2.2'
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
data/spec/svn_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib/')
|
2
|
+
$TESTING = true
|
3
|
+
|
4
|
+
require 'svn'
|
5
|
+
|
6
|
+
describe "SVN" do
|
7
|
+
|
8
|
+
it "should determine if we are using a windows environment or a unix environment" do
|
9
|
+
if RUBY_PLATFORM =~ /win32/
|
10
|
+
SVN.win32?.should be_true
|
11
|
+
else
|
12
|
+
SVN.win32?.should be_false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/svn_project.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{svn_project}
|
5
|
+
s.version = "0.6.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Steven Hansen"]
|
9
|
+
s.date = %q{2008-12-10}
|
10
|
+
s.description = %q{Adds rake tasks for viewing/creating svn tags}
|
11
|
+
s.email = %q{runner@berkeley.edu}
|
12
|
+
s.extra_rdoc_files = ["README", "lib/svn/project.rb", "lib/svn/rake/svntask.rb", "lib/svn/release_tag.rb", "lib/svn.rb", "tasks/svn_project.rake"]
|
13
|
+
s.files = ["Manifest", "README", "Rakefile", "lib/svn/project.rb", "lib/svn/rake/svntask.rb", "lib/svn/release_tag.rb", "lib/svn.rb", "spec/svn_integration_spec.rb", "spec/svn_project_spec.rb", "spec/svn_release_tag_spec.rb", "spec/svn_spec.rb", "tasks/svn_project.rake", "svn_project.gemspec"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://http://svnproj.rubyforge.org}
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Svn_project", "--main", "README"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{svnproj}
|
19
|
+
s.rubygems_version = %q{1.3.0}
|
20
|
+
s.summary = %q{Adds rake tasks for viewing/creating svn tags}
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 2
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_development_dependency(%q<echoe>, [">= 0"])
|
28
|
+
else
|
29
|
+
s.add_dependency(%q<echoe>, [">= 0"])
|
30
|
+
end
|
31
|
+
else
|
32
|
+
s.add_dependency(%q<echoe>, [">= 0"])
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: svn_project
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Steven Hansen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-10 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: echoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: Adds rake tasks for viewing/creating svn tags
|
26
|
+
email: runner@berkeley.edu
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README
|
33
|
+
- lib/svn/project.rb
|
34
|
+
- lib/svn/rake/svntask.rb
|
35
|
+
- lib/svn/release_tag.rb
|
36
|
+
- lib/svn.rb
|
37
|
+
- tasks/svn_project.rake
|
38
|
+
files:
|
39
|
+
- Manifest
|
40
|
+
- README
|
41
|
+
- Rakefile
|
42
|
+
- lib/svn/project.rb
|
43
|
+
- lib/svn/rake/svntask.rb
|
44
|
+
- lib/svn/release_tag.rb
|
45
|
+
- lib/svn.rb
|
46
|
+
- spec/svn_integration_spec.rb
|
47
|
+
- spec/svn_project_spec.rb
|
48
|
+
- spec/svn_release_tag_spec.rb
|
49
|
+
- spec/svn_spec.rb
|
50
|
+
- tasks/svn_project.rake
|
51
|
+
- svn_project.gemspec
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://http://svnproj.rubyforge.org
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options:
|
56
|
+
- --line-numbers
|
57
|
+
- --inline-source
|
58
|
+
- --title
|
59
|
+
- Svn_project
|
60
|
+
- --main
|
61
|
+
- README
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "1.2"
|
75
|
+
version:
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project: svnproj
|
79
|
+
rubygems_version: 1.3.0
|
80
|
+
signing_key:
|
81
|
+
specification_version: 2
|
82
|
+
summary: Adds rake tasks for viewing/creating svn tags
|
83
|
+
test_files: []
|
84
|
+
|