@@ -98,17 +98,27 @@ async function getMetadataFromEnvironment() {
9898// @param {string } metadata.headRef - the head reference of git
9999// It's the name of the current branch
100100function writeToFile ( antoraPlaybookFile , metadata ) {
101- fs . readFile ( antoraPlaybookFile , "utf8" , function ( err , data ) {
101+ fs . readFile ( antoraPlaybookFile , "utf8" , function ( err , data ) {
102102 if ( err ) {
103- return console . err ( err ) ;
103+ return console . error ( err ) ;
104104 }
105105
106- let result = data . replace ( metadata . baseRef , metadata . headRef ) ;
106+ let result = data ;
107107
108108 const isDevelopment = metadata . headRef === "HEAD" ;
109+
110+ // Only modify inside documentation sources
111+ result = result . replace (
112+ / ( - u r l : & d o c u m e n t a t i o n [ ^ \n ] * \n (?: \s + .* \n ) * ?\s + b r a n c h e s : \s * \[ [ ^ \] ] * ?) , \s * d e v e l o p ( \s * \] ) / gm,
113+ `$1, ${ metadata . headRef } $2`
114+ ) ;
115+
109116 if ( isDevelopment ) {
110- const antoraDocumentationUrl = "https://github.com/decidim/documentation" ;
111- result = result . replace ( antoraDocumentationUrl , "." ) ;
117+ // Replace only the documentation URLs, not the decidim/decidim one
118+ result = result . replace (
119+ / ^ ( \s * - \s * u r l : \s * & d o c u m e n t a t i o n \s * ) h t t p s : \/ \/ g i t h u b \. c o m \/ d e c i d i m \/ d o c u m e n t a t i o n / mg,
120+ "$1."
121+ ) ;
112122 }
113123
114124 console . log ( "********************************" )
@@ -118,7 +128,7 @@ function writeToFile(antoraPlaybookFile, metadata) {
118128
119129 fs . writeFile ( antoraPlaybookFile , result , "utf8" , function ( err ) {
120130 if ( err ) {
121- return console . err ( err ) ;
131+ return console . error ( err ) ;
122132 }
123133 } ) ;
124134 } ) ;
0 commit comments