Skip to content

Commit

Permalink
Run clear-pr-merge-commit-message only once per load (#6330)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Feb 11, 2023
1 parent 10a6b6c commit 6914b06
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions source/features/clear-pr-merge-commit-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import features from '../feature-manager';
import {getBranches} from './update-pr-from-base-branch';
import getDefaultBranch from '../github-helpers/get-default-branch';
import onPrMergePanelOpen from '../github-events/on-pr-merge-panel-open';
import attachElement from '../helpers/attach-element';

async function init(): Promise<void | false> {
// Only run once so that it doesn't clear the field every time it's opened
features.unload(import.meta.url);

const messageField = select('textarea#merge_message_field')!;
const originalMessage = messageField.value;
const preservedContent = new Set();
Expand All @@ -33,12 +37,16 @@ async function init(): Promise<void | false> {
}

set(messageField, cleanedMessage);
messageField.after(
<p className="note">
The description field was cleared by <a target="_blank" href="https://github.com/refined-github/refined-github/wiki/Extended-feature-descriptions#clear-pr-merge-commit-message" rel="noreferrer">Refined GitHub</a>.
</p>,
<hr/>,
);
attachElement(messageField, {
after: () => (
<div>
<p className="note">
The description field was cleared by <a target="_blank" href="https://github.com/refined-github/refined-github/wiki/Extended-feature-descriptions#clear-pr-merge-commit-message" rel="noreferrer">Refined GitHub</a>.
</p>
<hr/>
</div>
),
});
}

void features.add(import.meta.url, {
Expand Down

0 comments on commit 6914b06

Please sign in to comment.