forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorRepositoryBranch.php
43 lines (36 loc) · 1.07 KB
/
PhabricatorRepositoryBranch.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
final class PhabricatorRepositoryBranch extends PhabricatorRepositoryDAO {
protected $repositoryID;
protected $name;
protected $lintCommit;
protected function getConfiguration() {
return array(
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text128',
'lintCommit' => 'text40?',
),
self::CONFIG_KEY_SCHEMA => array(
'repositoryID' => array(
'columns' => array('repositoryID', 'name'),
'unique' => true,
),
),
) + parent::getConfiguration();
}
public static function loadBranch($repository_id, $branch_name) {
return id(new PhabricatorRepositoryBranch())->loadOneWhere(
'repositoryID = %d AND name = %s',
$repository_id,
$branch_name);
}
public static function loadOrCreateBranch($repository_id, $branch_name) {
$branch = self::loadBranch($repository_id, $branch_name);
if ($branch) {
return $branch;
}
return id(new PhabricatorRepositoryBranch())
->setRepositoryID($repository_id)
->setName($branch_name)
->save();
}
}