grimzy/git-info 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

grimzy/git-info

最新稳定版本:v1.0.0

Composer 安装命令:

composer require grimzy/git-info

包简介

Utility library to retrieve Git information from a working directory.

README 文档

README

Build Status Maintainability Test Coverage StyleCI

Utility library to retrieve Git information from a working directory.

Minimum requirement: PHP 7.1

Installation

composer require git-info

Usage

// Instantiate GitInfo
$gitInfo = new \Grimzy\GitInfo\GitInfo();

// Run all registered commands
$info = $gitInfo->getInfo();

// $info = [
//     'commit-hash-long' => 'd93287e02a3b7823623f383ffb443d686b41e5ae',
//     'commit-hash-short' => 'd93287',
//     'author-name' => 'John Doe',
//     'author-email' => 'john.doe@git-info',
//     'author-date' => '2018-08-17T20:58:21-04:00',
//     'subject' => 'Release v1.2.3'
//     'branch' => 'master'
//     'version' => 'v1.2.3'
// ]


// Run a subset of commands
$info = $gitInfo->getInfo(['branch', 'commit-hash-short', 'author-date']);

// $info = [
//     'branch' => 'master'
//     'commit-hash-short' => 'd93287',
//     'author-date' => '2018-08-17T20:58:21-04:00'
// ]


// Run one command
$info = $gitInfo->getInfo('version');

// $info = 'v1.2.3'

Commands

Get registered commands

$commands = GitInfo::getCommands();

// Default commands:
// $commands = [
//     'commit-hash-long'  => 'git log -1 --pretty=%H',
//     'commit-hash-short' => 'git log -1 --pretty=%h',
//     'author-name'       => 'git log -1 --pretty=%aN',
//     'author-email'      => 'git log -1 --pretty=%aE',
//     'author-date'       => 'git log -1 --pretty=%aI',
//     'subject'           => 'git log -1 --pretty=%s',
//     'branch'            => 'git rev-parse --abbrev-ref HEAD',
//     'version'           => 'git describe --always --tags --abbrev=0'
// ]

Add commands to GitInfo

When instantiating:

$gitInfo = new \Grimzy\GitInfo\GitInfo(null, [
    'status' => 'git status'
]);

$info = $gitInfo->getInfo('status');
// $info = THE STATUS

Using static method:

// Add the status command
GitInfo::addCommand('status', 'git status');

// All instances of GitInfo (existing and newly created) will now have a status command
$gitInfo = new GitInfo();
$info = $gitInfo->getInfo('status');

// $info = THE STATUS

Working directory

Set the working directory

You can set the working directory when instantiating a new instance of GitInfo:

// When instantiating GitInfo
$gitInfo = new \Grimzy\GitInfo\GitInfo('absolute/or/relative/path');

The default working directory is set using getcwd().

Get the working directory

$gitInfo = new \Grimzy\GitInfo\GitInfo();
$gwd = $gitInfo->getWorkingDirectory();
// $gwd = '/absolute/path/to/working/directory'

Tests

$ composer test

Licence

GitInfo is licensed under the MIT License.

统计信息

  • 总下载量: 67
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固