Skip to content

Commit 8d61a7c

Browse files
committed
Add similar rollup creation link to PR
1 parent c6f8fc6 commit 8d61a7c

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

cfg.production.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ${HOMU_SSH_KEY}
1818
host = '0.0.0.0'
1919
port = 80
2020

21+
base_url = "https://bors.rust-lang.org"
2122
canonical_url = "https://bors.rust-lang.org"
2223
remove_path_prefixes = ["homu"]
2324

cfg.sample.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ port = 54856
5151
# all open PRs.
5252
sync_on_start = true
5353

54+
# The base url used for links pointing to this homu instance.
55+
# If base_url is not present, links will use canonical_url as a fallback.
56+
# If neither base_url nor canonical_url are present, no links to this homu
57+
# instance will be generated.
58+
#base_url = "https://bors.example.com"
59+
5460
# The canonical URL of this homu instance. If a user reaches the instance
5561
# through a different path they will be redirected. If this is not present in
5662
# the configuration homu will still work, but no redirect will be performed.

homu/html/queue.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,14 @@ <h1>Homu queue - {% if repo_url %}<a href="{{repo_url}}" target="_blank">{{repo_
187187

188188
<tbody>
189189
{% for state in states %}
190+
{% set checkbox_state =
191+
('checked' if state.prechecked else '') if
192+
((state.status == 'approved' or (state.status == 'pending' and not state.try_)) and state.rollup != 'never')
193+
else 'disabled'
194+
%}
190195
<tr class="{{state.greyed}}">
191196
<td class="hide">{{loop.index}}</td>
192-
<td><input type="checkbox" data-num="{{state.num}}" {{ '' if ((state.status == 'approved' or (state.status == 'pending' and not state.try_)) and state.rollup != 'never') else 'disabled' }}></td>
197+
<td><input type="checkbox" data-num="{{state.num}}" {{checkbox_state}}></td>
193198
{% if multiple %}
194199
<td><a href="{{state.repo_url}}">{{state.repo_label}}</a></td>
195200
{% endif %}

homu/server.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ def queue(repo_label):
139139
except KeyError:
140140
abort(404, 'No such repository: {}'.format(label))
141141

142+
prechecked_prs = set()
143+
if request.query.get('prs'):
144+
prechecked_prs = set(request.query.get('prs').split(','))
145+
142146
pull_states = sorted(states)
143147
rows = []
144148
for state in pull_states:
@@ -154,6 +158,7 @@ def queue(repo_label):
154158
'status_ext': status_ext,
155159
'priority': state.priority,
156160
'rollup': ROLLUP_STR.get(state.rollup, ''),
161+
'prechecked': str(state.num) in prechecked_prs,
157162
'url': 'https://github.com/{}/{}/pull/{}'.format(state.owner,
158163
state.name,
159164
state.num),
@@ -329,6 +334,16 @@ def rollup(user_gh, state, repo_label, repo_cfg, repo):
329334
body += ' - #{} ({})\n'.format(x.num, x.title)
330335
body += '\nr? @ghost'
331336

337+
# Set web.base_url in cfg to enable
338+
base_url = g.cfg['web'].get('base_url')
339+
if not base_url:
340+
# If web.base_url is not present, fall back to using web.canonical_url
341+
base_url = g.cfg['web'].get('canonical_url')
342+
343+
if base_url:
344+
pr_list = ','.join(x.num for x in successes)
345+
body += '\n\n[Create a similar rollup]({}/queue/{}?prs={})'.format(base_url, repo_label, pr_list)
346+
332347
try:
333348
pull = base_repo.create_pull(
334349
title,

0 commit comments

Comments
 (0)