Record new commits in the push log
Summary:
Ref T4195. Like the previous diffs, these both create a useful log and give us an object to hand off to Herald.
Surface this information in Diffusion, too, and clean things up a little bit.
Test Plan: {F87565}
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T4195
Differential Revision: https://secure.phabricator.com/D7718
This commit is contained in:
@@ -403,8 +403,10 @@ final class DiffusionCommitController extends DiffusionController {
|
||||
array $audit_requests) {
|
||||
|
||||
assert_instances_of($parents, 'PhabricatorRepositoryCommit');
|
||||
$user = $this->getRequest()->getUser();
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
$commit_phid = $commit->getPHID();
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
$edge_query = id(new PhabricatorEdgeQuery())
|
||||
->withSourcePHIDs(array($commit_phid))
|
||||
@@ -440,6 +442,29 @@ final class DiffusionCommitController extends DiffusionController {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: We should never normally have more than a single push log, but
|
||||
// it can occur naturally if a commit is pushed, then the branch it was
|
||||
// on is deleted, then the commit is pushed again (or through other similar
|
||||
// chains of events). This should be rare, but does not indicate a bug
|
||||
// or data issue.
|
||||
|
||||
// NOTE: We never query push logs in SVN because the commiter is always
|
||||
// the pusher and the commit time is always the push time; the push log
|
||||
// is redundant and we save a query by skipping it.
|
||||
|
||||
$push_logs = array();
|
||||
if ($repository->isHosted() && !$repository->isSVN()) {
|
||||
$push_logs = id(new PhabricatorRepositoryPushLogQuery())
|
||||
->setViewer($viewer)
|
||||
->withRepositoryPHIDs(array($repository->getPHID()))
|
||||
->withNewRefs(array($commit->getCommitIdentifier()))
|
||||
->withRefTypes(array(PhabricatorRepositoryPushLog::REFTYPE_COMMIT))
|
||||
->execute();
|
||||
foreach ($push_logs as $log) {
|
||||
$phids[] = $log->getPusherPHID();
|
||||
}
|
||||
}
|
||||
|
||||
$handles = array();
|
||||
if ($phids) {
|
||||
$handles = $this->loadViewerHandles($phids);
|
||||
@@ -494,13 +519,52 @@ final class DiffusionCommitController extends DiffusionController {
|
||||
}
|
||||
}
|
||||
|
||||
$props['Committed'] = phabricator_datetime($commit->getEpoch(), $user);
|
||||
if (!$repository->isSVN()) {
|
||||
$authored_info = id(new PHUIStatusItemView());
|
||||
// TODO: In Git, a distinct authorship date is available. When present,
|
||||
// we should show it here.
|
||||
|
||||
$author_phid = $data->getCommitDetail('authorPHID');
|
||||
if ($data->getCommitDetail('authorPHID')) {
|
||||
$props['Author'] = $handles[$author_phid]->renderLink();
|
||||
} else {
|
||||
$props['Author'] = $data->getAuthorName();
|
||||
$author_phid = $data->getCommitDetail('authorPHID');
|
||||
$author_name = $data->getAuthorName();
|
||||
if ($author_phid) {
|
||||
$authored_info->setTarget($handles[$author_phid]->renderLink());
|
||||
} else if (strlen($author_name)) {
|
||||
$authored_info->setTarget($author_name);
|
||||
}
|
||||
|
||||
$props['Authored'] = id(new PHUIStatusListView())
|
||||
->addItem($authored_info);
|
||||
}
|
||||
|
||||
$committed_info = id(new PHUIStatusItemView())
|
||||
->setNote(phabricator_datetime($commit->getEpoch(), $viewer));
|
||||
|
||||
$committer_phid = $data->getCommitDetail('committerPHID');
|
||||
$committer_name = $data->getCommitDetail('committer');
|
||||
if ($committer_phid) {
|
||||
$committed_info->setTarget($handles[$committer_phid]->renderLink());
|
||||
} else if (strlen($committer_name)) {
|
||||
$committed_info->setTarget($committer_name);
|
||||
} else if ($author_phid) {
|
||||
$committed_info->setTarget($handles[$author_phid]->renderLink());
|
||||
} else if (strlen($author_name)) {
|
||||
$committed_info->setTarget($author_name);
|
||||
}
|
||||
|
||||
$props['Comitted'] = id(new PHUIStatusListView())
|
||||
->addItem($committed_info);
|
||||
|
||||
if ($push_logs) {
|
||||
$pushed_list = new PHUIStatusListView();
|
||||
|
||||
foreach ($push_logs as $push_log) {
|
||||
$pushed_item = id(new PHUIStatusItemView())
|
||||
->setTarget($handles[$push_log->getPusherPHID()]->renderLink())
|
||||
->setNote(phabricator_datetime($push_log->getEpoch(), $viewer));
|
||||
$pushed_list->addItem($pushed_item);
|
||||
}
|
||||
|
||||
$props['Pushed'] = $pushed_list;
|
||||
}
|
||||
|
||||
$reviewer_phid = $data->getCommitDetail('reviewerPHID');
|
||||
@@ -508,16 +572,6 @@ final class DiffusionCommitController extends DiffusionController {
|
||||
$props['Reviewer'] = $handles[$reviewer_phid]->renderLink();
|
||||
}
|
||||
|
||||
$committer = $data->getCommitDetail('committer');
|
||||
if ($committer) {
|
||||
$committer_phid = $data->getCommitDetail('committerPHID');
|
||||
if ($data->getCommitDetail('committerPHID')) {
|
||||
$props['Committer'] = $handles[$committer_phid]->renderLink();
|
||||
} else {
|
||||
$props['Committer'] = $committer;
|
||||
}
|
||||
}
|
||||
|
||||
if ($revision_phid) {
|
||||
$props['Differential Revision'] = $handles[$revision_phid]->renderLink();
|
||||
}
|
||||
@@ -530,8 +584,6 @@ final class DiffusionCommitController extends DiffusionController {
|
||||
$props['Parents'] = phutil_implode_html(" \xC2\xB7 ", $parent_links);
|
||||
}
|
||||
|
||||
$request = $this->getDiffusionRequest();
|
||||
|
||||
$props['Branches'] = phutil_tag(
|
||||
'span',
|
||||
array(
|
||||
@@ -545,7 +597,7 @@ final class DiffusionCommitController extends DiffusionController {
|
||||
),
|
||||
pht('Unknown'));
|
||||
|
||||
$callsign = $request->getRepository()->getCallsign();
|
||||
$callsign = $repository->getCallsign();
|
||||
$root = '/diffusion/'.$callsign.'/commit/'.$commit->getCommitIdentifier();
|
||||
Javelin::initBehavior(
|
||||
'diffusion-commit-branches',
|
||||
@@ -554,7 +606,7 @@ final class DiffusionCommitController extends DiffusionController {
|
||||
$root.'/tags/' => 'commit-tags',
|
||||
));
|
||||
|
||||
$refs = $this->buildRefs($request);
|
||||
$refs = $this->buildRefs($drequest);
|
||||
if ($refs) {
|
||||
$props['References'] = $refs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user