Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F106950000
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, Apr 2, 22:11
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Apr 4, 22:11 (2 d)
Engine
blob
Format
Raw Data
Handle
25292549
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
(
'Total files size (bytes)'
);
}
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
->
loadChangesetsForCommit
(
$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
;
}
function
supportsObject
(
$object
)
{
if
(
$object
->
getRepository
()->
isHg
())
{
return
false
;
}
return
parent
::
supportsObject
(
$object
);
}
}
Event Timeline
Log In to Comment