Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getLastCommitHash example
new
GitRepository
(
$this
->targetDir
)
;
}
public
function
testItClonesTheRepository
(
)
{
$git
= GitRepository::
download
(
self::REPO_URL,
$this
->targetDir
)
;
$this
->
assertInstanceOf
(
GitRepository::
class
,
$git
)
;
$this
->
assertDirectoryExists
(
$this
->targetDir.'/.git'
)
;
$this
->
assertSame
(
$this
->targetDir,
$git
->
getPath
(
)
)
;
$this
->
assertSame
(
self::REPO_URL,
$git
->
getUrl
(
)
)
;
$this
->
assertMatchesRegularExpression
(
'#^[0-9a-z]{40}$#',
$git
->
getLastCommitHash
(
)
)
;
$this
->
assertNotEmpty
(
$git
->
getLastAuthor
(
)
)
;
$this
->
assertInstanceOf
(
\DateTimeImmutable::
class
,
$git
->
getLastAuthoredDate
(
)
)
;
$this
->
assertStringMatchesFormat
(
'v%s',
$git
->
getLastTag
(
)
)
;
$this
->
assertStringMatchesFormat
(
'v3%s',
$git
->
getLastTag
(
fn
(
$tag
)
=>
str_starts_with
(
$tag
, 'v3'
)
)
)
;
}
public
function
testItCheckoutsToTheLastTag
(
)
{
$git
= GitRepository::
download
(
self::REPO_URL,
$this
->targetDir
)
;
$lastCommitHash
=
$git
->
getLastCommitHash
(
)
;
$lastV3Tag
=
$git
->
getLastTag
(
fn
(
$tag
)
=>
str_starts_with
(
$tag
, 'v3'
)
)
;
$generator
=
new
TimezoneDataGenerator
(
$compiler
, Intl::TIMEZONE_DIR
)
;
$generator
->
generateData
(
$config
)
;
echo
"Resource bundle compilation complete.\n";
$gitInfo
= <<<GIT_INFO Git information =============== URL: {
$git
->
getUrl
(
)
}
Revision: {
$git
->
getLastCommitHash
(
)
}
Author: {
$git
->
getLastAuthor
(
)
}
Date: {
$git
->
getLastAuthoredDate
(
)
->
format
(
'c'
)
}
GIT_INFO;
$gitInfoFile
=
$dataDir
.'/git-info.txt';
file_put_contents
(
$gitInfoFile
,
$gitInfo
)
;
echo
"Wrote
$gitInfoFile
.\n";