@@ -8,7 +8,11 @@ import { prepareGitHubHighlighter } from './githubHighlighter'
8
8
interface GitHubPRNewCommentSpot extends CommentSpot {
9
9
type : 'GH_PR_NEW_COMMENT'
10
10
domain : string
11
- slug : string // owner/repo/base-branch/compare-branch
11
+ slug : string // owner/repo
12
+ title : string
13
+ head : string // branch name where changes are implemented
14
+ head_repo ?: string // repository where changes were made (for cross-repo PRs)
15
+ base : string // branch you want changes pulled into
12
16
}
13
17
14
18
export class GitHubPRNewCommentEnhancer implements CommentEnhancer < GitHubPRNewCommentSpot > {
@@ -38,13 +42,25 @@ export class GitHubPRNewCommentEnhancer implements CommentEnhancer<GitHubPRNewCo
38
42
39
43
if ( ! match ) return null
40
44
const [ , owner , repo , baseBranch , compareBranch ] = match
41
- const slug = baseBranch
42
- ? `${ owner } /${ repo } /${ baseBranch } ...${ compareBranch } `
43
- : `${ owner } /${ repo } /${ compareBranch } `
44
- const unique_key = `github.com:${ slug } `
45
+ const slug = `${ owner } /${ repo } `
46
+ const base = baseBranch || 'main'
47
+ const head = compareBranch
48
+ const unique_key = `github.com:${ slug } :${ base } ...${ head } `
49
+ const titleInput = document . querySelector ( 'input[placeholder="Title"]' ) as HTMLInputElement
50
+ const title = titleInput ?. value || ''
51
+
52
+ // Check if this is a cross-repository PR by looking at the head repository button
53
+ const headRepoButton = document . querySelector ( 'button[aria-label*="head repository:"]' )
54
+ const headRepoText = headRepoButton ?. textContent
55
+ const headRepo = headRepoText ?. includes ( '/' ) ? headRepoText . split ( ':' ) [ 1 ] ?. trim ( ) : undefined
56
+
45
57
return {
46
58
domain : location . host ,
47
59
slug,
60
+ title,
61
+ head,
62
+ head_repo : headRepo ,
63
+ base,
48
64
type : 'GH_PR_NEW_COMMENT' ,
49
65
unique_key,
50
66
}
@@ -70,8 +86,8 @@ export class GitHubPRNewCommentEnhancer implements CommentEnhancer<GitHubPRNewCo
70
86
)
71
87
}
72
88
73
- tableTitle ( _spot : GitHubPRNewCommentSpot ) : string {
74
- return 'TITLE_TODO '
89
+ tableTitle ( spot : GitHubPRNewCommentSpot ) : string {
90
+ return spot . title || 'New Pull Request '
75
91
}
76
92
77
93
buildUrl ( spot : GitHubPRNewCommentSpot ) : string {
0 commit comments