No commit activity in last 3 years
No release in over 3 years
Fetch extra git commit informations and storing in a INI/JSON/XML/YML file when deploying with Capstrano 3.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.10
~> 10.0
~> 3.0

Runtime

>= 3.0.0
>= 1.8.0
>= 1.2.0
>= 1.1.0
 Project Readme

Capistrano-gitinfos

Build Status

Capistrano 3 plugin to fetch git commit additional informations and store them in an INI/XML/YAML/JSON file when deploying

Installation

Add this line to your application's Gemfile:

gem 'capistrano-gitinfos'

And then execute:

$ bundle

Or install it yourself as:

$ gem install capistrano-gitinfos

Usage

require 'capistrano/gitinfos'

Set the version file format and filename.

# version file output format and file extension
# available formats : ini, xml, yml, json
# default : json
set :gitinfos_format, "json"

# relative path from release_path without file extension
# default : version
# if :gitinfos_format = yml and :gitinfos_file = config/version
# then the final path is <release_path>/config/version.yml
set :gitinfos_file, "version"

# section name : "namespace" in the config file which will contains git commit informations
# if the namespace contains dots, it will be translated as nested path in JSON, YML and XML
set :gitinfos_section, ''

After deploying, you will get a file with the following informations:

  • full_commit : git full SHA1 commit
  • abbrev_commit : git abbrev SHA1 commit
  • version : the result of git describe --tags command if possible, otherwise the abbrev commit
  • commit_date : commit date in IS08601 format (with timezone)
  • commit_timestamp : commit date in unix timestamp format
  • deploy_date : capistrano deploy date in IS08601 format (with timezone)
  • deploy_timestamp : capistrano deploy date in unix timestamp format

e.g. :

  • version.json
{
  "commit_date": "2015-11-25T16:25:50+0000",
  "full_commit": "576e27c6ebcef6987f143e1468a815eaf2eb8bc1",
  "version": "v0.8.0-268-g576e27c",
  "commit_timestamp": "1448468750",
  "deploy_date": "2015-11-25T16:45:39+0000",
  "deploy_timestamp": "1448469939",
  "abbrev_commit": "576e27c"
}

with :gitinfos_section = 'parameters.git'

{
  "parameters": {
    "git": {
      "commit_date": "2015-11-25T16:25:50+0000",
      "full_commit": "576e27c6ebcef6987f143e1468a815eaf2eb8bc1",
      "version": "v0.8.0-268-g576e27c",
      "commit_timestamp": "1448468750",
      "deploy_date": "2015-11-25T16:45:39+0000",
      "deploy_timestamp": "1448469939",
      "abbrev_commit": "576e27c"
    }
  }
}
  • version.ini
[app_version]
commit_date = 2015-11-25T16:25:50+0000
full_commit = 576e27c6ebcef6987f143e1468a815eaf2eb8bc1
version = v0.8.0-268-g576e27c
commit_timestamp = 1448468750
deploy_date = 2015-11-25T16:45:43+0000
deploy_timestamp = 1448469943
abbrev_commit = 576e27c

with :gitinfos_section = 'parameters.git'

[parameters.git]
commit_date = 2015-11-25T16:25:50+0000
full_commit = 576e27c6ebcef6987f143e1468a815eaf2eb8bc1
version = v0.8.0-268-g576e27c
commit_timestamp = 1448468750
deploy_date = 2015-11-25T16:45:43+0000
deploy_timestamp = 1448469943
abbrev_commit = 576e27c
  • version.yml
abbrev_commit: 576e27c
commit_date: 2015-11-25T16:25:50+0000
commit_timestamp: '1448468750'
deploy_date: 2015-11-25T16:45:41+0000
deploy_timestamp: '1448469941'
full_commit: 576e27c6ebcef6987f143e1468a815eaf2eb8bc1
version: v0.8.0-268-g576e27c

with :gitinfos_section = 'parameters.git'

parameters:
  git:
    abbrev_commit: '576e27c'
    commit_date: '2015-11-25T16:25:50+0000'
    commit_timestamp: '1448468750'
    deploy_date: '2015-11-25T16:45:41+0000'
    deploy_timestamp: '1448469941'
    full_commit: '576e27c6ebcef6987f143e1468a815eaf2eb8bc1'
    version: 'v0.8.0-268-g576e27c'
  • version.xml
<?xml version='1.0' encoding='UTF-8'?>
<app_version>
  <commit_date>2015-11-25T16:25:50+0000</commit_date>
  <full_commit>576e27c6ebcef6987f143e1468a815eaf2eb8bc1</full_commit>
  <version>v0.8.0-268-g576e27c</version>
  <commit_timestamp>1448468750</commit_timestamp>
  <deploy_date>2015-11-25T16:45:48+0000</deploy_date>
  <deploy_timestamp>1448469948</deploy_timestamp>
  <abbrev_commit>576e27c</abbrev_commit>
</app_version>

with :gitinfos_section = 'parameters.git'

<?xml version='1.0' encoding='UTF-8'?>
<parameters>
  <git>
    <commit_date>2015-11-25T16:25:50+0000</commit_date>
    <full_commit>576e27c6ebcef6987f143e1468a815eaf2eb8bc1</full_commit>
    <version>v0.8.0-268-g576e27c</version>
    <commit_timestamp>1448468750</commit_timestamp>
    <deploy_date>2015-11-25T16:45:48+0000</deploy_date>
    <deploy_timestamp>1448469948</deploy_timestamp>
    <abbrev_commit>576e27c</abbrev_commit>
  </git>
</parameters>

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kilix/capistrano-gitinfos.

License

The gem is available as open source under the terms of the MIT License.