capistrano-gitinfos 0.0.6 → 0.1.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.
- checksums.yaml +4 -4
- data/.gitignore +9 -10
- data/README.md +73 -7
- data/Rakefile +5 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/capistrano-gitinfos.gemspec +2 -2
- data/lib/capistrano/gitinfos.rb +1 -4
- data/lib/capistrano/gitinfos/defaults.rb +3 -2
- data/lib/capistrano/gitinfos/format.rb +70 -0
- data/lib/capistrano/gitinfos/version.rb +1 -1
- data/lib/capistrano/tasks/gitinfos.rake +9 -42
- metadata +13 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 545e60e2a1003cecfef90e3603209be54b0fafbc
|
|
4
|
+
data.tar.gz: 2682b030448987273e7a6b315e5d4c50cb9f58d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 58f2523fdd240d695a953cad68064514e5430597fb017aac0c5fd6b2aad997e3577fbf08759bb50f762fcc23673d23c3a6f9b2d60602cc5240f2af30348b78ce
|
|
7
|
+
data.tar.gz: 25a5c5ae7dca5012c64ae27b31ad9d73fa4714f8cb1b3eaaa7cddb44b613a4b1d11ff3e202fc328aa6e323e9112bca24a40846f1a9eb7c86a57845d133cbd8d1
|
data/.gitignore
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
*.gem
|
|
2
2
|
*.rbc
|
|
3
|
-
|
|
3
|
+
/.bundle/
|
|
4
4
|
.config
|
|
5
|
-
|
|
6
|
-
Gemfile.lock
|
|
5
|
+
/.yardoc
|
|
6
|
+
/Gemfile.lock
|
|
7
7
|
InstalledFiles
|
|
8
|
-
_yardoc
|
|
9
|
-
coverage
|
|
10
|
-
|
|
11
|
-
doc/
|
|
8
|
+
/_yardoc/
|
|
9
|
+
/coverage/
|
|
10
|
+
/doc/
|
|
12
11
|
lib/bundler/man
|
|
13
|
-
pkg
|
|
12
|
+
/pkg/
|
|
14
13
|
rdoc
|
|
15
|
-
spec/reports
|
|
14
|
+
/spec/reports/
|
|
16
15
|
test/tmp
|
|
17
16
|
test/version_tmp
|
|
18
|
-
tmp
|
|
17
|
+
/tmp/
|
|
19
18
|
/vendor/ruby
|
|
20
19
|
.idea
|
data/README.md
CHANGED
|
@@ -37,6 +37,10 @@ set :gitinfos_format, "json"
|
|
|
37
37
|
# if :gitinfos_format = yml and :gitinfos_file = config/version
|
|
38
38
|
# then the final path is <release_path>/config/version.yml
|
|
39
39
|
set :gitinfos_file, "version"
|
|
40
|
+
|
|
41
|
+
# section name : "namespace" in the config file which will contains git commit informations
|
|
42
|
+
# if the namespace contains dots, it will be translated as nested path in JSON, YML and XML
|
|
43
|
+
set :gitinfos_section, ''
|
|
40
44
|
```
|
|
41
45
|
|
|
42
46
|
After deploying, you will get a file with the following informations:
|
|
@@ -55,13 +59,31 @@ e.g. :
|
|
|
55
59
|
|
|
56
60
|
```json
|
|
57
61
|
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
"commit_date": "2015-11-25T16:25:50+0000",
|
|
63
|
+
"full_commit": "576e27c6ebcef6987f143e1468a815eaf2eb8bc1",
|
|
64
|
+
"version": "v0.8.0-268-g576e27c",
|
|
65
|
+
"commit_timestamp": "1448468750",
|
|
66
|
+
"deploy_date": "2015-11-25T16:45:39+0000",
|
|
67
|
+
"deploy_timestamp": "1448469939",
|
|
68
|
+
"abbrev_commit": "576e27c"
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
with `:gitinfos_section` = 'parameters.git'
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"parameters": {
|
|
77
|
+
"git": {
|
|
78
|
+
"commit_date": "2015-11-25T16:25:50+0000",
|
|
79
|
+
"full_commit": "576e27c6ebcef6987f143e1468a815eaf2eb8bc1",
|
|
80
|
+
"version": "v0.8.0-268-g576e27c",
|
|
81
|
+
"commit_timestamp": "1448468750",
|
|
82
|
+
"deploy_date": "2015-11-25T16:45:39+0000",
|
|
83
|
+
"deploy_timestamp": "1448469939",
|
|
84
|
+
"abbrev_commit": "576e27c"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
65
87
|
}
|
|
66
88
|
```
|
|
67
89
|
|
|
@@ -78,6 +100,19 @@ deploy_timestamp = 1448469943
|
|
|
78
100
|
abbrev_commit = 576e27c
|
|
79
101
|
```
|
|
80
102
|
|
|
103
|
+
with `:gitinfos_section` = 'parameters.git'
|
|
104
|
+
|
|
105
|
+
```ini
|
|
106
|
+
[parameters.git]
|
|
107
|
+
commit_date = 2015-11-25T16:25:50+0000
|
|
108
|
+
full_commit = 576e27c6ebcef6987f143e1468a815eaf2eb8bc1
|
|
109
|
+
version = v0.8.0-268-g576e27c
|
|
110
|
+
commit_timestamp = 1448468750
|
|
111
|
+
deploy_date = 2015-11-25T16:45:43+0000
|
|
112
|
+
deploy_timestamp = 1448469943
|
|
113
|
+
abbrev_commit = 576e27c
|
|
114
|
+
```
|
|
115
|
+
|
|
81
116
|
* version.yml
|
|
82
117
|
|
|
83
118
|
```yml
|
|
@@ -90,6 +125,20 @@ full_commit: 576e27c6ebcef6987f143e1468a815eaf2eb8bc1
|
|
|
90
125
|
version: v0.8.0-268-g576e27c
|
|
91
126
|
```
|
|
92
127
|
|
|
128
|
+
with `:gitinfos_section` = 'parameters.git'
|
|
129
|
+
|
|
130
|
+
```yml
|
|
131
|
+
parameters:
|
|
132
|
+
git:
|
|
133
|
+
abbrev_commit: '576e27c'
|
|
134
|
+
commit_date: '2015-11-25T16:25:50+0000'
|
|
135
|
+
commit_timestamp: '1448468750'
|
|
136
|
+
deploy_date: '2015-11-25T16:45:41+0000'
|
|
137
|
+
deploy_timestamp: '1448469941'
|
|
138
|
+
full_commit: '576e27c6ebcef6987f143e1468a815eaf2eb8bc1'
|
|
139
|
+
version: 'v0.8.0-268-g576e27c'
|
|
140
|
+
```
|
|
141
|
+
|
|
93
142
|
* version.xml
|
|
94
143
|
|
|
95
144
|
```xml
|
|
@@ -105,6 +154,23 @@ version: v0.8.0-268-g576e27c
|
|
|
105
154
|
</app_version>
|
|
106
155
|
```
|
|
107
156
|
|
|
157
|
+
with `:gitinfos_section` = 'parameters.git'
|
|
158
|
+
|
|
159
|
+
```xml
|
|
160
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
|
161
|
+
<parameters>
|
|
162
|
+
<git>
|
|
163
|
+
<commit_date>2015-11-25T16:25:50+0000</commit_date>
|
|
164
|
+
<full_commit>576e27c6ebcef6987f143e1468a815eaf2eb8bc1</full_commit>
|
|
165
|
+
<version>v0.8.0-268-g576e27c</version>
|
|
166
|
+
<commit_timestamp>1448468750</commit_timestamp>
|
|
167
|
+
<deploy_date>2015-11-25T16:45:48+0000</deploy_date>
|
|
168
|
+
<deploy_timestamp>1448469948</deploy_timestamp>
|
|
169
|
+
<abbrev_commit>576e27c</abbrev_commit>
|
|
170
|
+
</git>
|
|
171
|
+
</parameters>
|
|
172
|
+
```
|
|
173
|
+
|
|
108
174
|
## Contributing
|
|
109
175
|
|
|
110
176
|
Bug reports and pull requests are welcome on GitHub at https://github.com/kilix/capistrano-gitinfos.
|
data/Rakefile
CHANGED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "capistrano/gitinfos"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/capistrano-gitinfos.gemspec
CHANGED
|
@@ -31,10 +31,10 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
spec.add_dependency "sshkit", ">= 1.2.0"
|
|
32
32
|
spec.add_dependency "inifile", ">= 3.0.0"
|
|
33
33
|
spec.add_dependency "json", ">= 1.8.0"
|
|
34
|
-
spec.add_dependency "
|
|
34
|
+
spec.add_dependency "xml-simple", ">= 1.1.0"
|
|
35
35
|
spec.add_dependency "activesupport", ">= 4.2.0"
|
|
36
36
|
|
|
37
37
|
spec.add_development_dependency "bundler", "~> 1.10"
|
|
38
38
|
spec.add_development_dependency "rake", "~> 10.0"
|
|
39
|
-
spec.add_development_dependency "rspec"
|
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
40
40
|
end
|
data/lib/capistrano/gitinfos.rb
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
require 'json'
|
|
2
|
-
require 'yaml'
|
|
3
|
-
require 'inifile'
|
|
4
|
-
require 'nokogiri'
|
|
5
1
|
require 'active_support/time'
|
|
6
2
|
require "capistrano/gitinfos/version"
|
|
7
3
|
require "capistrano/gitinfos/gitinfos"
|
|
4
|
+
require "capistrano/gitinfos/format"
|
|
8
5
|
|
|
9
6
|
load File.expand_path("../tasks/deploy.rake", __FILE__)
|
|
10
7
|
|
|
@@ -9,5 +9,6 @@ set :gitinfos_format, "json"
|
|
|
9
9
|
# then the final path is <release_path>/config/version.yml
|
|
10
10
|
set :gitinfos_file, "version"
|
|
11
11
|
|
|
12
|
-
#
|
|
13
|
-
|
|
12
|
+
# section name : "namespace" in the config file which will contains git commit informations
|
|
13
|
+
# if the namespace contains dots, it will be translated as nested path in JSON, YML and XML
|
|
14
|
+
set :gitinfos_section, ''
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require 'yaml'
|
|
3
|
+
require 'inifile'
|
|
4
|
+
require 'xmlsimple'
|
|
5
|
+
|
|
6
|
+
module Capistrano
|
|
7
|
+
module Gitinfos
|
|
8
|
+
def self.format(infos, extension = 'json', section = nil)
|
|
9
|
+
case extension.downcase
|
|
10
|
+
when "yml"
|
|
11
|
+
return dumpForceQuotedYaml(createInfosToDump(infos, section))
|
|
12
|
+
|
|
13
|
+
when "xml"
|
|
14
|
+
section = section.nil? || section == '' ? 'app_version' : section
|
|
15
|
+
|
|
16
|
+
return XmlSimple.xml_out(createInfosToDump(infos, section), {
|
|
17
|
+
'KeepRoot' => true,
|
|
18
|
+
'XmlDeclaration' => '<?xml version="1.0"?>',
|
|
19
|
+
'NoAttr' => true
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
when "ini"
|
|
23
|
+
section = section.nil? || section == '' ? 'app_version' : section
|
|
24
|
+
|
|
25
|
+
ini = IniFile.new
|
|
26
|
+
ini[section] = infos
|
|
27
|
+
|
|
28
|
+
return ini.to_s
|
|
29
|
+
|
|
30
|
+
else
|
|
31
|
+
return JSON.pretty_generate(createInfosToDump(infos, section))+"\n"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.createInfosToDump(infos, section = nil)
|
|
36
|
+
toDump = infos
|
|
37
|
+
if !section.nil? && section != ''
|
|
38
|
+
sections = section.split('.')
|
|
39
|
+
sections.reverse_each do |sec|
|
|
40
|
+
toDump = { sec => toDump.dup }
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
return toDump
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Hack to force string quoting and prevent abbrev_commit to be read as float in YAML
|
|
48
|
+
def self.dumpForceQuotedYaml(data)
|
|
49
|
+
raw = data.dup
|
|
50
|
+
pattern = "__ensure_quotes__ "
|
|
51
|
+
yml = YAML.dump(ensure_quotes(raw, pattern))
|
|
52
|
+
|
|
53
|
+
return yml.gsub(/#{Regexp.escape(pattern)}/, '')
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.ensure_quotes(h, pattern = "__ensure_quotes__")
|
|
57
|
+
h.each do |k, v|
|
|
58
|
+
if v.is_a?(Hash)
|
|
59
|
+
ensure_quotes(v, pattern)
|
|
60
|
+
next
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
if v.is_a?(String)
|
|
64
|
+
h[k] = v + pattern
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -21,53 +21,20 @@ def getGitInfos(commit)
|
|
|
21
21
|
}
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
def formatGitInfos(infos, format)
|
|
25
|
-
case format
|
|
26
|
-
when "yml"
|
|
27
|
-
# TODO find option to force quoting to prevent abbrev_commit to be read as float in YAML
|
|
28
|
-
# return YAML.dump(infos)
|
|
29
|
-
return <<-YAML
|
|
30
|
-
---
|
|
31
|
-
version: '#{infos['version']}'
|
|
32
|
-
abbrev_commit: '#{infos['abbrev_commit']}'
|
|
33
|
-
full_commit: '#{infos['full_commit']}'
|
|
34
|
-
commit_date: '#{infos['commit_date']}'
|
|
35
|
-
commit_timestamp: '#{infos['commit_timestamp']}'
|
|
36
|
-
deploy_date: '#{infos['deploy_date']}'
|
|
37
|
-
deploy_timestamp: '#{infos['deploy_timestamp']}'
|
|
38
|
-
YAML
|
|
39
|
-
|
|
40
|
-
when "xml"
|
|
41
|
-
builder = Nokogiri::XML::Builder.new do |xml|
|
|
42
|
-
|
|
43
|
-
xml.send("#{fetch(:gitinfos_section)}") do
|
|
44
|
-
infos.each do |key, value|
|
|
45
|
-
xml.send(key, value)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
return builder.to_xml
|
|
51
|
-
|
|
52
|
-
when "ini"
|
|
53
|
-
ini = IniFile.new
|
|
54
|
-
ini["#{fetch(:gitinfos_section)}"] = infos
|
|
55
|
-
|
|
56
|
-
return ini.to_s
|
|
57
|
-
|
|
58
|
-
else
|
|
59
|
-
set :gitinfos_format, "json"
|
|
60
|
-
return JSON.pretty_generate(infos)+"\n"
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
24
|
namespace :gitinfos do
|
|
65
25
|
task :set_version_infos do
|
|
66
26
|
on release_roles :all do
|
|
67
27
|
within repo_path do
|
|
68
28
|
with fetch(:git_environmental_variables) do
|
|
69
|
-
|
|
70
|
-
|
|
29
|
+
|
|
30
|
+
extension = fetch(:gitinfos_format)
|
|
31
|
+
if !['yml','ini','xml','json'].include?(extension)
|
|
32
|
+
set :gitinfos_format, 'json'
|
|
33
|
+
extension = 'json'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
infos = Capistrano::Gitinfos.format(getGitInfos(fetch(:branch)), extension, fetch(:gitinfos_section))
|
|
37
|
+
upload! StringIO.new(infos), "#{release_path}/#{fetch(:gitinfos_file)}.#{extension}"
|
|
71
38
|
end
|
|
72
39
|
end
|
|
73
40
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: capistrano-gitinfos
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Charles Sanquer
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-04-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: capistrano
|
|
@@ -67,19 +67,19 @@ dependencies:
|
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: 1.8.0
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
70
|
+
name: xml-simple
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - ">="
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 1.
|
|
75
|
+
version: 1.1.0
|
|
76
76
|
type: :runtime
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 1.
|
|
82
|
+
version: 1.1.0
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: activesupport
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -126,16 +126,16 @@ dependencies:
|
|
|
126
126
|
name: rspec
|
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
|
128
128
|
requirements:
|
|
129
|
-
- - "
|
|
129
|
+
- - "~>"
|
|
130
130
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: '0'
|
|
131
|
+
version: '3.0'
|
|
132
132
|
type: :development
|
|
133
133
|
prerelease: false
|
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
135
|
requirements:
|
|
136
|
-
- - "
|
|
136
|
+
- - "~>"
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: '0'
|
|
138
|
+
version: '3.0'
|
|
139
139
|
description: Fetch extra git commit informations and storing in a INI/JSON/XML/YML
|
|
140
140
|
file when deploying with Capstrano 3.
|
|
141
141
|
email:
|
|
@@ -149,10 +149,13 @@ files:
|
|
|
149
149
|
- LICENSE.txt
|
|
150
150
|
- README.md
|
|
151
151
|
- Rakefile
|
|
152
|
+
- bin/console
|
|
153
|
+
- bin/setup
|
|
152
154
|
- capistrano-gitinfos.gemspec
|
|
153
155
|
- lib/capistrano-gitinfos.rb
|
|
154
156
|
- lib/capistrano/gitinfos.rb
|
|
155
157
|
- lib/capistrano/gitinfos/defaults.rb
|
|
158
|
+
- lib/capistrano/gitinfos/format.rb
|
|
156
159
|
- lib/capistrano/gitinfos/gitinfos.rb
|
|
157
160
|
- lib/capistrano/gitinfos/version.rb
|
|
158
161
|
- lib/capistrano/tasks/deploy.rake
|
|
@@ -177,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
177
180
|
version: '0'
|
|
178
181
|
requirements: []
|
|
179
182
|
rubyforge_project:
|
|
180
|
-
rubygems_version: 2.5.
|
|
183
|
+
rubygems_version: 2.5.2
|
|
181
184
|
signing_key:
|
|
182
185
|
specification_version: 4
|
|
183
186
|
summary: Fetch git commit informations when deploying with Capistrano 3.
|