mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 13:00:56 +01:00
Restore some commit metadata to browse views.
This commit is contained in:
parent
e6cf7a9cb0
commit
e25c58ed9c
8 changed files with 131 additions and 6 deletions
|
@ -83,6 +83,15 @@ final class DiffusionPathChange {
|
||||||
return $this->commitIdentifier;
|
return $this->commitIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final public function setTargetCommitIdentifier($target_commit_identifier) {
|
||||||
|
$this->targetCommitIdentifier = $target_commit_identifier;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function getTargetCommitIdentifier() {
|
||||||
|
return $this->targetCommitIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
final public function setCommit($commit) {
|
final public function setCommit($commit) {
|
||||||
$this->commit = $commit;
|
$this->commit = $commit;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -23,6 +23,9 @@ final class DiffusionRepositoryPath {
|
||||||
private $fileType;
|
private $fileType;
|
||||||
private $fileSize;
|
private $fileSize;
|
||||||
|
|
||||||
|
private $lastModifiedCommit;
|
||||||
|
private $lastCommitData;
|
||||||
|
|
||||||
final public function setPath($path) {
|
final public function setPath($path) {
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -41,6 +44,26 @@ final class DiffusionRepositoryPath {
|
||||||
return $this->hash;
|
return $this->hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final public function setLastModifiedCommit(
|
||||||
|
PhabricatorRepositoryCommit $commit) {
|
||||||
|
$this->lastModifiedCommit = $commit;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function getLastModifiedCommit() {
|
||||||
|
return $this->lastModifiedCommit;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function setLastCommitData(
|
||||||
|
PhabricatorRepositoryCommitData $last_commit_data) {
|
||||||
|
$this->lastCommitData = $last_commit_data;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function getLastCommitData() {
|
||||||
|
return $this->lastCommitData;
|
||||||
|
}
|
||||||
|
|
||||||
final public function setFileType($file_type) {
|
final public function setFileType($file_type) {
|
||||||
$this->fileType = $file_type;
|
$this->fileType = $file_type;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -123,6 +123,32 @@ final class DiffusionSvnBrowseQuery extends DiffusionBrowseQuery {
|
||||||
$path_id,
|
$path_id,
|
||||||
implode(', ', $sql));
|
implode(', ', $sql));
|
||||||
|
|
||||||
|
$loadable_commits = array();
|
||||||
|
foreach ($browse as $key => $file) {
|
||||||
|
// We need to strip out directories because we don't store last-modified
|
||||||
|
// in the filesystem table.
|
||||||
|
if ($file['fileType'] != DifferentialChangeType::FILE_DIRECTORY) {
|
||||||
|
$loadable_commits[] = $file['svnCommit'];
|
||||||
|
$browse[$key]['hasCommit'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$commits = array();
|
||||||
|
$commit_data = array();
|
||||||
|
if ($loadable_commits) {
|
||||||
|
// NOTE: Even though these are integers, use '%Ls' because MySQL doesn't
|
||||||
|
// use the second part of the key otherwise!
|
||||||
|
$commits = id(new PhabricatorRepositoryCommit())->loadAllWhere(
|
||||||
|
'repositoryID = %d AND commitIdentifier IN (%Ls)',
|
||||||
|
$repository->getID(),
|
||||||
|
$loadable_commits);
|
||||||
|
$commits = mpull($commits, null, 'getCommitIdentifier');
|
||||||
|
$commit_data = id(new PhabricatorRepositoryCommitData())->loadAllWhere(
|
||||||
|
'commitID in (%Ld)',
|
||||||
|
mpull($commits, 'getID'));
|
||||||
|
$commit_data = mpull($commit_data, null, 'getCommitID');
|
||||||
|
}
|
||||||
|
|
||||||
$path_normal = DiffusionGitPathIDQuery::normalizePath($path);
|
$path_normal = DiffusionGitPathIDQuery::normalizePath($path);
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
|
@ -137,6 +163,15 @@ final class DiffusionSvnBrowseQuery extends DiffusionBrowseQuery {
|
||||||
$result->setFileType($file['fileType']);
|
$result->setFileType($file['fileType']);
|
||||||
// $result->setFileSize($size);
|
// $result->setFileSize($size);
|
||||||
|
|
||||||
|
if (!empty($file['hasCommit'])) {
|
||||||
|
$commit = idx($commits, $file['svnCommit']);
|
||||||
|
if ($commit) {
|
||||||
|
$data = idx($commit_data, $commit->getID());
|
||||||
|
$result->setLastModifiedCommit($commit);
|
||||||
|
$result->setLastCommitData($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$results[] = $result;
|
$results[] = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,12 @@ phutil_require_module('phabricator', 'applications/differential/constants/change
|
||||||
phutil_require_module('phabricator', 'applications/diffusion/data/repositorypath');
|
phutil_require_module('phabricator', 'applications/diffusion/data/repositorypath');
|
||||||
phutil_require_module('phabricator', 'applications/diffusion/query/browse/base');
|
phutil_require_module('phabricator', 'applications/diffusion/query/browse/base');
|
||||||
phutil_require_module('phabricator', 'applications/diffusion/query/pathid/base');
|
phutil_require_module('phabricator', 'applications/diffusion/query/pathid/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/repository/storage/commit');
|
||||||
|
phutil_require_module('phabricator', 'applications/repository/storage/commitdata');
|
||||||
phutil_require_module('phabricator', 'applications/repository/storage/repository');
|
phutil_require_module('phabricator', 'applications/repository/storage/repository');
|
||||||
phutil_require_module('phabricator', 'storage/queryfx');
|
phutil_require_module('phabricator', 'storage/queryfx');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('DiffusionSvnBrowseQuery.php');
|
phutil_require_source('DiffusionSvnBrowseQuery.php');
|
||||||
|
|
|
@ -62,6 +62,8 @@ class DiffusionPathChangeQuery {
|
||||||
$changes = array();
|
$changes = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$raw_changes = isort($raw_changes, 'pathName');
|
$raw_changes = isort($raw_changes, 'pathName');
|
||||||
foreach ($raw_changes as $raw_change) {
|
foreach ($raw_changes as $raw_change) {
|
||||||
$type = $raw_change['changeType'];
|
$type = $raw_change['changeType'];
|
||||||
|
|
|
@ -27,6 +27,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
$request = $this->getDiffusionRequest();
|
$request = $this->getDiffusionRequest();
|
||||||
|
$repository = $request->getRepository();
|
||||||
|
|
||||||
$base_path = trim($request->getPath(), '/');
|
$base_path = trim($request->getPath(), '/');
|
||||||
if ($base_path) {
|
if ($base_path) {
|
||||||
|
@ -39,18 +40,53 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
if ($path->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
|
if ($path->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
|
||||||
$browse_text = $path->getPath().'/';
|
$browse_text = $path->getPath().'/';
|
||||||
$dir_slash = '/';
|
$dir_slash = '/';
|
||||||
|
|
||||||
|
$browse_link = '<strong>'.$this->linkBrowse(
|
||||||
|
$base_path.$path->getPath().$dir_slash,
|
||||||
|
array(
|
||||||
|
'text' => $browse_text,
|
||||||
|
)).'</strong>';
|
||||||
} else {
|
} else {
|
||||||
$browse_text = $path->getPath();
|
$browse_text = $path->getPath();
|
||||||
$dir_slash = null;
|
$dir_slash = null;
|
||||||
|
$browse_link = $this->linkBrowse(
|
||||||
|
$base_path.$path->getPath().$dir_slash,
|
||||||
|
array(
|
||||||
|
'text' => $browse_text,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$commit = $path->getLastModifiedCommit();
|
||||||
|
if ($commit) {
|
||||||
|
$epoch = $commit->getEpoch();
|
||||||
|
$modified = $this->linkCommit(
|
||||||
|
$repository,
|
||||||
|
$commit->getCommitIdentifier());
|
||||||
|
$date = date('M j, Y', $epoch);
|
||||||
|
$time = date('g:i A', $epoch);
|
||||||
|
} else {
|
||||||
|
$modified = '';
|
||||||
|
$date = '';
|
||||||
|
$time = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $path->getLastCommitData();
|
||||||
|
if ($data) {
|
||||||
|
$author = phutil_escape_html($data->getAuthorName());
|
||||||
|
$details = phutil_escape_html($data->getSummary());
|
||||||
|
} else {
|
||||||
|
$author = '';
|
||||||
|
$details = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
$this->linkHistory($base_path.$path->getPath().$dir_slash),
|
$this->linkHistory($base_path.$path->getPath().$dir_slash),
|
||||||
$this->linkBrowse(
|
$browse_link,
|
||||||
$base_path.$path->getPath().$dir_slash,
|
$modified,
|
||||||
array(
|
$date,
|
||||||
'text' => $browse_text,
|
$time,
|
||||||
)),
|
$author,
|
||||||
|
$details,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,11 +95,21 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
array(
|
array(
|
||||||
'History',
|
'History',
|
||||||
'Path',
|
'Path',
|
||||||
|
'Modified',
|
||||||
|
'Date',
|
||||||
|
'Time',
|
||||||
|
'Author',
|
||||||
|
'Details',
|
||||||
));
|
));
|
||||||
$view->setColumnClasses(
|
$view->setColumnClasses(
|
||||||
array(
|
array(
|
||||||
'',
|
'',
|
||||||
'wide pri',
|
'',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'right',
|
||||||
|
'',
|
||||||
|
'wide',
|
||||||
));
|
));
|
||||||
return $view->render();
|
return $view->render();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,5 +10,7 @@ phutil_require_module('phabricator', 'applications/differential/constants/change
|
||||||
phutil_require_module('phabricator', 'applications/diffusion/view/base');
|
phutil_require_module('phabricator', 'applications/diffusion/view/base');
|
||||||
phutil_require_module('phabricator', 'view/control/table');
|
phutil_require_module('phabricator', 'view/control/table');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'markup');
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('DiffusionBrowseTableView.php');
|
phutil_require_source('DiffusionBrowseTableView.php');
|
||||||
|
|
|
@ -32,4 +32,8 @@ class PhabricatorRepositoryCommitData extends PhabricatorRepositoryDAO {
|
||||||
) + parent::getConfiguration();
|
) + parent::getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSummary() {
|
||||||
|
return substr($this->getCommitMessage(), 0, 80);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue