Differential D25141 Diff 550 src/applications/config/controller/PhabricatorConfigConsoleController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/controller/PhabricatorConfigConsoleController.php
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | final class PhabricatorConfigConsoleController | ||||
public function newLibraryVersionTable() { | public function newLibraryVersionTable() { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$versions = $this->loadVersions($viewer); | $versions = $this->loadVersions($viewer); | ||||
$rows = array(); | $rows = array(); | ||||
foreach ($versions as $name => $info) { | foreach ($versions as $name => $info) { | ||||
$branchpoint = $info['branchpoint']; | $branchpoint = $info['branchpoint']; | ||||
if (strlen($branchpoint)) { | if (phutil_nonempty_string($branchpoint)) { | ||||
valerio.bozzolan: ✅ This is safe to be considered NULL or a string since `$branchpoint` defined by `loadVersion… | |||||
$branchpoint = substr($branchpoint, 0, 12); | $branchpoint = substr($branchpoint, 0, 12); | ||||
} else { | } else { | ||||
$branchpoint = null; | $branchpoint = null; | ||||
} | } | ||||
$version = $info['hash']; | $version = $info['hash']; | ||||
if (strlen($version)) { | if (phutil_nonempty_string($version)) { | ||||
Done Inline Actions✅ This is safe to be considered NULL or a string since $info['hash'] defined by private loadVersion() is so. Alien values will be reported and that is OK. valerio.bozzolan: ✅ This is safe to be considered NULL or a string since `$info['hash']` defined by private… | |||||
$version = substr($version, 0, 12); | $version = substr($version, 0, 12); | ||||
} else { | } else { | ||||
$version = pht('Unknown'); | $version = pht('Unknown'); | ||||
} | } | ||||
$epoch = $info['epoch']; | $epoch = $info['epoch']; | ||||
if ($epoch) { | if ($epoch) { | ||||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | if ($upstream_futures) { | ||||
id(new FutureIterator($upstream_futures)) | id(new FutureIterator($upstream_futures)) | ||||
->resolveAll(); | ->resolveAll(); | ||||
} | } | ||||
$results = array(); | $results = array(); | ||||
foreach ($log_futures as $lib => $future) { | foreach ($log_futures as $lib => $future) { | ||||
list($err, $stdout) = $future->resolve(); | list($err, $stdout) = $future->resolve(); | ||||
if (!$err) { | if (!$err) { | ||||
list($hash, $epoch) = explode(' ', $stdout); | list($hash, $epoch) = explode(' ', $stdout); | ||||
Done Inline Actions✅ Noted: $hash is a string since it's a parsing of the stdout. valerio.bozzolan: ✅ Noted: `$hash` is a string since it's a parsing of the `stdout`. | |||||
} else { | } else { | ||||
$hash = null; | $hash = null; | ||||
$epoch = null; | $epoch = null; | ||||
} | } | ||||
$result = array( | $result = array( | ||||
'hash' => $hash, | 'hash' => $hash, | ||||
'epoch' => $epoch, | 'epoch' => $epoch, | ||||
'upstream' => null, | 'upstream' => null, | ||||
'branchpoint' => null, | 'branchpoint' => null, | ||||
); | ); | ||||
$upstream_future = idx($upstream_futures, $lib); | $upstream_future = idx($upstream_futures, $lib); | ||||
if ($upstream_future) { | if ($upstream_future) { | ||||
list($err, $stdout) = $upstream_future->resolve(); | list($err, $stdout) = $upstream_future->resolve(); | ||||
if (!$err) { | if (!$err) { | ||||
$branchpoint = trim($stdout); | $branchpoint = trim($stdout); | ||||
Done Inline Actions✅ Noted: $branchpoint is a string valerio.bozzolan: ✅ Noted: `$branchpoint` is a string | |||||
if (strlen($branchpoint)) { | if (strlen($branchpoint)) { | ||||
// We only list a branchpoint if it differs from HEAD. | // We only list a branchpoint if it differs from HEAD. | ||||
if ($branchpoint != $hash) { | if ($branchpoint != $hash) { | ||||
$result['upstream'] = $lib_upstreams[$lib]; | $result['upstream'] = $lib_upstreams[$lib]; | ||||
$result['branchpoint'] = trim($stdout); | $result['branchpoint'] = trim($stdout); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
✅ This is safe to be considered NULL or a string since $branchpoint defined by loadVersion() is so. Alien values will be reported and that is OK.