Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93287378
DiffusionPreCommitContentSizeHeraldField.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, Nov 27, 15:36
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Nov 29, 15:36 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22525327
Attached To
rPH Phabricator
DiffusionPreCommitContentSizeHeraldField.php
View Options
<?php
final
class
DiffusionPreCommitContentSizeHeraldField
extends
DiffusionPreCommitContentHeraldField
{
const
FIELDCONST
=
'diffusion.pre.content.diff.size'
;
public
function
getHeraldFieldName
()
{
return
pht
(
'Files size (bytes) [Git/Svn]'
);
}
public
function
getFieldGroupKey
()
{
return
DiffusionChangeHeraldFieldGroup
::
FIELDGROUPKEY
;
}
public
function
getHeraldFieldValue
(
$object
)
{
$adapter
=
$this
->
getAdapter
();
$hook
=
$adapter
->
getHookEngine
();
$repository
=
$hook
->
getRepository
();
$vcs
=
$repository
->
getVersionControlSystem
();
$total_size
=
0
;
$ref
=
$adapter
->
getObject
()->
getRefNew
();
$changesets
=
$hook
->
getChangesetsForCommit
(
$ref
);
foreach
(
$changesets
as
$change
){
$size
=
0
;
$err
=
null
;
if
(
$vcs
==
PhabricatorRepositoryType
::
REPOSITORY_TYPE_GIT
)
{
list
(
$size
,
$err
)
=
execx
(
"git cat-file -s %s:%s"
,
$ref
,
$change
->
getFileName
());
}
elseif
(
$vcs
==
PhabricatorRepositoryType
::
REPOSITORY_TYPE_SVN
)
{
list
(
$size
,
$err
)
=
execx
(
"svnlook filesize -t %s %s %s"
,
$hook
->
getSubversionTransaction
(),
$repository
->
getLocalPath
(),
$change
->
getFileName
());
}
$total_size
+=
(
int
)
$size
;
}
return
$total_size
;
}
protected
function
getHeraldFieldStandardType
()
{
return
HeraldField
::
STANDARD_INT
;
}
}
Event Timeline
Log In to Comment