Page MenuHomec4science

DiffusionPreCommitContentSizeHeraldField.php
No OneTemporary

File Metadata

Created
Wed, Nov 27, 15:36

DiffusionPreCommitContentSizeHeraldField.php

<?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