@@ -122,15 +122,20 @@ module.exports = {
122122 const title = context . payload . pull_request . title ;
123123 if ( title . startsWith ( "MINOR: " ) ) {
124124 console . log ( "PR is a minor PR" ) ;
125- return { "issue" : null } ;
125+ return { "issue" : null , "type" : "minor" } ;
126126 }
127127
128- const match = title . match ( / ^ G H - ( [ 0 - 9 ] + ) : .* $ / ) ;
128+ const match = title . match ( / ^ ( G H | D X ) - ( [ 0 - 9 ] + ) : .* $ / ) ;
129129 if ( match === null ) {
130- core . setFailed ( "Invalid PR title format. Must either be MINOR: or GH -NNN:" ) ;
131- return { "issue" : null } ;
130+ core . setFailed ( "Invalid PR title format. Must either be MINOR:, GH-NNN:, or DX -NNN:" ) ;
131+ return { "issue" : null , "type" : null } ;
132132 }
133- return { "issue" : parseInt ( match [ 1 ] , 10 ) } ;
133+
134+ const issueType = match [ 1 ] ; // "GH" or "DX"
135+ const issueNumber = parseInt ( match [ 2 ] , 10 ) ;
136+
137+ console . log ( `PR references ${ issueType } -${ issueNumber } ` ) ;
138+ return { "issue" : issueNumber , "type" : issueType } ;
134139 } ,
135140
136141 apply_labels : async function ( { core, github, context} ) {
@@ -203,9 +208,28 @@ See [CONTRIBUTING.md](https://github.com/apache/arrow-java/blob/main/CONTRIBUTIN
203208 console . log ( "This is a MINOR PR" ) ;
204209 return ;
205210 }
206- const expected = `https://github.com/apache/arrow-java/issues/${ issue . issue } ` ;
207211
208- const query = `
212+ // Handle Jira tickets (DX-NNN)
213+ if ( issue . type === "DX" ) {
214+ const jiraUrl = `https://dremio.atlassian.net/browse/DX-${ issue . issue } ` ;
215+ console . log ( `This PR references Jira ticket: ${ jiraUrl } ` ) ;
216+
217+ // Add a comment with the Jira link
218+ const comment_tag = "jira_link_comment" ;
219+ const maybe_comment_id = await have_comment ( github , context , context . payload . pull_request . number , comment_tag ) ;
220+ const body_text = `<!-- ${ comment_tag } -->
221+ **Related Jira Ticket:** [DX-${ issue . issue } ](${ jiraUrl } )` ;
222+
223+ await upsert_comment ( github , maybe_comment_id , body_text , true ) ;
224+ console . log ( "Added/updated Jira link comment" ) ;
225+ return ;
226+ }
227+
228+ // Handle GitHub issues (GH-NNN)
229+ if ( issue . type === "GH" ) {
230+ const expected = `https://github.com/apache/arrow-java/issues/${ issue . issue } ` ;
231+
232+ const query = `
209233query($owner: String!, $name: String!, $number: Int!) {
210234 repository(owner: $owner, name: $name) {
211235 pullRequest(number: $number) {
@@ -220,22 +244,23 @@ query($owner: String!, $name: String!, $number: Int!) {
220244 }
221245}` ;
222246
223- const result = await github . graphql ( query , {
224- owner : context . repo . owner ,
225- name : context . repo . repo ,
226- number : context . payload . pull_request . number ,
227- } ) ;
228- const issues = result . repository . pullRequest . closingIssuesReferences . edges ;
229- console . log ( issues ) ;
230-
231- for ( const link of issues ) {
232- console . log ( `PR is linked to ${ link . node . number } ` ) ;
233- if ( link . node . number === issue . issue ) {
234- console . log ( `Found link to ${ expected } ` ) ;
235- return ;
247+ const result = await github . graphql ( query , {
248+ owner : context . repo . owner ,
249+ name : context . repo . repo ,
250+ number : context . payload . pull_request . number ,
251+ } ) ;
252+ const issues = result . repository . pullRequest . closingIssuesReferences . edges ;
253+ console . log ( issues ) ;
254+
255+ for ( const link of issues ) {
256+ console . log ( `PR is linked to ${ link . node . number } ` ) ;
257+ if ( link . node . number === issue . issue ) {
258+ console . log ( `Found link to ${ expected } ` ) ;
259+ return ;
260+ }
236261 }
262+ console . log ( `Did not find link to ${ expected } ` ) ;
263+ core . setFailed ( "Missing link to issue in title" ) ;
237264 }
238- console . log ( `Did not find link to ${ expected } ` ) ;
239- core . setFailed ( "Missing link to issue in title" ) ;
240265 } ,
241266} ;
0 commit comments