From 23b86bae6c618b1b74287cb676b0722f12f21312 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 14 Apr 2019 11:50:20 -0700 Subject: [PATCH] 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 --- .../diffusion/engine/DiffusionCommitHookEngine.php | 5 +---- .../herald/DiffusionPreCommitRefTypeHeraldField.php | 1 + .../repository/storage/PhabricatorRepositoryPushLog.php | 1 + .../worker/PhabricatorRepositoryPushMailWorker.php | 4 ++++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php index 6856b8676d..6ebaf6bdc7 100644 --- a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php +++ b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php @@ -459,10 +459,7 @@ final class DiffusionCommitHookEngine extends Phobject { $ref_type = PhabricatorRepositoryPushLog::REFTYPE_TAG; $ref_raw = substr($ref_raw, strlen('refs/tags/')); } else { - throw new Exception( - pht( - "Unable to identify the reftype of '%s'. Rejecting push.", - $ref_raw)); + $ref_type = PhabricatorRepositoryPushLog::REFTYPE_REF; } $ref_update = $this->newPushLog() diff --git a/src/applications/diffusion/herald/DiffusionPreCommitRefTypeHeraldField.php b/src/applications/diffusion/herald/DiffusionPreCommitRefTypeHeraldField.php index ff71ae8713..0c18f58712 100644 --- a/src/applications/diffusion/herald/DiffusionPreCommitRefTypeHeraldField.php +++ b/src/applications/diffusion/herald/DiffusionPreCommitRefTypeHeraldField.php @@ -24,6 +24,7 @@ final class DiffusionPreCommitRefTypeHeraldField $types = array( PhabricatorRepositoryPushLog::REFTYPE_BRANCH => pht('branch (git/hg)'), PhabricatorRepositoryPushLog::REFTYPE_TAG => pht('tag (git)'), + PhabricatorRepositoryPushLog::REFTYPE_REF => pht('ref (git)'), PhabricatorRepositoryPushLog::REFTYPE_BOOKMARK => pht('bookmark (hg)'), ); diff --git a/src/applications/repository/storage/PhabricatorRepositoryPushLog.php b/src/applications/repository/storage/PhabricatorRepositoryPushLog.php index cfb5402c2a..095c227994 100644 --- a/src/applications/repository/storage/PhabricatorRepositoryPushLog.php +++ b/src/applications/repository/storage/PhabricatorRepositoryPushLog.php @@ -17,6 +17,7 @@ final class PhabricatorRepositoryPushLog const REFTYPE_TAG = 'tag'; const REFTYPE_BOOKMARK = 'bookmark'; const REFTYPE_COMMIT = 'commit'; + const REFTYPE_REF = 'ref'; const CHANGEFLAG_ADD = 1; const CHANGEFLAG_DELETE = 2; diff --git a/src/applications/repository/worker/PhabricatorRepositoryPushMailWorker.php b/src/applications/repository/worker/PhabricatorRepositoryPushMailWorker.php index 7459073ca8..7119ab42d7 100644 --- a/src/applications/repository/worker/PhabricatorRepositoryPushMailWorker.php +++ b/src/applications/repository/worker/PhabricatorRepositoryPushMailWorker.php @@ -149,6 +149,10 @@ final class PhabricatorRepositoryPushMailWorker $type_name = pht('bookmark'); $type_prefix = pht('bookmark:'); break; + case PhabricatorRepositoryPushLog::REFTYPE_REF: + $type_name = pht('ref'); + $type_prefix = pht('ref:'); + break; case PhabricatorRepositoryPushLog::REFTYPE_COMMIT: default: break;