first commit
This commit is contained in:
43
vendor/sebastian/version/ChangeLog.md
vendored
Normal file
43
vendor/sebastian/version/ChangeLog.md
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
# ChangeLog
|
||||
|
||||
All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
|
||||
|
||||
## [4.0.1] - 2023-02-07
|
||||
|
||||
### Fixed
|
||||
|
||||
* [#17](https://github.com/sebastianbergmann/version/pull/17): Release archive contains unnecessary assets
|
||||
|
||||
## [4.0.0] - 2023-02-03
|
||||
|
||||
### Changed
|
||||
|
||||
* `Version::getVersion()` has been renamed to `Version::asString()`
|
||||
|
||||
### Removed
|
||||
|
||||
* This component is no longer supported on PHP 7.3, PHP 7.4, and PHP 8.0
|
||||
|
||||
## [3.0.2] - 2020-09-28
|
||||
|
||||
### Changed
|
||||
|
||||
* Changed PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3`
|
||||
|
||||
## [3.0.1] - 2020-06-26
|
||||
|
||||
### Added
|
||||
|
||||
* This component is now supported on PHP 8
|
||||
|
||||
## [3.0.0] - 2020-01-21
|
||||
|
||||
### Removed
|
||||
|
||||
* This component is no longer supported on PHP 7.1 and PHP 7.2
|
||||
|
||||
[4.0.1]: https://github.com/sebastianbergmann/version/compare/4.0.0...4.0.1
|
||||
[4.0.0]: https://github.com/sebastianbergmann/version/compare/3.0.2...4.0.0
|
||||
[3.0.2]: https://github.com/sebastianbergmann/version/compare/3.0.1...3.0.2
|
||||
[3.0.1]: https://github.com/sebastianbergmann/version/compare/3.0.0...3.0.1
|
||||
[3.0.0]: https://github.com/sebastianbergmann/version/compare/2.0.1...3.0.0
|
29
vendor/sebastian/version/LICENSE
vendored
Normal file
29
vendor/sebastian/version/LICENSE
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2013-2023, Sebastian Bergmann
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. 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.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
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 HOLDER 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.
|
50
vendor/sebastian/version/README.md
vendored
Normal file
50
vendor/sebastian/version/README.md
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
[](https://packagist.org/packages/sebastian/version)
|
||||
|
||||
# sebastian/version
|
||||
|
||||
**sebastian/version** is a library that helps with managing the version number of Git-hosted PHP projects.
|
||||
|
||||
## Installation
|
||||
|
||||
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
|
||||
|
||||
```
|
||||
composer require sebastian/version
|
||||
```
|
||||
|
||||
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/version
|
||||
```
|
||||
## Usage
|
||||
|
||||
The constructor of the `SebastianBergmann\Version` class expects two parameters:
|
||||
|
||||
* `$release` is the version number of the latest release (`X.Y.Z`, for instance) or the name of the release series (`X.Y`) when no release has been made from that branch / for that release series yet.
|
||||
* `$path` is the path to the directory (or a subdirectory thereof) where the sourcecode of the project can be found. Simply passing `__DIR__` here usually suffices.
|
||||
|
||||
Apart from the constructor, the `SebastianBergmann\Version` class has a single public method: `asString()`.
|
||||
|
||||
Here is a contrived example that shows the basic usage:
|
||||
|
||||
```php
|
||||
<?php declare(strict_types=1);
|
||||
use SebastianBergmann\Version;
|
||||
|
||||
$version = new Version('1.0.0', __DIR__);
|
||||
|
||||
var_dump($version->asString());
|
||||
```
|
||||
```
|
||||
string(18) "1.0.0-17-g00f3408"
|
||||
```
|
||||
|
||||
When a new release is prepared, the string that is passed to the constructor as the first argument needs to be updated.
|
||||
|
||||
### How SebastianBergmann\Version::asString() works
|
||||
|
||||
* If `$path` is not (part of) a Git repository and `$release` is in `X.Y.Z` format then `$release` is returned as-is.
|
||||
* If `$path` is not (part of) a Git repository and `$release` is in `X.Y` format then `$release` is returned suffixed with `-dev`.
|
||||
* If `$path` is (part of) a Git repository and `$release` is in `X.Y.Z` format then the output of `git describe --tags` is returned as-is.
|
||||
* If `$path` is (part of) a Git repository and `$release` is in `X.Y` format then a string is returned that begins with `X.Y` and ends with information from `git describe --tags`.
|
9
vendor/sebastian/version/SECURITY.md
vendored
Normal file
9
vendor/sebastian/version/SECURITY.md
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
# Security Policy
|
||||
|
||||
This library is intended to be used in development environments only. For instance, it is used by the testing framework PHPUnit. There is no reason why this library should be installed on a webserver.
|
||||
|
||||
**If you upload this library to a webserver then your deployment process is broken. On a more general note, if your `vendor` directory is publicly accessible on your webserver then your deployment process is also broken.**
|
||||
|
||||
## Security Contact Information
|
||||
|
||||
After the above, if you still would like to report a security vulnerability, please email `sebastian@phpunit.de`.
|
37
vendor/sebastian/version/composer.json
vendored
Normal file
37
vendor/sebastian/version/composer.json
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "sebastian/version",
|
||||
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
|
||||
"homepage": "https://github.com/sebastianbergmann/version",
|
||||
"license": "BSD-3-Clause",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/version/issues"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "8.1.0"
|
||||
},
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"require": {
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "4.0-dev"
|
||||
}
|
||||
}
|
||||
}
|
93
vendor/sebastian/version/src/Version.php
vendored
Normal file
93
vendor/sebastian/version/src/Version.php
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/version.
|
||||
*
|
||||
* (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;
|
||||
|
||||
use function end;
|
||||
use function explode;
|
||||
use function fclose;
|
||||
use function is_dir;
|
||||
use function is_resource;
|
||||
use function proc_close;
|
||||
use function proc_open;
|
||||
use function stream_get_contents;
|
||||
use function substr_count;
|
||||
use function trim;
|
||||
|
||||
final class Version
|
||||
{
|
||||
private readonly string $version;
|
||||
|
||||
public function __construct(string $release, string $path)
|
||||
{
|
||||
$this->version = $this->generate($release, $path);
|
||||
}
|
||||
|
||||
public function asString(): string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
private function generate(string $release, string $path): string
|
||||
{
|
||||
if (substr_count($release, '.') + 1 === 3) {
|
||||
$version = $release;
|
||||
} else {
|
||||
$version = $release . '-dev';
|
||||
}
|
||||
|
||||
$git = $this->getGitInformation($path);
|
||||
|
||||
if (!$git) {
|
||||
return $version;
|
||||
}
|
||||
|
||||
if (substr_count($release, '.') + 1 === 3) {
|
||||
return $git;
|
||||
}
|
||||
|
||||
$git = explode('-', $git);
|
||||
|
||||
return $release . '-' . end($git);
|
||||
}
|
||||
|
||||
private function getGitInformation(string $path): bool|string
|
||||
{
|
||||
if (!is_dir($path . DIRECTORY_SEPARATOR . '.git')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$process = proc_open(
|
||||
'git describe --tags',
|
||||
[
|
||||
1 => ['pipe', 'w'],
|
||||
2 => ['pipe', 'w'],
|
||||
],
|
||||
$pipes,
|
||||
$path
|
||||
);
|
||||
|
||||
if (!is_resource($process)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = trim(stream_get_contents($pipes[1]));
|
||||
|
||||
fclose($pipes[1]);
|
||||
fclose($pipes[2]);
|
||||
|
||||
$returnCode = proc_close($process);
|
||||
|
||||
if ($returnCode !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user