Skip to content

Commit d818aa3

Browse files
authored
closing-remarks - Exclude nightly tags and non-version tags (refined-github#7243)
1 parent 8813896 commit d818aa3

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

source/features/closing-remarks.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'dom-chef';
22
import {CachedFunction} from 'webext-storage-cache';
3-
import {$} from 'select-dom';
3+
import {$, $$} from 'select-dom';
44
import TagIcon from 'octicons-plain-react/Tag';
55
import * as pageDetect from 'github-url-detection';
66

@@ -18,14 +18,17 @@ import observe from '../helpers/selector-observer.js';
1818
// TODO: Not an exact match; Moderators can edit comments but not create releases
1919
const canCreateRelease = canEditEveryComment;
2020

21+
function excludeNightliesAndJunk({textContent}: HTMLAnchorElement): boolean {
22+
// https://github.com/refined-github/refined-github/issues/7206
23+
return !textContent.includes('nightly') && /\d[.]\d/.test(textContent);
24+
}
25+
2126
const firstTag = new CachedFunction('first-tag', {
2227
async updater(commit: string): Promise<string | false> {
23-
const firstTag = await fetchDom(
24-
buildRepoURL('branch_commits', commit),
25-
'ul.branches-tag-list li:last-child a',
26-
);
27-
28-
return firstTag?.textContent ?? false;
28+
const tagsAndBranches = await fetchDom(buildRepoURL('branch_commits', commit));
29+
const tags = $$('ul.branches-tag-list a', tagsAndBranches);
30+
// eslint-disable-next-line unicorn/no-array-callback-reference -- Just this once, I swear
31+
return tags.findLast(excludeNightliesAndJunk)?.textContent ?? false;
2932
},
3033
cacheKey: ([commit]) => [getRepo()!.nameWithOwner, commit].join(':'),
3134
});
@@ -147,6 +150,11 @@ Test URLs
147150
- PR: https://github.com/refined-github/refined-github/pull/5600
148151
- Locked PR: https://github.com/eslint/eslint/pull/17
149152
- Archived repo: https://github.com/fregante/iphone-inline-video/pull/130
150-
- RGH tagged PR: https://github.com/refined-github/sandbox/pull/1
153+
- Junk tag: https://github.com/refined-github/sandbox/pull/1
154+
- See: https://github.com/refined-github/sandbox/branch_commits/f743c334f6475021ef133591b587bc282c0cf4c4
155+
- Normal tag: https://togithub.com/refined-github/refined-github/pull/7127
156+
- See https://github.com/refined-github/refined-github/branch_commits/5321825
157+
- Nightly tag: https://togithub.com/neovim/neovim/pull/22060
158+
- see: https://github.com/neovim/neovim/branch_commits/27b81af
151159
152160
*/

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"lib": [
77
"DOM",
88
"DOM.Iterable",
9-
"ES2022"
9+
"ES2023"
1010
],
1111
},
1212
"include": [

0 commit comments

Comments
 (0)