Package: git-app-version
Git App VersionA CLI tool written in Python to fetch Git commit informations and store them in a config file.supported formats :JSONYAMLXMLINICSVShell script variablesTypical usecase : when deploying, run this command and import the git version config file.RequirementsPython 2.7 or >= 3.4python pip package toolInstallationJust run :pipinstallgit-app-versionOr downloadlatest binary releasefor Linux amd64 :wgethttps://github.com/csanquer/git-app-version/releases/download/v1.0.0/git-app-version_linux_amd64.tar.gz
tar-xvzfgit-app-version_linux_amd64.tar.gz
sudomvgit-app-version/usr/local/bin/
sudochmoda+x/usr/local/bin/git-app-versionUsageHelpTo get helpgit-app-version-hHelp resultUsage: git-app-version [OPTIONS] [REPOSITORY] [COMMIT]

  Get Git commit informations and store them in a config file

  REPOSITORY git repository path, Default is the current directory.
  COMMIT     git commit to check, Default is HEAD.

Options:
  -V, --version
  -q, --quiet                     silent mode
  -o, --output TEXT               output file path (without extension).
                                  Default is '<repository-path>/version'.
  -f, --format [all|json|yml|xml|ini|csv|sh]
                                  output file format and extension, use 'all'
                                  to output all format, can be set several
                                  times , Default is json.
  -n, --namespace TEXT            namespace like notation in version file, use
                                  dot separator to segment namespaces e.g.:
                                  'foo.bar.git'. Default is 'app_version' for
                                  XML and INI and no namespace for JSON and
                                  YAML. Never used for CSV or Shell file.
  -m, --meta METADATA             meta data to add, format = "<key>=<value>",
                                  can be set several times
  -d, --csv-delimiter TEXT        CSV delimiter, default=","
  -e, --csv-eol [lf|crlf]         CSV end of line, lf = Unix new line, crlf =
                                  windows new line, default=lf
  -u, --csv-quote TEXT            CSV quoting character, default='"'
  -h, --help                      Show this message and exit.Get Commit InformationsTo store git commit informations into a json file# git-app-version -o <output-file-without-extension> -f <file-format> <my-git-repository>git-app-version-oversion-fjsonoutput :Git commit :
