@@ -239,7 +239,7 @@ export async function checkSvnInstalled(): Promise<boolean> {
239239 * @param cwd The working directory
240240 * @returns Array of matching SVN commits
241241 */
242- export async function searchSvnCommits ( query : string , cwd : string , p0 : number ) : Promise < SvnCommit [ ] > {
242+ export async function searchSvnCommits ( query : string , cwd : string ) : Promise < SvnCommit [ ] > {
243243 SvnLogger . debug ( "searchSvnCommits called" , { query, cwd } )
244244
245245 try {
@@ -499,3 +499,108 @@ export async function getSvnWorkingState(cwd: string): Promise<{
499499 return { status : "" , diff : "" }
500500 }
501501}
502+
503+ /**
504+ * Gets formatted SVN commit information for mentions
505+ * @param revision The revision number (can be with or without 'r' prefix)
506+ * @param cwd The working directory
507+ * @returns Formatted commit information string
508+ */
509+ export async function getSvnCommitInfoForMentions ( revision : string , cwd : string ) : Promise < string > {
510+ try {
511+ console . log ( "[DEBUG] getSvnCommitInfoForMentions called with revision:" , revision , "cwd:" , cwd )
512+
513+ if ( ! ( await checkSvnInstalled ( ) ) || ! ( await checkSvnRepo ( cwd ) ) ) {
514+ console . log ( "[DEBUG] SVN not installed or not a repository" )
515+ return "Error: SVN not available or not an SVN repository"
516+ }
517+
518+ // Clean revision number (remove 'r' prefix if present)
519+ const cleanRevision = revision . replace ( / ^ r / i, "" )
520+ console . log ( "[DEBUG] Clean revision:" , cleanRevision )
521+
522+ // Get commit info
523+ const { stdout : logOutput } = await execAsync ( `svn log -r ${ cleanRevision } -v` , { cwd } )
524+ console . log ( "[DEBUG] SVN log output:" , logOutput )
525+
526+ // Parse the log output
527+ const lines = logOutput . split ( "\n" )
528+ let commitInfo = ""
529+ let author = ""
530+ let date = ""
531+ let message = ""
532+ let changedPaths = ""
533+
534+ // Find the revision line
535+ const revisionLineIndex = lines . findIndex ( ( line ) => line . includes ( `r${ cleanRevision } ` ) )
536+ if ( revisionLineIndex >= 0 ) {
537+ const revisionLine = lines [ revisionLineIndex ]
538+ const match = revisionLine . match ( / r ( \d + ) \s + \| \s + ( [ ^ | ] + ) \s + \| \s + ( [ ^ | ] + ) \s + \| / )
539+ if ( match ) {
540+ author = match [ 2 ] . trim ( )
541+ date = match [ 3 ] . trim ( )
542+ }
543+ }
544+
545+ // Find changed paths
546+ const changedPathsStart = lines . findIndex ( ( line ) => line . includes ( "Changed paths:" ) )
547+ if ( changedPathsStart >= 0 ) {
548+ let i = changedPathsStart + 1
549+ const pathLines = [ ]
550+ while ( i < lines . length && lines [ i ] . trim ( ) && ! lines [ i ] . startsWith ( "-" ) ) {
551+ if ( lines [ i ] . trim ( ) ) {
552+ pathLines . push ( lines [ i ] . trim ( ) )
553+ }
554+ i ++
555+ }
556+ changedPaths = pathLines . join ( "\n" )
557+ }
558+
559+ // Find message
560+ const messageStart = lines . findIndex (
561+ ( line , index ) =>
562+ index > revisionLineIndex && line . trim ( ) && ! line . startsWith ( "-" ) && ! line . includes ( "Changed paths:" ) ,
563+ )
564+ if ( messageStart >= 0 ) {
565+ let i = messageStart
566+ const messageLines = [ ]
567+ while ( i < lines . length && ! lines [ i ] . startsWith ( "-" ) ) {
568+ if ( lines [ i ] . trim ( ) ) {
569+ messageLines . push ( lines [ i ] . trim ( ) )
570+ }
571+ i ++
572+ }
573+ message = messageLines . join ( "\n" )
574+ }
575+
576+ // Get diff
577+ let diff = ""
578+ try {
579+ const { stdout : diffOutput } = await execAsync ( `svn diff -c ${ cleanRevision } ` , { cwd } )
580+ diff = truncateOutput ( diffOutput , SVN_OUTPUT_LINE_LIMIT )
581+ } catch ( error ) {
582+ console . log ( "[DEBUG] SVN diff command failed:" , error )
583+ diff = "Diff not available"
584+ }
585+
586+ // Format the output
587+ commitInfo = `Revision: r${ cleanRevision } \n`
588+ commitInfo += `Author: ${ author } \n`
589+ commitInfo += `Date: ${ date } \n\n`
590+ commitInfo += `Message: ${ message } \n\n`
591+
592+ if ( changedPaths ) {
593+ commitInfo += `Changed Paths:\n${ changedPaths } \n\n`
594+ }
595+
596+ if ( diff && diff . trim ( ) ) {
597+ commitInfo += `Full Changes:\n\n${ diff } `
598+ }
599+
600+ console . log ( "[DEBUG] Formatted commit info:" , commitInfo )
601+ return commitInfo
602+ } catch ( error ) {
603+ console . error ( "[DEBUG] Error getting SVN commit info for mentions:" , error )
604+ return `Error fetching SVN commit r${ revision } : ${ error . message } `
605+ }
606+ }
0 commit comments