1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-16 00:38:38 +01:00
phorge-phorge/src/applications/diffusion/request/DiffusionGitRequest.php
epriestley 28d0094856 Improve ref resolution for Git branches and tags
Summary:
Fixes T7982.

  - When resolving branches, make sure they get type `'branch'`.
  - Correctly resolve refs when a repository has a branch and tag with the same name.

Test Plan: Disabled ref cache and resolved refs in a Git repository with a 'master' tag and a 'master' branch. Saw refs resolve accurately.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7982

Differential Revision: https://secure.phabricator.com/D12609
2015-04-29 13:21:12 -07:00

23 lines
474 B
PHP

<?php
final class DiffusionGitRequest extends DiffusionRequest {
public function supportsBranches() {
return true;
}
protected function isStableCommit($symbol) {
return preg_match('/^[a-f0-9]{40}\z/', $symbol);
}
public function getBranch() {
if ($this->branch) {
return $this->branch;
}
if ($this->repository) {
return $this->repository->getDefaultBranch();
}
throw new Exception('Unable to determine branch!');
}
}