Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96628983
DiffusionGitExpandShortNameQuery.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Dec 29, 05:34
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Dec 31, 05:34 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23194391
Attached To
rPH Phabricator
DiffusionGitExpandShortNameQuery.php
View Options
<?php
final
class
DiffusionGitExpandShortNameQuery
extends
DiffusionExpandShortNameQuery
{
protected
function
executeQuery
()
{
$repository
=
$this
->
getRepository
();
$commit
=
$this
->
getCommit
();
$future
=
$repository
->
getLocalCommandFuture
(
'cat-file --batch'
);
$future
->
write
(
$commit
);
list
(
$stdout
)
=
$future
->
resolvex
();
list
(
$hash
,
$type
)
=
explode
(
' '
,
$stdout
);
if
(
$type
==
'missing'
)
{
throw
new
DiffusionExpandCommitQueryException
(
DiffusionExpandCommitQueryException
::
CODE_MISSING
,
"Bad commit '{$this->commit}'."
);
}
switch
(
$type
)
{
case
'tag'
:
$this
->
commitType
=
'tag'
;
$matches
=
null
;
$ok
=
preg_match
(
'/^object ([a-f0-9]+)$.*?
\n\n
(.*)$/sm'
,
$stdout
,
$matches
);
if
(!
$ok
)
{
throw
new
DiffusionExpandCommitQueryException
(
DiffusionExpandCommitQueryException
::
CODE_UNPARSEABLE
,
"Unparseable output from cat-file: {$stdout}"
);
}
$hash
=
$matches
[
1
];
$this
->
tagContent
=
trim
(
$matches
[
2
]);
break
;
case
'commit'
:
break
;
default
:
throw
new
DiffusionExpandCommitQueryException
(
DiffusionExpandCommitQueryException
::
CODE_INVALID
,
"The reference '{$this->commit}' does not name a valid "
.
'commit or a tag in this repository.'
);
break
;
}
$this
->
commit
=
$hash
;
}
}
Event Timeline
Log In to Comment