Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F106477699
DiffusionLowLevelGitCommitQuery.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
Wed, Mar 26, 02:24
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Mar 28, 02:24 (2 d)
Engine
blob
Format
Raw Data
Handle
25156309
Attached To
rPH Phabricator
DiffusionLowLevelGitCommitQuery.php
View Options
<?php
final
class
DiffusionLowLevelGitCommitQuery
extends
DiffusionLowLevelQuery
{
private
$identifier
;
public
function
withIdentifier
(
$identifier
)
{
$this
->
identifier
=
$identifier
;
return
$this
;
}
protected
function
executeQuery
()
{
$repository
=
$this
->
getRepository
();
// NOTE: %B was introduced somewhat recently in git's history, so pull
// commit message information with %s and %b instead.
// Even though we pass --encoding here, git doesn't always succeed, so
// we try a little harder, since git *does* tell us what the actual encoding
// is correctly (unless it doesn't; encoding is sometimes empty).
list
(
$info
)
=
$repository
->
execxLocalCommand
(
'log -n 1 --encoding=%s --format=%s %s --'
,
'UTF-8'
,
implode
(
'%x00'
,
array
(
'%e'
,
'%cn'
,
'%ce'
,
'%an'
,
'%ae'
,
'%s%n%n%b'
)),
$this
->
identifier
);
$parts
=
explode
(
"
\0
"
,
$info
);
$encoding
=
array_shift
(
$parts
);
foreach
(
$parts
as
$key
=>
$part
)
{
if
(
$encoding
)
{
$part
=
phutil_utf8_convert
(
$part
,
'UTF-8'
,
$encoding
);
}
$parts
[
$key
]
=
phutil_utf8ize
(
$part
);
if
(!
strlen
(
$parts
[
$key
]))
{
$parts
[
$key
]
=
null
;
}
}
return
id
(
new
DiffusionCommitRef
())
->
setCommitterName
(
$parts
[
0
])
->
setCommitterEmail
(
$parts
[
1
])
->
setAuthorName
(
$parts
[
2
])
->
setAuthorEmail
(
$parts
[
3
])
->
setMessage
(
$parts
[
4
]);
}
}
Event Timeline
Log In to Comment