@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at recaptime-dev/main 41 lines 1.0 kB view raw
1<?php 2 3final class DiffusionPreCommitUsesGitLFSHeraldField 4 extends DiffusionPreCommitContentHeraldField { 5 6 const FIELDCONST = 'diffusion.pre.commit.git-lfs'; 7 8 public function getHeraldFieldName() { 9 return pht('Commit uses Git LFS'); 10 } 11 12 public function getFieldGroupKey() { 13 return DiffusionChangeHeraldFieldGroup::FIELDGROUPKEY; 14 } 15 16 public function getHeraldFieldValue($object) { 17 $map = $this->getAdapter()->getDiffContent('+'); 18 19 // At the time of writing, all current Git LFS files begin with this 20 // line, verbatim: 21 // 22 // version https://git-lfs.github.com/spec/v1 23 // 24 // ...but we don't try to match the specific version here, in the hopes 25 // that this might also detect future versions. 26 $pattern = '(^version\s*https://git-lfs.github.com/spec/)i'; 27 28 foreach ($map as $path => $content) { 29 if (preg_match($pattern, $content)) { 30 return true; 31 } 32 } 33 34 return false; 35 } 36 37 protected function getHeraldFieldStandardType() { 38 return self::STANDARD_BOOL; 39 } 40 41}