@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 PhabricatorDiffusionConfigOptions
4 extends PhabricatorApplicationConfigOptions {
5
6 public function getName() {
7 return pht('Diffusion');
8 }
9
10 public function getDescription() {
11 return pht('Configure Diffusion repository browsing.');
12 }
13
14 public function getIcon() {
15 return 'fa-code';
16 }
17
18 public function getGroup() {
19 return 'apps';
20 }
21
22 public function getApplicationClassName() {
23 return PhabricatorDiffusionApplication::class;
24 }
25
26 public function getOptions() {
27 $custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType';
28
29 $fields = array(
30 new PhabricatorCommitRepositoryField(),
31 new PhabricatorCommitBranchesField(),
32 new PhabricatorCommitTagsField(),
33 new PhabricatorCommitMergedCommitsField(),
34 );
35
36 $default_fields = array();
37 foreach ($fields as $field) {
38 $default_fields[$field->getFieldKey()] = array(
39 'disabled' => $field->shouldDisableByDefault(),
40 );
41 }
42
43 return array(
44 $this->newOption(
45 'metamta.diffusion.attach-patches',
46 'bool',
47 false)
48 ->setBoolOptions(
49 array(
50 pht('Attach Patches'),
51 pht('Do Not Attach Patches'),
52 ))
53 ->setDescription(
54 pht(
55 'Set this to true if you want patches to be attached to commit '.
56 'notifications from Diffusion.')),
57 $this->newOption('metamta.diffusion.inline-patches', 'int', 0)
58 ->setSummary(pht('Include patches in Diffusion mail as body text.'))
59 ->setDescription(
60 pht(
61 'To include patches in Diffusion email bodies, set this to a '.
62 'positive integer. Patches will be inlined if they are at most '.
63 'that many lines. By default, patches are not inlined.')),
64 $this->newOption('metamta.diffusion.byte-limit', 'int', 1024 * 1024)
65 ->setDescription(pht('Hard byte limit on including patches in email.')),
66 $this->newOption('metamta.diffusion.time-limit', 'int', 60)
67 ->setDescription(pht('Hard time limit on generating patches.')),
68
69 $this->newOption('bugtraq.url', 'string', null)
70 ->addExample('https://bugs.php.net/%BUGID%', pht('PHP bugs'))
71 ->addExample('/%BUGID%', pht('Local Maniphest URL'))
72 ->setDescription(
73 pht(
74 'URL of external bug tracker used by Diffusion. %s will be '.
75 'substituted by the bug ID.',
76 '%BUGID%')),
77 $this->newOption('bugtraq.logregex', 'list<regex>', array())
78 ->addExample(array('/\B#([1-9]\d*)\b/'), pht('Issue #123'))
79 ->addExample(
80 array('/[Ii]ssues?:?(\s*,?\s*#\d+)+/', '/(\d+)/'),
81 pht('Issue #123, #456'))
82 ->addExample(array('/(?<!#)\b(T[1-9]\d*)\b/'), pht('Task T123'))
83 ->addExample('/[A-Z]{2,}-\d+/', pht('JIRA-1234'))
84 ->setDescription(
85 pht(
86 'Regular expression to link external bug tracker. See '.
87 'https://tortoisesvn.net/docs/release/TortoiseSVN_en/'.
88 'tsvn-dug-bugtracker.html for further explanation.')),
89 $this->newOption('diffusion.allow-http-auth', 'bool', false)
90 ->setBoolOptions(
91 array(
92 pht('Allow HTTP Basic Auth'),
93 pht('Disallow HTTP Basic Auth'),
94 ))
95 ->setSummary(pht('Enable HTTP Basic Auth for repositories.'))
96 ->setDescription(
97 pht(
98 "This server can serve repositories over HTTP, using HTTP basic ".
99 "auth.\n\n".
100 "Because HTTP basic auth is less secure than SSH auth, it is ".
101 "disabled by default. You can enable it here if you'd like to use ".
102 "it anyway. There's nothing fundamentally insecure about it as ".
103 "long as this server uses HTTPS, but it presents a much lower ".
104 "barrier to attackers than SSH does.\n\n".
105 "Consider using SSH for authenticated access to repositories ".
106 "instead of HTTP.")),
107 $this->newOption('diffusion.allow-git-lfs', 'bool', false)
108 ->setBoolOptions(
109 array(
110 pht('Allow Git LFS'),
111 pht('Disallow Git LFS'),
112 ))
113 ->setLocked(true)
114 ->setSummary(pht('Allow Git Large File Storage (LFS).'))
115 ->setDescription(
116 pht(
117 'This server supports Git LFS, a Git extension for storing large '.
118 'files alongside a repository. Activate this setting to allow '.
119 'the extension to store file data.')),
120 $this->newOption('diffusion.ssh-user', 'string', null)
121 ->setLocked(true)
122 ->setSummary(pht('Login username for SSH connections to repositories.'))
123 ->setDescription(
124 pht(
125 'When constructing clone URIs to show to users, Diffusion will '.
126 'fill in this login username. If you have configured a VCS user '.
127 'like `git`, you should provide it here.')),
128 $this->newOption('diffusion.ssh-port', 'int', null)
129 ->setLocked(true)
130 ->setSummary(pht('Port for SSH connections to repositories.'))
131 ->setDescription(
132 pht(
133 'When constructing clone URIs to show to users, Diffusion by '.
134 'default will not display a port assuming the default for your '.
135 'VCS. Explicitly declare when running on a non-standard port.')),
136 $this->newOption('diffusion.ssh-host', 'string', null)
137 ->setLocked(true)
138 ->setSummary(pht('Host for SSH connections to repositories.'))
139 ->setDescription(
140 pht(
141 'If you accept SSH traffic on a different host from web traffic '.
142 '(for example, if you use different SSH and web load balancers), '.
143 'you can set the SSH hostname here. This is an advanced option.')),
144 $this->newOption('diffusion.fields', $custom_field_type, $default_fields)
145 ->setCustomData(
146 id(new PhabricatorRepositoryCommit())
147 ->getCustomFieldBaseClass())
148 ->setDescription(
149 pht('Select and reorder Diffusion fields.')),
150 );
151 }
152
153}