(Grav GitSync) Automatic Commit from GitSync

This commit is contained in:
GitSync
2026-06-14 00:27:27 +00:00
parent a2920f812d
commit 3c1bfda80f
2933 changed files with 491625 additions and 0 deletions
@@ -0,0 +1,5 @@
/.idea
/vendor
/composer.lock
/composer.phar
/cache.properties
+33
View File
@@ -0,0 +1,33 @@
Git
Copyright (c) 2013-2016, Sebastian Bergmann <sebastian@phpunit.de>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Sebastian Bergmann nor the names of his
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
+14
View File
@@ -0,0 +1,14 @@
# Git
Simple PHP wrapper for Git.
## Installation
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
composer require sebastian/git
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
composer require --dev sebastian/git
+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="git" default="build">
<target name="build" depends="prepare,lint,phpcs"/>
<target name="clean" description="Cleanup build artifacts">
</target>
<target name="prepare" depends="clean" description="Prepare for build">
</target>
<target name="lint">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir="${basedir}/src">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
</target>
<target name="phpcs" description="Find coding standard violations using PHP_CodeSniffer">
<exec executable="phpcs">
<arg value="--standard=PSR2" />
<arg value="--extensions=php" />
<arg path="${basedir}/src" />
</exec>
</target>
</project>
+26
View File
@@ -0,0 +1,26 @@
{
"name": "sebastian/git",
"description": "Simple wrapper for Git",
"keywords": ["git"],
"homepage": "http://www.github.com/sebastianbergmann/git",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"require": {
"php": ">=5.3.3"
},
"autoload": {
"classmap": [
"src/"
]
},
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
}
}
}
@@ -0,0 +1,15 @@
<?php
/*
* This file is part of Git.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Git;
interface Exception
{
}
@@ -0,0 +1,15 @@
<?php
/*
* This file is part of Git.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Git;
class RuntimeException extends \RuntimeException implements Exception
{
}
+145
View File
@@ -0,0 +1,145 @@
<?php
/*
* This file is part of Git.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Git;
use DateTime;
class Git
{
/**
* @var string
*/
private $repositoryPath;
/**
* @param string $repositoryPath
*/
public function __construct($repositoryPath)
{
if (!is_dir($repositoryPath)) {
throw new RuntimeException(
sprintf(
'Directory "%s" does not exist',
$repositoryPath
)
);
}
$this->repositoryPath = realpath($repositoryPath);
}
/**
* @param string $revision
*/
public function checkout($revision)
{
$this->execute(
'checkout --force --quiet ' . $revision
);
}
/**
* @return string
*/
public function getCurrentBranch()
{
$output = $this->execute('symbolic-ref --short HEAD');
return $output[0];
}
/**
* @param string $from
* @param string $to
* @return string
*/
public function getDiff($from, $to)
{
$output = $this->execute(
'diff --no-ext-diff ' . $from . ' ' . $to
);
return implode("\n", $output);
}
/**
* @return array
*/
public function getRevisions()
{
$output = $this->execute(
'log --no-merges --date-order --reverse --format=medium'
);
$numLines = count($output);
$revisions = array();
for ($i = 0; $i < $numLines; $i++) {
$tmp = explode(' ', $output[$i]);
if ($tmp[0] == 'commit') {
$sha1 = $tmp[1];
} elseif ($tmp[0] == 'Author:') {
$author = implode(' ', array_slice($tmp, 1));
} elseif ($tmp[0] == 'Date:' && isset($author) && isset($sha1)) {
$revisions[] = array(
'author' => $author,
'date' => DateTime::createFromFormat(
'D M j H:i:s Y O',
implode(' ', array_slice($tmp, 3))
),
'sha1' => $sha1,
'message' => isset($output[$i+2]) ? trim($output[$i+2]) : ''
);
unset($author);
unset($sha1);
}
}
return $revisions;
}
/**
* @return bool
*/
public function isWorkingCopyClean()
{
$output = $this->execute('status');
return $output[count($output)-1] == 'nothing to commit, working directory clean' ||
$output[count($output)-1] == 'nothing to commit, working tree clean';
}
/**
* @param string $command
*
* @return string
*
* @throws RuntimeException
*/
protected function execute($command)
{
$command = 'cd ' . escapeshellarg($this->repositoryPath) . '; git ' . $command . ' 2>&1';
if (DIRECTORY_SEPARATOR == '/') {
$command = 'LC_ALL=en_US.UTF-8 ' . $command;
}
exec($command, $output, $returnValue);
if ($returnValue !== 0) {
throw new RuntimeException(implode("\r\n", $output));
}
return $output;
}
}