capistrano-gitinfos 0.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 08a1bca2f8af168b0eb97964483fde9566cd8d65
4
+ data.tar.gz: 71a023fbb7194aa1fa6713636ff568120cfd2394
5
+ SHA512:
6
+ metadata.gz: 6d323524718ff20748cb313f5c66488c07f41bef70bc6c32f0ebb0cb23b9b99f25fc2fe6359b12705284298f993e929fdd35d300258bef8256e135d5b1a1f455
7
+ data.tar.gz: 80c4fd38ae6dff588a88803d4800a3033e0631ec1d62885bae985913ee5330349454e93b08fa30063ba0f46c18e6a14034df828fd1440951f9851ff5d61dabb4
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ bin/
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ /vendor/ruby
20
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-gitinfos.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Kilix
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Capistrano-gitinfos
2
+
3
+ Capistrano 3 plugin to fetch git commit additional informations and store them in an INI/XML/YAML/JSON file when deploying
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'capistrano-gitinfos'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install capistrano-gitinfos
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'capistrano/gitinfos'
25
+ ```
26
+
27
+ Set the version file format and filename.
28
+
29
+ ```ruby
30
+ # version file output format and file extension
31
+ # available formats : ini, xml, yml, json
32
+ # default : json
33
+ set :gitinfos_format, "json"
34
+
35
+ # relative path from release_path without file extension
36
+ # default : version
37
+ # if :gitinfos_format = yml and :gitinfos_file = config/version
38
+ # then the final path is <release_path>/config/version.yml
39
+ set :gitinfos_file, "version"
40
+ ```
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kilix/capistrano-gitinfos.
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/gitinfos/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-gitinfos"
8
+ spec.version = Capistrano::Gitinfos::VERSION
9
+ spec.authors = ["Charles Sanquer"]
10
+ spec.email = ["csanquer@kilix.fr"]
11
+
12
+ spec.summary = "Fetch git commit informations when deploying with Capistrano 3."
13
+ spec.description = "Fetch extra git commit informations and storing in a INI/JSON/XML/YML file when deploying with Capstrano 3."
14
+ spec.homepage = "http://rubygems.org/gems/capistrano-gitinfos"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "capistrano", ">= 3.1"
31
+ spec.add_dependency "sshkit", ">= 1.2.0"
32
+ spec.add_dependency "inifile", ">= 3.0.0"
33
+ spec.add_dependency "json", ">= 1.8.0"
34
+ spec.add_dependency "nokogiri", ">= 1.6.0"
35
+ spec.add_dependency "activesupport", ">= 4.2.0"
36
+
37
+ spec.add_development_dependency "bundler", "~> 1.10"
38
+ spec.add_development_dependency "rake", "~> 10.0"
39
+ spec.add_development_dependency "rspec"
40
+ end
@@ -0,0 +1,13 @@
1
+ # version file output format and file extension
2
+ # available formats : ini, xml, yml, json
3
+ # default : json
4
+ set :gitinfos_format, "json"
5
+
6
+ # relative path from release_path without file extension
7
+ # default : version
8
+ # if :gitinfos_format = yml and :gitinfos_file = config/version
9
+ # then the final path is <release_path>/config/version.yml
10
+ set :gitinfos_file, "version"
11
+
12
+ # XML root tag or INI section (only for XML or INI format)
13
+ set :gitinfos_section, "app_version"
@@ -0,0 +1 @@
1
+ load File.expand_path("../../tasks/gitinfos.rake", __FILE__)
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Gitinfos
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ require 'json'
2
+ require 'yaml'
3
+ require 'inifile'
4
+ require 'nokogiri'
5
+ require 'active_support/time'
6
+ require "capistrano/gitinfos/version"
7
+ require "capistrano/gitinfos/gitinfos"
8
+
9
+ load File.expand_path("../tasks/deploy.rake", __FILE__)
10
+
11
+ namespace :load do
12
+ task :defaults do
13
+ load "capistrano/gitinfos/defaults.rb"
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ namespace :deploy do
2
+ task :set_current_revision do
3
+ invoke "gitinfos:set_version_infos"
4
+ end
5
+ end
@@ -0,0 +1,65 @@
1
+ def getGitInfos(commit)
2
+ rawCommitDate = capture(:git, "log -1 --pretty=tformat:'{%ci}' --no-color --date=local #{commit}").slice(/\{(.+)\}/,1).sub(/\s/, 'T').sub(/\s/, '')
3
+ abbrevCommit = capture(:git, "rev-list --max-count=1 --abbrev-commit #{commit}")
4
+ fullCommit = capture(:git, "rev-list --max-count=1 --no-abbrev-commit #{commit}")
5
+ version = capture(:git, "describe --tag #{commit}")
6
+
7
+ if version.empty?
8
+ version = abbrevCommit
9
+ end
10
+
11
+ deployDate = Time.strptime(release_timestamp, "%Y%m%d%H%M%S").in_time_zone
12
+ commitDate = Time.strptime(rawCommitDate, "%Y-%m-%dT%H:%M:%S%z").in_time_zone
13
+
14
+ return {
15
+ 'version' => version,
16
+ 'abbrev_commit' => abbrevCommit,
17
+ 'full_commit' => fullCommit,
18
+ 'commit_date' => commitDate.strftime('%FT%T%z'),
19
+ 'commit_timestamp' => commitDate.strftime('%s'),
20
+ 'deploy_date' => deployDate.strftime('%FT%T%z'),
21
+ 'deploy_timestamp' => deployDate.strftime('%s'),
22
+ }
23
+ end
24
+
25
+ def formatGitInfos(infos, format)
26
+ case format
27
+ when "yml"
28
+ return YAML.dump(infos)
29
+
30
+ when "xml"
31
+ builder = Nokogiri::XML::Builder.new do |xml|
32
+
33
+ xml.send("#{fetch(:gitinfos_section)}") do
34
+ infos.each do |key, value|
35
+ xml.send(key, value)
36
+ end
37
+ end
38
+ end
39
+
40
+ return builder.to_xml
41
+
42
+ when "ini"
43
+ ini = IniFile.new
44
+ ini["#{fetch(:gitinfos_section)}"] = infos
45
+
46
+ return ini.to_s
47
+
48
+ else
49
+ set :gitinfos_format, "json"
50
+ return JSON.pretty_generate(infos)+"\n"
51
+ end
52
+ end
53
+
54
+ namespace :gitinfos do
55
+ task :set_version_infos do
56
+ on release_roles :all do
57
+ within repo_path do
58
+ with fetch(:git_environmental_variables) do
59
+ infos = formatGitInfos(getGitInfos(fetch(:branch)), fetch(:gitinfos_format))
60
+ upload! StringIO.new(infos), "#{release_path}/#{fetch(:gitinfos_file)}.#{fetch(:gitinfos_format)}"
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
File without changes
metadata ADDED
@@ -0,0 +1,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-gitinfos
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Charles Sanquer
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sshkit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: inifile
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.8.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.6.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.6.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: activesupport
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 4.2.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 4.2.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.10'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.10'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '10.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '10.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Fetch extra git commit informations and storing in a INI/JSON/XML/YML
140
+ file when deploying with Capstrano 3.
141
+ email:
142
+ - csanquer@kilix.fr
143
+ executables: []
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".gitignore"
148
+ - Gemfile
149
+ - LICENSE.txt
150
+ - README.md
151
+ - Rakefile
152
+ - capistrano-gitinfos.gemspec
153
+ - lib/capistrano-gitinfos.rb
154
+ - lib/capistrano/gitinfos.rb
155
+ - lib/capistrano/gitinfos/defaults.rb
156
+ - lib/capistrano/gitinfos/gitinfos.rb
157
+ - lib/capistrano/gitinfos/version.rb
158
+ - lib/capistrano/tasks/deploy.rake
159
+ - lib/capistrano/tasks/gitinfos.rake
160
+ homepage: http://rubygems.org/gems/capistrano-gitinfos
161
+ licenses:
162
+ - MIT
163
+ metadata: {}
164
+ post_install_message:
165
+ rdoc_options: []
166
+ require_paths:
167
+ - lib
168
+ required_ruby_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ required_rubygems_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ requirements: []
179
+ rubyforge_project:
180
+ rubygems_version: 2.4.5.1
181
+ signing_key:
182
+ specification_version: 4
183
+ summary: Fetch git commit informations when deploying with Capistrano 3.
184
+ test_files: []