buuum/git

简单快速的 Git php

v1.0.1 2017-04-04 05:30 UTC

This package is auto-updated.

Last update: 2024-09-17 19:52:02 UTC


README

Packagist license

安装

系统需求

要使用 Buuum\Git,您需要 PHP >= 5.5.0,但建议使用 PHP 的最新稳定版本。

Composer

Buuum\Git 可在 Packagist 上找到,并可以使用 Composer 安装。

composer require buuum/git

手动安装

只要您的自动加载器遵循 PSR-0 或 PSR-4 标准,您就可以使用自己的自动加载器。只需将 src 目录的内容放入您的 vendor 目录中即可。

 初始化

$repository_path = __DIR__;
$git = new \Buuum\Git($repository_path);

方法

getCurrentBranch()

$git->getCurrentBranch();

输出 (string)

master

getCommits($order_asc)

$git->getCommits();

输出 (array)

array(2) {
  ["f70a8a70c3504257d8ccc79d2c759ee743b9391d"]=>
  array(4) {
    ["commit"]=>
    string(40) "f70a8a70c3504257d8ccc79d2c759ee743b9391d"
    ["author"]=>
    string(27) "buuum <buuumlion@gmail.com>"
    ["date"]=>
    string(29) "Sun May 1 15:51:51 2016 +0200"
    ["message"]=>
    string(14) "Initial commit"
  }
  ["cda360828e92443bfc0c19129794fd7729b7f7c8"]=>
  array(4) {
    ["commit"]=>
    string(40) "cda360828e92443bfc0c19129794fd7729b7f7c8"
    ["author"]=>
    string(47) "buuum <buuumlion@gmail.com>"
    ["date"]=>
    string(30) "Thu May 12 08:15:31 2016 +0200"
    ["message"]=>
    string(14) "initial commit"
  }
}

getAllFiles()

$git->getAllFiles();

输出 (array)

array(4) {
  [0]=>
  string(10) ".gitignore"
  [1]=>
  string(9) "README.md"
  [2]=>
  string(13) "composer.json"
  [3]=>
  string(15) "src/Git/Git.php"
}

getDiffCommits($from, $to)

$git->getDiffCommits($from,$to);

输出 (array)

array(4) {
  [0]=>
  string(12) "M	.gitignore"
  [1]=>
  string(11) "A	README.md"
  [2]=>
  string(15) "A	composer.json"
  [3]=>
  string(17) "A	src/Git/Git.php"
}

getDiff($number)

$git->getDiff(1);

输出 (array)

array(4) {
  [0]=>
  string(12) "M	.gitignore"
  [1]=>
  string(11) "A	README.md"
  [2]=>
  string(15) "A	composer.json"
  [3]=>
  string(17) "A	src/Git/Git.php"
}

isWorkingCopyClean()

$git->isWorkingCopyClean();

输出 (bool)

true

许可证

MIT 许可证 (MIT)

版权所有 (c) 2016

特此授予任何获得此软件及其相关文档副本(以下简称“软件”)的人,免费、无条件地使用该软件的权利,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件副本,并允许向软件提供副本的个人以本许可的方式使用该软件,前提是必须遵守以下条件

上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。

软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、针对特定目的的适用性和非侵权性。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论这些责任是基于合同、侵权或其他法律依据,无论这些责任产生于、源于或与软件或软件的使用或其他方式有关。