Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/query/PhabricatorRepositoryPublisher.php
| Show All 32 Lines | /* -( Publishing )--------------------------------------------------------- */ | ||||
| public function shouldPublishRef(DiffusionRepositoryRef $ref) { | public function shouldPublishRef(DiffusionRepositoryRef $ref) { | ||||
| return !$this->getRefHoldReasons($ref); | return !$this->getRefHoldReasons($ref); | ||||
| } | } | ||||
| public function shouldPublishCommit(PhabricatorRepositoryCommit $commit) { | public function shouldPublishCommit(PhabricatorRepositoryCommit $commit) { | ||||
| return !$this->getCommitHoldReasons($commit); | return !$this->getCommitHoldReasons($commit); | ||||
| } | } | ||||
| public function isPermanentRef(DiffusionRepositoryRef $ref) { | |||||
| return !$this->getRefImpermanentReasons($ref); | |||||
| } | |||||
| /* -( Hold Reasons )------------------------------------------------------- */ | /* -( Hold Reasons )------------------------------------------------------- */ | ||||
| public function getRepositoryHoldReasons() { | public function getRepositoryHoldReasons() { | ||||
| $repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
| $reasons = array(); | $reasons = array(); | ||||
| if ($repository->isImporting()) { | if ($repository->isImporting()) { | ||||
| $reasons[] = self::HOLD_IMPORTING; | $reasons[] = self::HOLD_IMPORTING; | ||||
| } | } | ||||
| if ($repository->isPublishingDisabled()) { | if ($repository->isPublishingDisabled()) { | ||||
| $reasons[] = self::HOLD_PUBLISHING_DISABLED; | $reasons[] = self::HOLD_PUBLISHING_DISABLED; | ||||
| } | } | ||||
| return $reasons; | return $reasons; | ||||
| } | } | ||||
| public function getRefHoldReasons(DiffusionRepositoryRef $ref) { | public function getRefHoldReasons(DiffusionRepositoryRef $ref) { | ||||
| $repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
| $reasons = $this->getRepositoryHoldReasons(); | $reasons = $this->getRepositoryHoldReasons(); | ||||
| if (!$ref->isBranch()) { | foreach ($this->getRefImpermanentReasons($ref) as $reason) { | ||||
| $reasons[] = self::HOLD_REF_NOT_BRANCH; | $reasons[] = $reason; | ||||
| } else { | |||||
| $branch_name = $ref->getShortName(); | |||||
| if (!$repository->shouldTrackBranch($branch_name)) { | |||||
| $reasons[] = self::HOLD_UNTRACKED; | |||||
| } | |||||
| if (!$repository->isBranchPermanentRef($branch_name)) { | |||||
| $reasons[] = self::HOLD_NOT_PERMANENT_REF; | |||||
| } | |||||
| } | } | ||||
| return $reasons; | return $reasons; | ||||
| } | } | ||||
| public function getCommitHoldReasons(PhabricatorRepositoryCommit $commit) { | public function getCommitHoldReasons(PhabricatorRepositoryCommit $commit) { | ||||
| $repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
| $reasons = $this->getRepositoryHoldReasons(); | $reasons = $this->getRepositoryHoldReasons(); | ||||
| if ($repository->isGit()) { | if ($repository->isGit()) { | ||||
| if (!$commit->isPermanentCommit()) { | if (!$commit->isPermanentCommit()) { | ||||
| $reasons[] = self::HOLD_NOT_REACHABLE_FROM_PERMANENT_REF; | $reasons[] = self::HOLD_NOT_REACHABLE_FROM_PERMANENT_REF; | ||||
| } | } | ||||
| } | } | ||||
| return $reasons; | return $reasons; | ||||
| } | } | ||||
| public function getRefImpermanentReasons(DiffusionRepositoryRef $ref) { | |||||
| $repository = $this->getRepository(); | |||||
| $reasons = array(); | |||||
| if (!$ref->isBranch()) { | |||||
| $reasons[] = self::HOLD_REF_NOT_BRANCH; | |||||
| } else { | |||||
| $branch_name = $ref->getShortName(); | |||||
| if (!$repository->shouldTrackBranch($branch_name)) { | |||||
| $reasons[] = self::HOLD_UNTRACKED; | |||||
| } | |||||
| if (!$repository->isBranchPermanentRef($branch_name)) { | |||||
| $reasons[] = self::HOLD_NOT_PERMANENT_REF; | |||||
| } | |||||
| } | |||||
| return $reasons; | |||||
| } | |||||
| } | } | ||||