----------------  ----------------------------------------
abbrev_commit     40aaf83
author_date       2015-09-05T16:14:16+0000
author_email      paul.durand@example.com
author_name       Paul Durand
author_timestamp  1441469656
branches          master develop
commit_date       2015-09-05T16:14:16+0000
commit_timestamp  1441469656
committer_email   paul.durand@example.com
committer_name    Paul Durand
deploy_date       2016-06-21T09:33:01+0000
deploy_timestamp  1466501581
full_commit       40aaf83894b98898895d478f8b7cc4a866b1d62c
message           new feature
top_branches      master
version           v1.1.0-3-g439e52
----------------  ----------------------------------------
written to :
<my-git-repository>/version.jsonThis will generate a version.json file in the current directory (if this directory is a git repository).You can generate several format at once :git-app-version-oversion-fjson-fyml-fxml-fini-fshMetadata : adding custom fieldsYou can add custom metadata fields with the --meta / -m option (can be used several times) :git-app-version-mfoo=bar-mcustom_key=custom_valueoutput :Git commit :
----------------  ----------------------------------------
abbrev_commit     40aaf83
author_date       2015-09-05T16:14:16+0000
author_email      paul.durand@example.com
author_name       Paul Durand
author_timestamp  1441469656
branches          master develop
commit_date       2015-09-05T16:14:16+0000
commit_timestamp  1441469656
committer_email   paul.durand@example.com
committer_name    Paul Durand
custom_key        custom_value
deploy_date       2016-06-21T09:33:01+0000
deploy_timestamp  1466501581
foo               bar
full_commit       40aaf83894b98898895d478f8b7cc4a866b1d62c
message           new feature
top_branches      master
version           v1.1.0-3-g439e52
----------------  ----------------------------------------
written to :
<my-git-repository>/version.jsonCommit informations fieldsfull_commit: Git SHA1 commit hash,e.g.: 40aaf83894b98898895d478f8b7cc4a866b1d62cabbrev_commit: Git SHA1 commit hash abbrev notation (x significant first characters),e.g.: 40aaf83version: result of the commandgit describe --tags --always, seegit-describe, if no version is found, the abbrev commit will be used per defaulte.g.: v1.1.0-3-g439e52message: Git commit messagecommit_date: Git commit date iniso8601format,e.g.: 2016-03-01T09:33:33+0000commit_timestamp: Git commit date in timestamp format,e.g.: 1456824813author_date: Git author date iniso8601format,e.g.: 2016-03-02T11:33:45+0000author_timestamp: Git author date in timestamp format,e.g.: 1456918425deploy_date: current date (when running the tool) iniso8601format,e.g.: 2016-03-02T11:33:45+0000deploy_timestamp: current date (when running the tool) in timestamp format,e.g.: 1456918425branches: branches which the commit belongs,e.g.: ['master', 'develop']top_branches: branches where the commit is the HEAD commit,e.g.: ['master']committer_name: Git committer name,e.g.: Paul Durandcommitter_email: Git committer email,e.g.:paul.durand@example.comauthor_name: Git author name,e.g.: Paul Durandauthor_email: Git author email,e.g.:paul.durand@example.comFile formatsjsonwithout namespacegit-app-version-fjsonresult{"version":"v1.1.0-3-g439e52","full_commit":"40aaf83894b98898895d478f8b7cc4a866b1d62c","abbrev_commit":"40aaf83","branches":["develop","master"],"top_branches":["master"],"committer_email":"paul.durand@example.com","committer_name":"Paul Durand","author_name":"Paul Durand","author_email":"paul.durand@example.com","commit_date":"2015-09-05T16:14:16+0000","commit_timestamp":"1441469656","author_date":"2015-09-05T16:14:16+0000","author_timestamp":"1441469656","deploy_date":"2016-06-21T09:33:01+0000","deploy_timestamp":"1466501581","message":"new feature"}with namespacegit-app-version-fjson-ngit.infosresult{"git":{"infos":{"version":"v1.1.0-3-g439e52","full_commit":"40aaf83894b98898895d478f8b7cc4a866b1d62c","abbrev_commit":"40aaf83","branches":["develop","master"],"top_branches":["master"],"committer_email":"paul.durand@example.com","committer_name":"Paul Durand","author_name":"Paul Durand","author_email":"paul.durand@example.com","commit_date":"2015-09-05T16:14:16+0000","commit_timestamp":"1441469656","author_date":"2015-09-05T16:14:16+0000","author_timestamp":"1441469656","deploy_date":"2016-06-21T09:33:01+0000","deploy_timestamp":"1466501581","message":"new feature"}}}ymlwithout namespacegit-app-version-fymlresult---
'version': 'v1.1.0-3-g439e52'
'full_commit': '40aaf83894b98898895d478f8b7cc4a866b1d62c'
'abbrev_commit': '40aaf83'
'committer_name': 'Paul Durand'
'committer_email': 'paul.durand@example.com'
'author_name': 'Paul Durand'
'author_email': 'paul.durand@example.com'
'commit_date': '2015-09-05T16:14:16+0000'
'commit_timestamp': '1441469656'
'author_date': '2015-09-05T16:14:16+0000'
'author_timestamp': '1441469656'
'deploy_date': '2016-06-21T09:32:57+0000'
'deploy_timestamp': '1466501577'
'message': 'new feature'
'branches':
- 'develop'
- 'master'
'top_branches':
- 'master'with namespacegit-app-version-fyml-ngit.infosresult---
'git':
  'infos':
    'version': 'v1.1.0-3-g439e52'
    'full_commit': '40aaf83894b98898895d478f8b7cc4a866b1d62c'
    'abbrev_commit': '40aaf83'
    'committer_name': 'Paul Durand'
    'committer_email': 'paul.durand@example.com'
    'author_name': 'Paul Durand'
    'author_email': 'paul.durand@example.com'
    'commit_date': '2015-09-05T16:14:16+0000'
    'commit_timestamp': '1441469656'
    'author_date': '2015-09-05T16:14:16+0000'
    'author_timestamp': '1441469656'
    'deploy_date': '2016-06-21T09:32:57+0000'
    'deploy_timestamp': '1466501577'
    'message': 'new feature'
    'branches':
    - 'develop'
    - 'master'
    'top_branches':
    - 'master'xmlwith default namespacegit-app-version-fxmlresult<?xml version='1.0' encoding='UTF-8'?><app_version><version>v1.1.0-3-g439e52</version><full_commit>40aaf83894b98898895d478f8b7cc4a866b1d62c</full_commit><abbrev_commit>40aaf83</abbrev_commit><commit_date>2015-09-05T16:14:16+0000</commit_date><commit_timestamp>1441469656</commit_timestamp><author_date>2015-09-05T16:14:16+0000</author_date><author_timestamp>1441469656</author_timestamp><deploy_date>2016-06-21T09:32:53+0000</deploy_date><deploy_timestamp>1466501573</deploy_timestamp><committer_name>PaulDurand</committer_name><committer_email>paul.durand@example.com</committer_email><author_name>PaulDurand</author_name><author_email>paul.durand@example.com</author_email><message>newfeature</message><branches>develop</branches><branches>master</branches><top_branches>master</top_branches></app_version>with namespacegit-app-version-fxml-ngit.infosresult<?xml version='1.0' encoding='UTF-8'?><git><infos><version>v1.1.0-3-g439e52</version><full_commit>40aaf83894b98898895d478f8b7cc4a866b1d62c</full_commit><abbrev_commit>40aaf83</abbrev_commit><commit_date>2015-09-05T16:14:16+0000</commit_date><commit_timestamp>1441469656</commit_timestamp><author_date>2015-09-05T16:14:16+0000</author_date><author_timestamp>1441469656</author_timestamp><deploy_date>2016-06-21T09:32:53+0000</deploy_date><deploy_timestamp>1466501573</deploy_timestamp><committer_name>PaulDurand</committer_name><committer_email>paul.durand@example.com</committer_email><author_name>PaulDurand</author_name><author_email>paul.durand@example.com</author_email><message>newfeature</message><branches>develop</branches><branches>master</branches><top_branches>master</top_branches></infos></git>iniwith default namespacegit-app-version-finiresult[app_version]version=v1.1.0-3-g439e52full_commit=40aaf83894b98898895d478f8b7cc4a866b1d62cabbrev_commit=40aaf83commit_date=2016-03-01T09:33:33+0000commit_timestamp=1456824813author_date=2016-03-01T09:33:33+0000author_timestamp=1456824813deploy_date=2016-03-02T11:33:45+0000deploy_timestamp=1456918425message=new featureauthor_name=Paul Durandauthor_email=paul.durand@example.comcommitter_name=Paul Durandcommitter_email=paul.durand@example.comtop_branches=['master']branches=['master','develop']with namespacegit-app-version-fini-ngit.infosresult[git.infos]version=v1.1.0-3-g439e52full_commit=40aaf83894b98898895d478f8b7cc4a866b1d62cabbrev_commit=40aaf83commit_date=2016-03-01T09:33:33+0000commit_timestamp=1456824813author_date=2016-03-01T09:33:33+0000author_timestamp=1456824813deploy_date=2016-03-02T11:33:45+0000deploy_timestamp=1456918425message=new featureauthor_name=Paul Durandauthor_email=paul.durand@example.comcommitter_name=Paul Durandcommitter_email=paul.durand@example.comtop_branches=['master']branches=['master','develop']csvyou can configure CSV format with the option --csv-delimiter , --csv-eol and --csv-quotegit-app-version-fcsv--csv-delimiter','--csv-eollf--csv-quote'"'resultversion,v1.1.0-3-g439e52
