Files
phabricator/src/applications/diffusion/query/stablecommitname/DiffusionSvnStableCommitNameQuery.php
Bob Trahan 2f44c0fac9 Diffusion - move querying for stable commit name to occur over conduit
Summary: Ref T2784. This is a lower-level one from drequest so it gets the conditional initialization treatment. Consolidated SVN as well even though SVN is issuing database queries; I felt better about the code de-duplication despite the small performance hit when we could just query the DB directly in the SVN case.

Test Plan: browsed around my Phabricator repositories in Mercurial, Git, and SVN flavors. Looked good.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2784

Differential Revision: https://secure.phabricator.com/D5956
2013-05-17 14:12:46 -07:00

24 lines
633 B
PHP

<?php
final class DiffusionSvnStableCommitNameQuery
extends DiffusionStableCommitNameQuery {
protected function executeQuery() {
$repository = $this->getRepository();
$commit = id(new PhabricatorRepositoryCommit())
->loadOneWhere(
'repositoryID = %d ORDER BY epoch DESC LIMIT 1',
$repository->getID());
if ($commit) {
$stable_commit_name = $commit->getCommitIdentifier();
} else {
// For new repositories, we may not have parsed any commits yet. Call
// the stable commit "1" and avoid fataling.
$stable_commit_name = 1;
}
return $stable_commit_name;
}
}