Skip to content

Commit 790025b

Browse files
authored
Add rgh-pr-template feature (#6947)
1 parent a0db15a commit 790025b

3 files changed

Lines changed: 41 additions & 2 deletions

File tree

.github/pull_request_template.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Thanks for contributing! 🍄 Do not ignore this template, plz.
44
5-
1. Does this PR close/fix an existing issue? Write something like `Closes #10`
5+
1. Does this PR close/fix an existing issue? Write something like: Closes #10
66
77
Help us test and visualize this PR:
88
@@ -21,4 +21,3 @@ Lastly:
2121

2222

2323
## Screenshot
24-
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from 'dom-chef';
2+
import {replace} from 'text-field-edit';
3+
import * as pageDetect from 'github-url-detection';
4+
5+
import features from '../feature-manager.js';
6+
import {isRefinedGitHubRepo} from '../github-helpers/index.js';
7+
import observe from '../helpers/selector-observer.js';
8+
9+
function extract(textarea: HTMLTextAreaElement): void {
10+
replace(textarea, /<!--(.+)-->\n/s, (_, match) => {
11+
textarea.closest('tab-container')!.before(
12+
<div style={{whiteSpace: 'pre-wrap'}} className="flash mx-2 p-2">
13+
{match.trim()}
14+
</div>,
15+
);
16+
17+
return '';
18+
});
19+
}
20+
21+
function init(signal: AbortSignal): void {
22+
observe('#pull_request_body', extract, {signal});
23+
}
24+
25+
void features.add(import.meta.url, {
26+
asLongAs: [
27+
isRefinedGitHubRepo,
28+
pageDetect.isCompare,
29+
],
30+
init,
31+
});
32+
33+
/*
34+
35+
Test URLs:
36+
37+
https://github.com/refined-github/refined-github/compare/main...sandbox/keep-branch?quick_pull=1
38+
39+
*/

source/refined-github.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,4 @@ import './features/action-pr-link.js';
215215
import './features/rgh-dim-commits.js';
216216
import './features/mobile-tabs.js';
217217
import './features/repo-header-info.js';
218+
import './features/rgh-pr-template.js';

0 commit comments

Comments
 (0)