@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorRepositoryBranch extends PhabricatorRepositoryDAO {
4
5 protected $repositoryID;
6 protected $name;
7 protected $lintCommit;
8
9 protected function getConfiguration() {
10 return array(
11 self::CONFIG_COLUMN_SCHEMA => array(
12 'name' => 'text128',
13 'lintCommit' => 'text40?',
14 ),
15 self::CONFIG_KEY_SCHEMA => array(
16 'repositoryID' => array(
17 'columns' => array('repositoryID', 'name'),
18 'unique' => true,
19 ),
20 ),
21 ) + parent::getConfiguration();
22 }
23
24 public static function loadBranch($repository_id, $branch_name) {
25 return id(new PhabricatorRepositoryBranch())->loadOneWhere(
26 'repositoryID = %d AND name = %s',
27 $repository_id,
28 $branch_name);
29 }
30
31 public static function loadOrCreateBranch($repository_id, $branch_name) {
32 $branch = self::loadBranch($repository_id, $branch_name);
33 if ($branch) {
34 return $branch;
35 }
36
37 return id(new PhabricatorRepositoryBranch())
38 ->setRepositoryID($repository_id)
39 ->setName($branch_name)
40 ->save();
41 }
42
43}