1
1
import React from 'dom-chef' ;
2
2
import { CachedFunction } from 'webext-storage-cache' ;
3
- import { $ } from 'select-dom' ;
3
+ import { $ , $$ } from 'select-dom' ;
4
4
import TagIcon from 'octicons-plain-react/Tag' ;
5
5
import * as pageDetect from 'github-url-detection' ;
6
6
@@ -18,14 +18,17 @@ import observe from '../helpers/selector-observer.js';
18
18
// TODO: Not an exact match; Moderators can edit comments but not create releases
19
19
const canCreateRelease = canEditEveryComment ;
20
20
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
+
21
26
const firstTag = new CachedFunction ( 'first-tag' , {
22
27
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 ;
29
32
} ,
30
33
cacheKey : ( [ commit ] ) => [ getRepo ( ) ! . nameWithOwner , commit ] . join ( ':' ) ,
31
34
} ) ;
@@ -147,6 +150,11 @@ Test URLs
147
150
- PR: https://github.com/refined-github/refined-github/pull/5600
148
151
- Locked PR: https://github.com/eslint/eslint/pull/17
149
152
- 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
151
159
152
160
*/
0 commit comments