11import { GitHubPrMonitor } from './githubPrMonitor' ;
22import { DEFAULT_HEADERS } from './headers' ;
33import { ghResponseToInstance , parseGitHubDetailedPullRequest } from './types' ;
4- import { showError } from '$lib/notifications/toasts' ;
4+ import { showToast } from '$lib/notifications/toasts' ;
55import { sleep } from '$lib/utils/sleep' ;
66import posthog from 'posthog-js' ;
77import { get , writable } from 'svelte/store' ;
@@ -21,7 +21,8 @@ export class GitHubPrService implements GitHostPrService {
2121 private repo : RepoInfo ,
2222 private baseBranch : string ,
2323 private upstreamName : string ,
24- private usePullRequestTemplate ?: Persisted < boolean >
24+ private usePullRequestTemplate ?: Persisted < boolean > ,
25+ private pullRequestTemplatePath ?: Persisted < string >
2526 ) { }
2627
2728 async createPr ( title : string , body : string , draft : boolean ) : Promise < PullRequest > {
@@ -67,19 +68,28 @@ export class GitHubPrService implements GitHostPrService {
6768 }
6869
6970 async fetchPrTemplate ( ) {
71+ const path = this . pullRequestTemplatePath
72+ ? get ( this . pullRequestTemplatePath )
73+ : DEFAULT_PULL_REQUEST_TEMPLATE_PATH ;
74+
7075 try {
7176 const response = await this . octokit . rest . repos . getContent ( {
7277 owner : this . repo . owner ,
7378 repo : this . repo . name ,
74- path : DEFAULT_PULL_REQUEST_TEMPLATE_PATH
79+ path
7580 } ) ;
7681 const b64Content = ( response . data as any ) ?. content ;
7782 if ( b64Content ) {
7883 return decodeURIComponent ( escape ( atob ( b64Content ) ) ) ;
7984 }
8085 } catch ( err ) {
81- console . error ( 'Error fetching pull request template: ' , err ) ;
82- showError ( 'Failed to fetch pull request template' , err ) ;
86+ console . error ( `Error fetching pull request template at path: ${ path } ` , err ) ;
87+
88+ showToast ( {
89+ title : 'Failed to fetch pull request template' ,
90+ message : `Template not found at path: <code>${ path } </code>.` ,
91+ style : 'neutral'
92+ } ) ;
8393 }
8494 }
8595
0 commit comments