1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Accept pushes with arbitrary Git refs

Summary:
Depends on D20419. Ref T13277. Fixes T8936. Fixes T9383. Fixes T12300. When you push arbitrary refs to Phabricator, the push log currently complains if those refs are not tags or branches.

Upstream Git now features "notes", and there's no reason to prevent writes to arbitrary refs, particularly beause we plan to start using them soon (see T13278).

Allow these writes as affecting raw refs.

Test Plan:
  - Pushed an arbitrary ref.
  - Pushed some Git notes.
  - Wrote a Herald ref rule, saw "ref" in the dropdown.

{F6376492}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13277, T8936, T9383, T12300

Differential Revision: https://secure.phabricator.com/D20420
This commit is contained in:
epriestley 2019-04-14 11:50:20 -07:00
parent 870b01f2d0
commit 23b86bae6c
4 changed files with 7 additions and 4 deletions

View file

@ -459,10 +459,7 @@ final class DiffusionCommitHookEngine extends Phobject {
$ref_type = PhabricatorRepositoryPushLog::REFTYPE_TAG; $ref_type = PhabricatorRepositoryPushLog::REFTYPE_TAG;
$ref_raw = substr($ref_raw, strlen('refs/tags/')); $ref_raw = substr($ref_raw, strlen('refs/tags/'));
} else { } else {
throw new Exception( $ref_type = PhabricatorRepositoryPushLog::REFTYPE_REF;
pht(
"Unable to identify the reftype of '%s'. Rejecting push.",
$ref_raw));
} }
$ref_update = $this->newPushLog() $ref_update = $this->newPushLog()

View file

@ -24,6 +24,7 @@ final class DiffusionPreCommitRefTypeHeraldField
$types = array( $types = array(
PhabricatorRepositoryPushLog::REFTYPE_BRANCH => pht('branch (git/hg)'), PhabricatorRepositoryPushLog::REFTYPE_BRANCH => pht('branch (git/hg)'),
PhabricatorRepositoryPushLog::REFTYPE_TAG => pht('tag (git)'), PhabricatorRepositoryPushLog::REFTYPE_TAG => pht('tag (git)'),
PhabricatorRepositoryPushLog::REFTYPE_REF => pht('ref (git)'),
PhabricatorRepositoryPushLog::REFTYPE_BOOKMARK => pht('bookmark (hg)'), PhabricatorRepositoryPushLog::REFTYPE_BOOKMARK => pht('bookmark (hg)'),
); );

View file

@ -17,6 +17,7 @@ final class PhabricatorRepositoryPushLog
const REFTYPE_TAG = 'tag'; const REFTYPE_TAG = 'tag';
const REFTYPE_BOOKMARK = 'bookmark'; const REFTYPE_BOOKMARK = 'bookmark';
const REFTYPE_COMMIT = 'commit'; const REFTYPE_COMMIT = 'commit';
const REFTYPE_REF = 'ref';
const CHANGEFLAG_ADD = 1; const CHANGEFLAG_ADD = 1;
const CHANGEFLAG_DELETE = 2; const CHANGEFLAG_DELETE = 2;

View file

@ -149,6 +149,10 @@ final class PhabricatorRepositoryPushMailWorker
$type_name = pht('bookmark'); $type_name = pht('bookmark');
$type_prefix = pht('bookmark:'); $type_prefix = pht('bookmark:');
break; break;
case PhabricatorRepositoryPushLog::REFTYPE_REF:
$type_name = pht('ref');
$type_prefix = pht('ref:');
break;
case PhabricatorRepositoryPushLog::REFTYPE_COMMIT: case PhabricatorRepositoryPushLog::REFTYPE_COMMIT:
default: default:
break; break;