cerberus 0.3.1 → 0.3.2
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.
- data/CHANGES +4 -0
- data/Rakefile +1 -3
- data/lib/cerberus/constants.rb +1 -1
- data/lib/cerberus/manager.rb +5 -3
- data/lib/cerberus/scm/cvs.rb +14 -12
- data/lib/cerberus/scm/darcs.rb +10 -1
- data/lib/cerberus/scm/perforce.rb +83 -0
- data/lib/cerberus/scm/svn.rb +6 -2
- data/lib/cerberus/utils.rb +10 -1
- data/test/perforce_scm_test.rb +22 -0
- data/test/test_helper.rb +2 -2
- metadata +9 -8
data/CHANGES
CHANGED
data/Rakefile
CHANGED
data/lib/cerberus/constants.rb
CHANGED
data/lib/cerberus/manager.rb
CHANGED
@@ -71,6 +71,7 @@ module Cerberus
|
|
71
71
|
|
72
72
|
scm_type = @config[:scm, :type]
|
73
73
|
@scm = SCM.get(scm_type).new(@config[:application_root], @config)
|
74
|
+
say "Client for SCM '#{scm_type}' does not installed" unless @scm.installed?
|
74
75
|
|
75
76
|
builder_type = get_configuration_option(@config[:builder], :type, :rake)
|
76
77
|
@builder = Builder.get(builder_type).new(@config)
|
@@ -180,7 +181,7 @@ module Cerberus
|
|
180
181
|
if projects.empty?
|
181
182
|
puts "There are no any active projects"
|
182
183
|
else
|
183
|
-
puts "List of active
|
184
|
+
puts "List of active projects:"
|
184
185
|
|
185
186
|
projects.each do |fn|
|
186
187
|
fn =~ %r{#{HOME}/config/(.*).yml}
|
@@ -214,7 +215,8 @@ module Cerberus
|
|
214
215
|
module SCM
|
215
216
|
TYPES = {
|
216
217
|
:svn => 'SVN', #Cerberus::SCM
|
217
|
-
:darcs => 'Darcs'
|
218
|
+
:darcs => 'Darcs',
|
219
|
+
:perforce => 'Perforce'
|
218
220
|
}
|
219
221
|
|
220
222
|
def self.get(type)
|
@@ -257,4 +259,4 @@ module Cerberus
|
|
257
259
|
const_get(class_name)
|
258
260
|
end
|
259
261
|
end
|
260
|
-
end
|
262
|
+
end
|
data/lib/cerberus/scm/cvs.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
+
require 'cerberus/utils'
|
2
|
+
|
1
3
|
class Cerberus::SCM::CVS
|
4
|
+
include Cerberus::Utils
|
5
|
+
|
2
6
|
def initialize(path, config = {})
|
3
7
|
raise "Path can't be nil" unless path
|
4
8
|
|
@@ -6,6 +10,10 @@ class Cerberus::SCM::CVS
|
|
6
10
|
@encoded_path = (@path.include?(' ') ? "\"#{@path}\"" : @path)
|
7
11
|
end
|
8
12
|
|
13
|
+
def installed?
|
14
|
+
exec_successful? "#{@config[:bin_path]}cvs --version"
|
15
|
+
end
|
16
|
+
|
9
17
|
def update!
|
10
18
|
if test(?d, @path + '/CVS')
|
11
19
|
@status = execute("update")
|
@@ -16,33 +24,27 @@ class Cerberus::SCM::CVS
|
|
16
24
|
end
|
17
25
|
|
18
26
|
def has_changes?
|
19
|
-
@status =~
|
27
|
+
@status =~ /^[U|P|C] (.*)/
|
20
28
|
end
|
21
29
|
|
22
30
|
def current_revision
|
23
|
-
|
31
|
+
raise NotImplementedError
|
24
32
|
end
|
25
33
|
|
26
34
|
def url
|
27
|
-
|
35
|
+
raise NotImplementedError
|
28
36
|
end
|
29
37
|
|
30
38
|
def last_commit_message
|
31
|
-
|
32
|
-
#strip first line that contains command line itself (svn log --limit ...)
|
33
|
-
if ((idx = message.index('-'*72)) != 0 )
|
34
|
-
message[idx..-1]
|
35
|
-
else
|
36
|
-
message
|
37
|
-
end
|
39
|
+
raise NotImplementedError
|
38
40
|
end
|
39
41
|
|
40
42
|
def last_author
|
41
|
-
|
43
|
+
raise NotImplementedError
|
42
44
|
end
|
43
45
|
|
44
46
|
private
|
45
47
|
def execute(command, parameters = nil, pre_parameters = nil)
|
46
48
|
`#{@config[:bin_path]}cvs #{command} #{pre_parameters} #{@encoded_path} #{parameters}`
|
47
49
|
end
|
48
|
-
end
|
50
|
+
end
|
data/lib/cerberus/scm/darcs.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
+
require 'cerberus/utils'
|
2
|
+
|
1
3
|
class Cerberus::SCM::Darcs
|
4
|
+
include Cerberus::Utils
|
5
|
+
|
2
6
|
def initialize(path, config = {})
|
3
7
|
raise "Path can't be nil" unless path
|
4
8
|
|
@@ -6,6 +10,10 @@ class Cerberus::SCM::Darcs
|
|
6
10
|
@encoded_path = (@path.include?(' ') ? "\"#{@path}\"" : @path)
|
7
11
|
end
|
8
12
|
|
13
|
+
def installed?
|
14
|
+
exec_successful? "#{@config[:bin_path]}darcs --version"
|
15
|
+
end
|
16
|
+
|
9
17
|
def update!
|
10
18
|
if test(?d, @path + '/_darcs')
|
11
19
|
@status = execute('pull', '-v -a')
|
@@ -46,6 +54,7 @@ class Cerberus::SCM::Darcs
|
|
46
54
|
def output
|
47
55
|
@status
|
48
56
|
end
|
57
|
+
|
49
58
|
private
|
50
59
|
def execute(command, parameters = nil, with_path = true)
|
51
60
|
cmd = "#{@config[:bin_path]}darcs #{command} #{parameters} --repodir=#{@encoded_path}"
|
@@ -60,4 +69,4 @@ class Cerberus::SCM::Darcs
|
|
60
69
|
@date = xml.elements["changelog/patch/@date"].value
|
61
70
|
@message = xml.elements["changelog/patch/name"].get_text.value
|
62
71
|
end
|
63
|
-
end
|
72
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'cerberus/utils'
|
2
|
+
|
3
|
+
class Cerberus::SCM::Perforce
|
4
|
+
include Cerberus::Utils
|
5
|
+
CHANGES_LOG_REGEXP = /^Change (\d+) on (.*) by (.*)\n\n(.*)/m
|
6
|
+
|
7
|
+
def initialize(path, config = {})
|
8
|
+
@config = config
|
9
|
+
@path = path.strip
|
10
|
+
|
11
|
+
@p4_view = @config[:scm, :view]
|
12
|
+
@client_name = Socket.gethostname + ":" + @path.gsub(' ', ':')
|
13
|
+
end
|
14
|
+
|
15
|
+
def installed?
|
16
|
+
exec_successful? "#{@config[:bin_path]}p4 info"
|
17
|
+
end
|
18
|
+
|
19
|
+
def update!
|
20
|
+
FileUtils.mkpath(@path) unless test(?d,@path)
|
21
|
+
create_client
|
22
|
+
|
23
|
+
@status = execute("sync")
|
24
|
+
end
|
25
|
+
|
26
|
+
def has_changes?
|
27
|
+
!@status.include?('file(s) up-to-date.')
|
28
|
+
end
|
29
|
+
|
30
|
+
def url
|
31
|
+
@view
|
32
|
+
end
|
33
|
+
|
34
|
+
attr_reader :current_revision
|
35
|
+
attr_reader :last_author
|
36
|
+
attr_reader :last_commit_message
|
37
|
+
|
38
|
+
private
|
39
|
+
def last_revision
|
40
|
+
unless @calculated
|
41
|
+
msg = execute("changes -m 1 -l")
|
42
|
+
msg =~ CHANGES_LOG_REGEXP
|
43
|
+
|
44
|
+
@current_revision = $1
|
45
|
+
#date = $2
|
46
|
+
@last_author = $3
|
47
|
+
@last_commit_message = $4.strip
|
48
|
+
|
49
|
+
@calculated = true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def execute(command)
|
54
|
+
`#{@config[:bin_path]}p4 #{p4_opts()} #{command} #{@p4_view} 2>&1`
|
55
|
+
end
|
56
|
+
|
57
|
+
def p4_opts
|
58
|
+
user_opt = @config[:scm, :user_name].to_s.empty? ? "" : "-u #{@config[:scm, :user_name]}"
|
59
|
+
password_opt = @config[:scm, :password].to_s.empty? ? "" : "-P #{@config[:scm, :password]}"
|
60
|
+
client_opt = "-c #{@client_name}"
|
61
|
+
"#{user_opt} #{password_opt} #{client_opt}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def create_client
|
65
|
+
IO.popen("p4 #{p4_opts} client -i", "w+") do |io|
|
66
|
+
io.puts(client_spec)
|
67
|
+
io.close_write
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def client_spec
|
72
|
+
<<-EOF
|
73
|
+
Client: #{@client_name}
|
74
|
+
Owner: #{@config[:scm, :user_name]}
|
75
|
+
Host: #{Socket.gethostname}
|
76
|
+
Description: Cerberus client
|
77
|
+
Root: #{@path}
|
78
|
+
Options: noallwrite noclobber nocompress unlocked nomodtime normdir
|
79
|
+
LineEnd: local
|
80
|
+
View: #{@p4_view} //#{@client_name}/...
|
81
|
+
EOF
|
82
|
+
end
|
83
|
+
end
|
data/lib/cerberus/scm/svn.rb
CHANGED
@@ -10,6 +10,10 @@ class Cerberus::SCM::SVN
|
|
10
10
|
@encoded_path = (@path.include?(' ') ? "\"#{@path}\"" : @path)
|
11
11
|
end
|
12
12
|
|
13
|
+
def installed?
|
14
|
+
exec_successful? "#{@config[:bin_path]}svn --version"
|
15
|
+
end
|
16
|
+
|
13
17
|
def update!
|
14
18
|
if test(?d, @path + '/.svn') #check first that it was not locked
|
15
19
|
execute("cleanup") if locked?
|
@@ -60,7 +64,7 @@ class Cerberus::SCM::SVN
|
|
60
64
|
output = execute("info")
|
61
65
|
@info = YAML.load(output)
|
62
66
|
|
63
|
-
if not @info.is_a?(Hash) or @info['Repository
|
67
|
+
if not @info.is_a?(Hash) or @info['Repository UUID'].nil? #.size > 8
|
64
68
|
say "Could not parse svn output. Seems source directory #{@encoded_path} is corrupted.\n#{output}"
|
65
69
|
end
|
66
70
|
end
|
@@ -78,4 +82,4 @@ class Cerberus::SCM::SVN
|
|
78
82
|
|
79
83
|
auth.join(' ')
|
80
84
|
end
|
81
|
-
end
|
85
|
+
end
|
data/lib/cerberus/utils.rb
CHANGED
@@ -35,6 +35,15 @@ module Cerberus
|
|
35
35
|
ensure
|
36
36
|
stream.reopen(old_stream)
|
37
37
|
end
|
38
|
+
|
39
|
+
def exec_successful?(cmd)
|
40
|
+
begin
|
41
|
+
`#{cmd}`
|
42
|
+
return true
|
43
|
+
rescue
|
44
|
+
return false
|
45
|
+
end
|
46
|
+
end
|
38
47
|
end
|
39
48
|
end
|
40
49
|
|
@@ -129,4 +138,4 @@ class IO
|
|
129
138
|
def self.write(filename, str)
|
130
139
|
File.open(filename, 'w'){|f| f.write str}
|
131
140
|
end
|
132
|
-
end
|
141
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
require 'cerberus/cli'
|
4
|
+
require 'cerberus/scm/perforce'
|
5
|
+
|
6
|
+
class PerforceSCMTest < Test::Unit::TestCase
|
7
|
+
def test_log_parser
|
8
|
+
MSG =~ Cerberus::SCM::Perforce::CHANGES_LOG_REGEXP
|
9
|
+
|
10
|
+
assert_equal '264179', $1
|
11
|
+
assert_equal '2006/11/29', $2
|
12
|
+
assert_equal 'someuser@someuser_SOMEUSER', $3
|
13
|
+
assert_equal "dbcis-2356\njust test", $4.strip
|
14
|
+
end
|
15
|
+
|
16
|
+
MSG =<<END
|
17
|
+
Change 264179 on 2006/11/29 by someuser@someuser_SOMEUSER
|
18
|
+
|
19
|
+
dbcis-2356
|
20
|
+
just test
|
21
|
+
END
|
22
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: cerberus
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.3.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.3.2
|
7
|
+
date: 2006-12-04 00:00:00 +03:00
|
8
8
|
summary: Cerberus is a Continuous Integration tool that could be easily run from Cron.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -15,7 +15,7 @@ description: Cerberus is a Continuous Integration software for Ruby projects. CI
|
|
15
15
|
autorequire:
|
16
16
|
default_executable: cerberus
|
17
17
|
bindir: bin
|
18
|
-
has_rdoc:
|
18
|
+
has_rdoc: false
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/cerberus/publisher/rss.rb
|
60
60
|
- lib/cerberus/scm/cvs.rb
|
61
61
|
- lib/cerberus/scm/darcs.rb
|
62
|
+
- lib/cerberus/scm/perforce.rb
|
62
63
|
- lib/cerberus/scm/svn.rb
|
63
64
|
- test/bjam_builder_test.rb
|
64
65
|
- test/config_test.rb
|
@@ -70,6 +71,7 @@ files:
|
|
70
71
|
- test/mail_publisher_test.rb
|
71
72
|
- test/maven2_builer_test.rb
|
72
73
|
- test/mock
|
74
|
+
- test/perforce_scm_test.rb
|
73
75
|
- test/rss_publisher_test.rb
|
74
76
|
- test/test_helper.rb
|
75
77
|
- test/data/darcs.zip
|
@@ -85,11 +87,10 @@ files:
|
|
85
87
|
- doc/site
|
86
88
|
test_files:
|
87
89
|
- test/integration_test.rb
|
88
|
-
rdoc_options:
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
- README
|
90
|
+
rdoc_options: []
|
91
|
+
|
92
|
+
extra_rdoc_files: []
|
93
|
+
|
93
94
|
executables:
|
94
95
|
- cerberus
|
95
96
|
extensions: []
|