https://github.com/devjack/gitver
Version parsing from git tags
https://github.com/devjack/gitver
Last synced: 9 months ago
JSON representation
Version parsing from git tags
- Host: GitHub
- URL: https://github.com/devjack/gitver
- Owner: devjack
- License: mit
- Created: 2013-10-07T07:24:32.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2013-11-09T04:55:36.000Z (about 12 years ago)
- Last Synced: 2025-01-30T15:49:30.057Z (11 months ago)
- Language: PHP
- Size: 168 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
gitver
======
Simple class to parse version tags from a git working directory.
[](https://travis-ci.org/sydnerdrage/gitver)
[](https://coveralls.io/r/sydnerdrage/gitver?branch=master)
Usage
-----------
Gitver defaults to the current working directory. As such it requires no immediate configuration
~~~php
use \Gitver\Git;
$gitver = new Git(__DIR__);
echo $gitver->version();
~~~
This will output a `git describe` of the current working directory.
e.g. v0.1.1-0-abcdefg
This is a combination of:
- Most recent tag (matching a $prefixX.Y.Z format - see configuration below)
- Number of commits since that tag
- Current commit prefixed with 'g' (identifying the repository as git).
## Configuration
- Working directory to retrieve version from (defaults to the current working directory)
- Tag match prefix (defaults to "v")
For example if you version tags are in the format of release-X.Y.Z then you would call
~~~php
$gitver = new Git(__DIR__, "version-");
~~~
#### CakePHP Sample
~~~php
set("VERSION", (new Git(__DIR__))->version());
}
}
~~~