mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 04:50:55 +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;
|
||||
}
|
||||
|
||||
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) {
|
||||
$this->commit = $commit;
|
||||
return $this;
|
||||
|
|
|
@ -23,6 +23,9 @@ final class DiffusionRepositoryPath {
|
|||
private $fileType;
|
||||
private $fileSize;
|
||||
|
||||
private $lastModifiedCommit;
|
||||
private $lastCommitData;
|
||||
|
||||
final public function setPath($path) {
|
||||
$this->path = $path;
|
||||
return $this;
|
||||
|
@ -41,6 +44,26 @@ final class DiffusionRepositoryPath {
|
|||
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) {
|
||||
$this->fileType = $file_type;
|
||||
return $this;
|
||||
|
|
|
@ -123,6 +123,32 @@ final class DiffusionSvnBrowseQuery extends DiffusionBrowseQuery {
|
|||
$path_id,
|
||||
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);
|
||||
|
||||
$results = array();
|
||||
|
@ -137,6 +163,15 @@ final class DiffusionSvnBrowseQuery extends DiffusionBrowseQuery {
|
|||
$result->setFileType($file['fileType']);
|
||||
// $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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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/query/browse/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', 'storage/queryfx');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionSvnBrowseQuery.php');
|
||||
|
|
|
@ -62,6 +62,8 @@ class DiffusionPathChangeQuery {
|
|||
$changes = array();
|
||||
|
||||
|
||||
|
||||
|
||||
$raw_changes = isort($raw_changes, 'pathName');
|
||||
foreach ($raw_changes as $raw_change) {
|
||||
$type = $raw_change['changeType'];
|
||||
|
|
|
@ -27,6 +27,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
|
||||
public function render() {
|
||||
$request = $this->getDiffusionRequest();
|
||||
$repository = $request->getRepository();
|
||||
|
||||
$base_path = trim($request->getPath(), '/');
|
||||
if ($base_path) {
|
||||
|
@ -39,18 +40,53 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
if ($path->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
|
||||
$browse_text = $path->getPath().'/';
|
||||
$dir_slash = '/';
|
||||
|
||||
$browse_link = '<strong>'.$this->linkBrowse(
|
||||
$base_path.$path->getPath().$dir_slash,
|
||||
array(
|
||||
'text' => $browse_text,
|
||||
)).'</strong>';
|
||||
} else {
|
||||
$browse_text = $path->getPath();
|
||||
$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(
|
||||
$this->linkHistory($base_path.$path->getPath().$dir_slash),
|
||||
$this->linkBrowse(
|
||||
$base_path.$path->getPath().$dir_slash,
|
||||
array(
|
||||
'text' => $browse_text,
|
||||
)),
|
||||
$browse_link,
|
||||
$modified,
|
||||
$date,
|
||||
$time,
|
||||
$author,
|
||||
$details,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -59,11 +95,21 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
array(
|
||||
'History',
|
||||
'Path',
|
||||
'Modified',
|
||||
'Date',
|
||||
'Time',
|
||||
'Author',
|
||||
'Details',
|
||||
));
|
||||
$view->setColumnClasses(
|
||||
array(
|
||||
'',
|
||||
'wide pri',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'right',
|
||||
'',
|
||||
'wide',
|
||||
));
|
||||
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', 'view/control/table');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionBrowseTableView.php');
|
||||
|
|
|
@ -32,4 +32,8 @@ class PhabricatorRepositoryCommitData extends PhabricatorRepositoryDAO {
|
|||
) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
public function getSummary() {
|
||||
return substr($this->getCommitMessage(), 0, 80);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue