summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--readme.md1
-rw-r--r--source/content.ts1
-rw-r--r--source/features/cross-deleted-pr-branches.css4
-rw-r--r--source/features/cross-deleted-pr-branches.tsx48
4 files changed, 54 insertions, 0 deletions
diff --git a/readme.md b/readme.md
index b9c7dbd0..0d53d8fc 100644
--- a/readme.md
+++ b/readme.md
@@ -242,6 +242,7 @@ Thanks for contributing! 🦋🙌
- [](# "pull-request-hotkey") Adds keyboard shortcuts to cycle through PR tabs: <kbd>g</kbd> <kbd>←</kbd> and <kbd>g</kbd> <kbd>→</kbd>, or <kbd>g</kbd> <kbd>1</kbd>, <kbd>g</kbd> <kbd>2</kbd>, <kbd>g</kbd> <kbd>3</kbd> and <kbd>g</kbd> <kbd>4</kbd>.
- [](# "pr-branch-auto-delete") Automatically deletes the branch right after merging a PR, if possible.
- [](# "separate-draft-pr-button") [Lets you create draft pull requests in one click.](https://user-images.githubusercontent.com/202916/67269317-cd791300-f4b6-11e9-89d1-392de7ef71e1.png)
+- [](# "cross-deleted-pr-branches") [Adds a line-through to the deleted branches.]('https://user-images.githubusercontent.com/16872793/75619638-9bef1300-5b4c-11ea-850e-3a8f95c86d83.png')
<!-- Refer to style guide above. Keep this message between sections. -->
diff --git a/source/content.ts b/source/content.ts
index 90291294..ac1d0d62 100644
--- a/source/content.ts
+++ b/source/content.ts
@@ -161,6 +161,7 @@ import './features/quick-mention';
import './features/extend-discussion-status-filters';
import './features/expand-all-hidden-comments';
import './features/bugs-tab';
+import './features/cross-deleted-pr-branches';
import './features/repo-wide-file-finder';
import './features/preserve-file-finder-term';
import './features/file-finder-buffer';
diff --git a/source/features/cross-deleted-pr-branches.css b/source/features/cross-deleted-pr-branches.css
new file mode 100644
index 00000000..f7795384
--- /dev/null
+++ b/source/features/cross-deleted-pr-branches.css
@@ -0,0 +1,4 @@
+.commit-ref[title='Deleted'],
+.commit-ref[title='Deleted'] * {
+ text-decoration: line-through !important;
+}
diff --git a/source/features/cross-deleted-pr-branches.tsx b/source/features/cross-deleted-pr-branches.tsx
new file mode 100644
index 00000000..c035f432
--- /dev/null
+++ b/source/features/cross-deleted-pr-branches.tsx
@@ -0,0 +1,48 @@
+import './cross-deleted-pr-branches.css';
+import React from 'dom-chef';
+import select from 'select-dom';
+import features from '../libs/features';
+import {wrap} from '../libs/dom-utils';
+
+function init(): void {
+ const lastBranchAction = select.last('.TimelineItem-body .user-select-contain > span:not(.base-ref)');
+ if (!lastBranchAction) {
+ return;
+ }
+
+ if (!lastBranchAction.closest('.TimelineItem-body')!.textContent!.includes(' deleted ')) {
+ return;
+ }
+
+ const deletedBranchName = lastBranchAction.textContent!.trim();
+
+ const headReferenceLink = select<HTMLAnchorElement>('.head-ref a')!;
+ const repoRootUrl = headReferenceLink.href.split('/', 5).join('/');
+ const repoIsDeleted = headReferenceLink.textContent === 'unknown repository';
+
+ for (const element of select.all('.commit-ref')) {
+ const branchName = element.textContent!.trim();
+ if (branchName === deletedBranchName || branchName === 'unknown repository') {
+ element.title = 'Deleted';
+
+ if (repoIsDeleted) {
+ select('a', element)?.removeAttribute('href');
+ } else if (element.classList.contains('head-ref')) {
+ select('a', element)!.href = repoRootUrl;
+ } else {
+ wrap(element, <a href={repoRootUrl}/>);
+ }
+ }
+ }
+}
+
+features.add({
+ id: __featureName__,
+ description: 'Adds a line-through to the deleted branches in PRs',
+ screenshot: 'https://user-images.githubusercontent.com/16872793/75619638-9bef1300-5b4c-11ea-850e-3a8f95c86d83.png',
+ include: [
+ features.isPRConversation
+ ],
+ load: features.onAjaxedPages,
+ init
+});