vlad-perforce 2.0.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.
- data/.autotest +24 -0
- data/History.txt +6 -0
- data/Manifest.txt +7 -0
- data/README.txt +46 -0
- data/Rakefile +14 -0
- data/lib/vlad/perforce.rb +118 -0
- data/test/test_vlad_perforce.rb +37 -0
- metadata +77 -0
data/.autotest
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
|
|
3
|
+
require 'autotest/restart'
|
|
4
|
+
|
|
5
|
+
Autotest.add_hook :initialize do |at|
|
|
6
|
+
at.testlib = "minitest/autorun"
|
|
7
|
+
# at.extra_files << "../some/external/dependency.rb"
|
|
8
|
+
#
|
|
9
|
+
# at.libs << ":../some/external"
|
|
10
|
+
#
|
|
11
|
+
# at.add_exception 'vendor'
|
|
12
|
+
#
|
|
13
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
|
14
|
+
# at.files_matching(/test_.*rb$/)
|
|
15
|
+
# end
|
|
16
|
+
#
|
|
17
|
+
# %w(TestA TestB).each do |klass|
|
|
18
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
|
19
|
+
# end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Autotest.add_hook :run_command do |at|
|
|
23
|
+
# system "rake build"
|
|
24
|
+
# end
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
= vlad-perforce
|
|
2
|
+
|
|
3
|
+
* http://rubyforge.org/projects/hitsquad
|
|
4
|
+
|
|
5
|
+
== DESCRIPTION:
|
|
6
|
+
|
|
7
|
+
Vlad plugin providing perforce support. This was previously available
|
|
8
|
+
in vlad but all extra modules outside of the core recipe have been
|
|
9
|
+
removed.
|
|
10
|
+
|
|
11
|
+
== FEATURES/PROBLEMS:
|
|
12
|
+
|
|
13
|
+
* vlad/perforce - provides perforce support for vlad.
|
|
14
|
+
|
|
15
|
+
== REQUIREMENTS:
|
|
16
|
+
|
|
17
|
+
* vlad
|
|
18
|
+
|
|
19
|
+
== INSTALL:
|
|
20
|
+
|
|
21
|
+
* sudo gem install vlad-perforce
|
|
22
|
+
|
|
23
|
+
== LICENSE:
|
|
24
|
+
|
|
25
|
+
(The MIT License)
|
|
26
|
+
|
|
27
|
+
Copyright (c) Ryan Davis, seattle.rb
|
|
28
|
+
|
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
30
|
+
a copy of this software and associated documentation files (the
|
|
31
|
+
'Software'), to deal in the Software without restriction, including
|
|
32
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
33
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
34
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
35
|
+
the following conditions:
|
|
36
|
+
|
|
37
|
+
The above copyright notice and this permission notice shall be
|
|
38
|
+
included in all copies or substantial portions of the Software.
|
|
39
|
+
|
|
40
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
41
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
42
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
43
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
44
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
45
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
46
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
class Vlad::Perforce
|
|
2
|
+
VERSION = '2.0.0'
|
|
3
|
+
|
|
4
|
+
set :p4_cmd, "p4"
|
|
5
|
+
set :source, Vlad::Perforce.new
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Returns the p4 command that will checkout +revision+ into the directory
|
|
9
|
+
# +destination+.
|
|
10
|
+
|
|
11
|
+
def checkout(revision, destination)
|
|
12
|
+
"#{p4_cmd} sync ...#{rev_no(revision)}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
# Returns the p4 command that will export +revision+ into the directory
|
|
17
|
+
# +directory+.
|
|
18
|
+
|
|
19
|
+
def export(revision_or_source, destination)
|
|
20
|
+
if revision_or_source =~ /^(\d+|head)$/i then
|
|
21
|
+
"(cd #{destination} && #{p4_cmd} sync ...#{rev_no(revision_or_source)})"
|
|
22
|
+
else
|
|
23
|
+
"cp -r #{revision_or_source} #{destination}"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
##
|
|
28
|
+
# Returns a command that maps human-friendly revision identifier +revision+
|
|
29
|
+
# into a Perforce revision specification.
|
|
30
|
+
|
|
31
|
+
def revision(revision)
|
|
32
|
+
"`#{p4_cmd} changes -s submitted -m 1 ...#{rev_no(revision)} | cut -f 2 -d\\ `"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
##
|
|
36
|
+
# Maps revision +revision+ into a Perforce revision.
|
|
37
|
+
|
|
38
|
+
def rev_no(revision)
|
|
39
|
+
case revision.to_s
|
|
40
|
+
when /head/i then
|
|
41
|
+
"#head"
|
|
42
|
+
when /^\d+$/ then
|
|
43
|
+
"@#{revision}"
|
|
44
|
+
else
|
|
45
|
+
revision
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
namespace :vlad do
|
|
51
|
+
remote_task :setup_app, :roles => :app do
|
|
52
|
+
p4data = p4port = p4user = p4passwd = nil
|
|
53
|
+
|
|
54
|
+
if ENV['P4CONFIG'] then
|
|
55
|
+
p4config_name = ENV['P4CONFIG']
|
|
56
|
+
p4config = nil
|
|
57
|
+
orig_dir = Dir.pwd.split File::SEPARATOR
|
|
58
|
+
|
|
59
|
+
until orig_dir.length == 1 do
|
|
60
|
+
p4config = orig_dir + [p4config_name]
|
|
61
|
+
p4config = File.join p4config
|
|
62
|
+
break if File.exist? p4config
|
|
63
|
+
orig_dir.pop
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
raise "couldn't find .p4config" unless File.exist? p4config
|
|
67
|
+
|
|
68
|
+
p4data = File.readlines(p4config).map { |line| line.strip.split '=', 2 }
|
|
69
|
+
p4data = Hash[*p4data.flatten]
|
|
70
|
+
else
|
|
71
|
+
p4data = ENV
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
p4port = p4data['P4PORT']
|
|
75
|
+
p4user = p4data['P4USER']
|
|
76
|
+
p4passwd = p4data['P4PASSWD']
|
|
77
|
+
|
|
78
|
+
raise "couldn't get P4PORT" if p4port.nil?
|
|
79
|
+
raise "couldn't get P4USER" if p4user.nil?
|
|
80
|
+
raise "couldn't get P4PASSWD" if p4passwd.nil?
|
|
81
|
+
|
|
82
|
+
p4client = [p4user, target_host, application].join '-'
|
|
83
|
+
|
|
84
|
+
require 'tmpdir'
|
|
85
|
+
require 'tempfile'
|
|
86
|
+
|
|
87
|
+
put File.join(scm_path, '.p4config'), 'vlad.p4config' do
|
|
88
|
+
[ "P4PORT=#{p4port}",
|
|
89
|
+
"P4USER=#{p4user}",
|
|
90
|
+
"P4PASSWD=#{p4passwd}",
|
|
91
|
+
"P4CLIENT=#{p4client}" ].join("\n")
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
p4client_path = File.join deploy_to, 'p4client.tmp'
|
|
95
|
+
|
|
96
|
+
put p4client_path, 'vlad.p4client' do
|
|
97
|
+
conf = <<-"CLIENT"
|
|
98
|
+
Client: #{p4client}
|
|
99
|
+
|
|
100
|
+
Owner: #{p4user}
|
|
101
|
+
|
|
102
|
+
Root: #{scm_path}
|
|
103
|
+
|
|
104
|
+
View:
|
|
105
|
+
#{repository}/... //#{p4client}/...
|
|
106
|
+
CLIENT
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
cmds = [
|
|
110
|
+
"cd #{scm_path}",
|
|
111
|
+
"p4 client -i < #{p4client_path}",
|
|
112
|
+
"rm #{p4client_path}",
|
|
113
|
+
]
|
|
114
|
+
|
|
115
|
+
run cmds.join(' && ')
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'vlad_test_case'
|
|
2
|
+
require 'vlad'
|
|
3
|
+
require 'vlad/perforce'
|
|
4
|
+
|
|
5
|
+
class TestVladPerforce < VladTestCase
|
|
6
|
+
def setup
|
|
7
|
+
super
|
|
8
|
+
@scm = Vlad::Perforce.new
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_checkout
|
|
12
|
+
cmd = @scm.checkout 'head', '/the/place'
|
|
13
|
+
assert_equal 'p4 sync ...#head', cmd
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_checkout_revision
|
|
17
|
+
cmd = @scm.checkout 555, '/the/place'
|
|
18
|
+
assert_equal 'p4 sync ...@555', cmd
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_export
|
|
22
|
+
cmd = @scm.export 'head', '/the/place'
|
|
23
|
+
assert_equal '(cd /the/place && p4 sync ...#head)', cmd
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_revision
|
|
27
|
+
cmd = @scm.revision('head')
|
|
28
|
+
assert_equal '`p4 changes -s submitted -m 1 ...#head | cut -f 2 -d\\ `', cmd
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_rev_no
|
|
32
|
+
assert_equal "@555", @scm.rev_no(555)
|
|
33
|
+
assert_equal "#head", @scm.rev_no('head')
|
|
34
|
+
assert_equal "#head", @scm.rev_no('HEAD')
|
|
35
|
+
assert_equal "@666", @scm.rev_no("@666")
|
|
36
|
+
end
|
|
37
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: vlad-perforce
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 2.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ryan Davis
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-08-18 00:00:00 -07:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: hoe
|
|
17
|
+
type: :development
|
|
18
|
+
version_requirement:
|
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
20
|
+
requirements:
|
|
21
|
+
- - ">="
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: 2.3.3
|
|
24
|
+
version:
|
|
25
|
+
description: |-
|
|
26
|
+
Vlad plugin providing perforce support. This was previously available
|
|
27
|
+
in vlad but all extra modules outside of the core recipe have been
|
|
28
|
+
removed.
|
|
29
|
+
email:
|
|
30
|
+
- ryand-ruby@zenspider.com
|
|
31
|
+
executables: []
|
|
32
|
+
|
|
33
|
+
extensions: []
|
|
34
|
+
|
|
35
|
+
extra_rdoc_files:
|
|
36
|
+
- History.txt
|
|
37
|
+
- Manifest.txt
|
|
38
|
+
- README.txt
|
|
39
|
+
files:
|
|
40
|
+
- .autotest
|
|
41
|
+
- History.txt
|
|
42
|
+
- Manifest.txt
|
|
43
|
+
- README.txt
|
|
44
|
+
- Rakefile
|
|
45
|
+
- lib/vlad/perforce.rb
|
|
46
|
+
- test/test_vlad_perforce.rb
|
|
47
|
+
has_rdoc: true
|
|
48
|
+
homepage: http://rubyforge.org/projects/hitsquad
|
|
49
|
+
licenses: []
|
|
50
|
+
|
|
51
|
+
post_install_message:
|
|
52
|
+
rdoc_options:
|
|
53
|
+
- --main
|
|
54
|
+
- README.txt
|
|
55
|
+
require_paths:
|
|
56
|
+
- lib
|
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: "0"
|
|
62
|
+
version:
|
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: "0"
|
|
68
|
+
version:
|
|
69
|
+
requirements: []
|
|
70
|
+
|
|
71
|
+
rubyforge_project: hitsquad
|
|
72
|
+
rubygems_version: 1.3.5
|
|
73
|
+
signing_key:
|
|
74
|
+
specification_version: 3
|
|
75
|
+
summary: Vlad plugin providing perforce support
|
|
76
|
+
test_files:
|
|
77
|
+
- test/test_vlad_perforce.rb
|