定制 ride/lib-vcs 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ride/lib-vcs

最新稳定版本:1.0.0

Composer 安装命令:

composer require ride/lib-vcs

包简介

Version control abstraction library of the Ride framework

README 文档

README

Simple version control abstraction library of the PHP Ride framework.

What's In This Library

Repository

The Repository interface represents a repository in any version control system. You can use it to get information about or to manipulate the repository.

Currently only git is implemented through the GitRepository class.

CommitLog

The CommitLog class is used as a data container of a single commit.

Code Sample

Check this code sample to see the possibilities of this library:

<?php

use ride\library\system\System;
use ride\library\vcs\git\GenericGitLogParser;
use ride\library\vcs\git\GitClient;
use ride\library\vcs\git\GitRepository;
use ride\library\vcs\Respository;

function createGitRepository(System $system) {
    $gitClient = new GitClient($system);
    $gitLogParser = new GenericGitLogParser();

    $gitRepository = new GitRepository($gitClient, $gitLogParser);
    $gitRepository->setUrl('git@github.com:all-ride/ride-lib-vcs.git');
    $gitRepository->setWorkingCopy($system->getFileSystem()->getFile('/path/to/local/copy'));
    
    // optionally, set a private key
    $gitRepository->setPrivateKey('/path/to/private.key');
    
    return $gitRepository;
}

function useRepository(Repository $repository) {
    if (!$repository->isCreated()) {
        // create the working copy the first time
        $repository->create();
        
        // perform the initial checkout to retrieve everything in the local copy
        $repository->checkout();
    }
    
    // perform an update or pull
    $repository->update();
    
    // deal with branches
    $currentBranch = $repository->getBranch();
    $availableBranches = $repository->getBranches();
    
    if (!$repository->hasBranch('my-branch')) {
        $repository->createBranch('my-branch');
    }
    
    // retrieve information about commits
    $currentRevision = $repository->getRevision();
    
    $commit = $repository->getCommit($currentRevision);
    if ($commit) {
        echo $commit->message;
        echo $commit->author;
    }
    
    $commits = $repository->getCommits();
    $commits = $repository->getCommits('src/ride/library/vcs/Repository.php');
    
    $sinceCommit = 'a1b2c3';
    $untilCommit = 'z9y8x7';
    $commits = $repository->getCommits('src/ride/library/vcs/Repository.php', 5, $sinceCommit, $untilCommit);
    
    // perform commits
    $repository->add('src/ride/library/vcs/git'); // a folder
    $repository->add('src/ride/library/vcs/git/git-ssh.sh'); // a directory
    
    $repository->remove('.gitignore');
    
    $repository->commit('added git implementation');
}

Implementations

For more examples, you can check the following implementations of this library:

Installation

You can use Composer to install this library.

composer require ride/lib-vcs

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-03-20