codebase 4.0.2 → 4.0.3
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/lib/codebase/recipes.rb +85 -64
- metadata +47 -17
data/lib/codebase/recipes.rb
CHANGED
@@ -1,74 +1,95 @@
|
|
1
1
|
Capistrano::Configuration.instance(:must_exist).load do
|
2
2
|
|
3
|
-
after "deploy:symlink", :
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
username = `git config codebase.username`.chomp.strip
|
8
|
-
api_key = `git config codebase.apikey`.chomp.strip
|
9
|
-
|
10
|
-
regex = /git\@(gitbase|codebasehq)\.com:(.*)\/(.*)\/(.*)\.git/
|
11
|
-
unless m = repository.match(regex)
|
12
|
-
puts " * \e[31mYour repository URL does not a match a valid CodebaseHQ Clone URL\e[0m"
|
13
|
-
else
|
14
|
-
url = "#{m[2]}.codebasehq.com"
|
15
|
-
project = m[3]
|
16
|
-
repository = m[4]
|
17
|
-
|
18
|
-
puts " * \e[44;33mAdding Deployment to your CodebaseHQ account\e[0m"
|
19
|
-
puts " - Account......: #{url}"
|
20
|
-
puts " - Username.....: #{username}"
|
21
|
-
puts " - API Key......: #{api_key[0,10]}..."
|
3
|
+
after "deploy:symlink", 'codebase:deploy'
|
4
|
+
|
5
|
+
namespace :codebase do
|
22
6
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
env.gsub!(/\ +/, '-')
|
34
|
-
puts " - Environment..: #{env}" unless env.nil? || env.empty?
|
35
|
-
env
|
36
|
-
else
|
37
|
-
''
|
38
|
-
end
|
7
|
+
desc "Open the Codebase comparison for the changes which are due to be deployed"
|
8
|
+
task :pending, :except => { :no_release => true } do
|
9
|
+
if match = repository.match(/git\@(codebasehq|gitbase)\.com\:([\w\-]+)\/([\w\-]+)\/([\w\-]+)\.git/)
|
10
|
+
from = source.next_revision(current_revision)
|
11
|
+
to = `git ls-remote #{repository} #{branch}`.split(/\s+/).first
|
12
|
+
url = "https://#{match[2]}.codebasehq.com/#{match[3]}/#{match[4]}/compare/#{from}..#{to}"
|
13
|
+
puts "Opening... #{url}"
|
14
|
+
system("open #{url}")
|
15
|
+
else
|
16
|
+
puts "! Repository does not match a valid Codebase Git URL."
|
39
17
|
end
|
40
|
-
|
41
|
-
servers = roles.values.collect{|r| r.servers}.flatten.collect{|s| s.host}.uniq.join(', ') rescue ''
|
18
|
+
end
|
42
19
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
xml = []
|
48
|
-
xml << "<deployment>"
|
49
|
-
xml << "<servers>#{servers}</servers>"
|
50
|
-
xml << "<revision>#{real_revision}</revision>"
|
51
|
-
xml << "<environment>#{environment_to_send}</environment>"
|
52
|
-
xml << "<branch>#{branch}</branch>"
|
53
|
-
xml << "</deployment>"
|
54
|
-
|
55
|
-
require 'net/http'
|
56
|
-
require 'uri'
|
57
|
-
|
58
|
-
real_url = "http://#{url}/#{project}/#{repository}/deployments"
|
59
|
-
puts " - URL..........: #{real_url}"
|
20
|
+
desc 'Log a deployment in Codebase'
|
21
|
+
task :deploy do
|
22
|
+
username = `git config codebase.username`.chomp.strip
|
23
|
+
api_key = `git config codebase.apikey`.chomp.strip
|
60
24
|
|
61
|
-
|
25
|
+
if username == '' || apikey == ''
|
26
|
+
puts " * Codebase is not configured on your computer. Run 'codebase setup' to auto configure it."
|
27
|
+
puts " * Deployments will not be tracked."
|
28
|
+
next
|
29
|
+
end
|
62
30
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
puts " * \e[
|
31
|
+
regex = /git\@(gitbase|codebasehq)\.com:(.*)\/(.*)\/(.*)\.git/
|
32
|
+
unless m = repository.match(regex)
|
33
|
+
puts " * \e[31mYour repository URL does not a match a valid CodebaseHQ Clone URL\e[0m"
|
34
|
+
else
|
35
|
+
url = "#{m[2]}.codebasehq.com"
|
36
|
+
project = m[3]
|
37
|
+
repository = m[4]
|
38
|
+
|
39
|
+
puts " * \e[44;33mAdding Deployment to your CodebaseHQ account\e[0m"
|
40
|
+
puts " - Account......: #{url}"
|
41
|
+
puts " - Username.....: #{username}"
|
42
|
+
puts " - API Key......: #{api_key[0,10]}..."
|
43
|
+
|
44
|
+
puts " - Project......: #{project}"
|
45
|
+
puts " - Repository...: #{repository}"
|
46
|
+
|
47
|
+
environment_to_send = begin
|
48
|
+
if respond_to?(:environment)
|
49
|
+
env = environment.dup
|
50
|
+
env.gsub!(/\W+/, ' ')
|
51
|
+
env.strip!
|
52
|
+
env.downcase!
|
53
|
+
env.gsub!(/\ +/, '-')
|
54
|
+
puts " - Environment..: #{env}" unless env.nil? || env.empty?
|
55
|
+
env
|
56
|
+
else
|
57
|
+
''
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
servers = roles.values.collect{|r| r.servers}.flatten.collect{|s| s.host}.uniq.join(', ') rescue ''
|
62
|
+
|
63
|
+
puts " - Servers......: #{servers}"
|
64
|
+
puts " - Revision.....: #{real_revision}"
|
65
|
+
puts " - Branch.......: #{branch}"
|
66
|
+
|
67
|
+
xml = []
|
68
|
+
xml << "<deployment>"
|
69
|
+
xml << "<servers>#{servers}</servers>"
|
70
|
+
xml << "<revision>#{real_revision}</revision>"
|
71
|
+
xml << "<environment>#{environment_to_send}</environment>"
|
72
|
+
xml << "<branch>#{branch}</branch>"
|
73
|
+
xml << "</deployment>"
|
74
|
+
|
75
|
+
require 'net/http'
|
76
|
+
require 'uri'
|
77
|
+
|
78
|
+
real_url = "http://#{url}/#{project}/#{repository}/deployments"
|
79
|
+
puts " - URL..........: #{real_url}"
|
80
|
+
|
81
|
+
url = URI.parse(real_url)
|
82
|
+
|
83
|
+
req = Net::HTTP::Post.new(url.path)
|
84
|
+
req.basic_auth(username, api_key)
|
85
|
+
req.add_field('Content-type', 'application/xml')
|
86
|
+
req.add_field('Accept', 'application/xml')
|
87
|
+
res = Net::HTTP.new(url.host, url.port).start { |http| http.request(req, xml.join) }
|
88
|
+
case res
|
89
|
+
when Net::HTTPCreated then puts " * \e[32mAdded deployment to Codebase\e[0m"
|
90
|
+
else
|
91
|
+
puts " * \e[31mSorry, your deployment was not logged in Codebase - please check your config above.\e[0m"
|
92
|
+
end
|
72
93
|
end
|
73
94
|
end
|
74
95
|
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codebase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 57
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 4.0.3
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Adam Cooke
|
@@ -9,39 +15,57 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-09-07 00:00:00 +01:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: highline
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 5
|
33
|
+
- 0
|
23
34
|
version: 1.5.0
|
24
|
-
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
25
37
|
- !ruby/object:Gem::Dependency
|
26
38
|
name: json
|
27
|
-
|
28
|
-
|
29
|
-
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
30
42
|
requirements:
|
31
43
|
- - ">="
|
32
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 25
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 1
|
49
|
+
- 5
|
33
50
|
version: 1.1.5
|
34
|
-
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
35
53
|
- !ruby/object:Gem::Dependency
|
36
54
|
name: hirb
|
37
|
-
|
38
|
-
|
39
|
-
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
40
58
|
requirements:
|
41
59
|
- - ">="
|
42
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 25
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
- 2
|
65
|
+
- 7
|
43
66
|
version: 0.2.7
|
44
|
-
|
67
|
+
type: :runtime
|
68
|
+
version_requirements: *id003
|
45
69
|
description:
|
46
70
|
email: adam@atechmedia.com
|
47
71
|
executables:
|
@@ -71,21 +95,27 @@ rdoc_options: []
|
|
71
95
|
require_paths:
|
72
96
|
- lib
|
73
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
74
99
|
requirements:
|
75
100
|
- - ">="
|
76
101
|
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
103
|
+
segments:
|
104
|
+
- 0
|
77
105
|
version: "0"
|
78
|
-
version:
|
79
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
80
108
|
requirements:
|
81
109
|
- - ">="
|
82
110
|
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
112
|
+
segments:
|
113
|
+
- 0
|
83
114
|
version: "0"
|
84
|
-
version:
|
85
115
|
requirements: []
|
86
116
|
|
87
117
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.3.
|
118
|
+
rubygems_version: 1.3.7
|
89
119
|
signing_key:
|
90
120
|
specification_version: 3
|
91
121
|
summary: Gem companion for your Codebase account. Including interactive cloning, key management and more
|