full_commit,40aaf83894b98898895d478f8b7cc4a866b1d62c
abbrev_commit,40aaf83
commit_date,2016-03-01T09:33:33+0000
commit_timestamp,1456824813
author_date,2016-03-01T09:33:33+0000
author_timestamp,1456824813
deploy_date,2016-03-02T11:33:45+0000
deploy_timestamp,1456918425
message,new feature
author_name,Paul Durand
author_email,paul.durand@example.com
committer_name,Paul Durand
committer_email,paul.durand@example.com
top_branches,"['master']"
branches,"['master','develop']"sh (shell script variables)git-app-version-fshresultversion="v1.1.0-3-g439e52"full_commit="40aaf83894b98898895d478f8b7cc4a866b1d62c"abbrev_commit="40aaf83"commit_date="2016-03-01T09:33:33+0000"commit_timestamp="1456824813"author_date="2016-03-01T09:33:33+0000"author_timestamp="1456824813"deploy_date="2016-03-02T11:33:45+0000"deploy_timestamp="1456918425"message="new feature"author_name="Paul Durand"author_email="paul.durand@example.com"committer_name="Paul Durand"committer_email="paul.durand@example.com"top_branches="['master']"branches="['master','develop']"LicensingProject under GPL v3 LicenseCopyright (C) 2016 Charles Sanquer