galek/git-repository-tags

此包已被弃用且不再维护。没有建议的替代包。

获取git仓库的标签和版本

v1.1.2 2017-10-18 15:39 UTC

This package is not auto-updated.

Last update: 2020-01-21 19:14:07 UTC


README

Build Status Total Downloads Latest Stable Version License Monthly Downloads

包安装

安装Git Repository Tags的最佳方式是使用Composer

$ composer require galek/git-repository-tags

基本用法

$directory = __DIR__ . '/..'; // where we have directory `.git`, not end with `/` or `\`
$versionPrefix = 'v'; // prefix for version, default is v, so v1.0.0
$currentBranchVersion = true; // true|false , return version by HEAD of branch
$gitTags = new \Galek\GitRepositoryTags\GitRepositoryTags($directory, $versionPrefix, $currentBranchVersion);

// gets informations:

$tags = $gitTags->tags; // array of everyone tags
$versions = $gitTags->versions; // array of everyone tags with our version prefix
$latestVersion = $git->tags->latestVersion; // string, get full name of latest version

Nette用法

config.neon

extensions: 
    gitTags: Galek\GitRepositoryTags\DI\GitRepositoryTagsExtension

gitTags:
	directory: %appDir%/..
	versionPrefix: 'v'
	byCurrentBranch: true

展示者

class BasePresenter extends Presenter
{
    /** @var \Galek\GitRepositoryTags\GitRepositoryTags @inject */
    public $gitTags;
    
    public function renderDefault()
    {
        $this->template->version = $this->gitTags->latestVersion;
        $this->template->currentVersion = $this->gitTags->currentVersion;
    }
}