@@ -78,14 +78,14 @@ function clearEmptyHashValueLine(filePath) {
78
78
* @param {string } description pull reqest description
79
79
* @param {string[] } targetsToCommit files to add in pull request
80
80
*/
81
- async function openPR ( repo , project , sourceBranch , targetBranch , commitMessage , title , description , targetsToCommit ) {
81
+ async function openPR ( repo , project , sourceBranch , targetBranch , commitMessage , title , description , targetsToCommit , dryrun = false ) {
82
82
console . log ( `Creating PR from "${ sourceBranch } " into "${ targetBranch } " in the "${ project } /${ repo } " repo` ) ;
83
83
84
84
const repoPath = path . join ( INTEGRATION_DIR , repo ) ;
85
85
86
86
if ( ! fs . existsSync ( repoPath ) ) {
87
87
const gitUrl = `https://${ process . env . PAT } @${ orgUrl } /${ project } /_git/${ repo } ` ;
88
- util . execInForeground ( `${ GIT } clone --depth 1 ${ gitUrl } ${ repoPath } ` , null , opt . options . dryrun ) ;
88
+ util . execInForeground ( `${ GIT } clone --depth 1 ${ gitUrl } ${ repoPath } ` , null , dryrun ) ;
89
89
}
90
90
91
91
for ( const targetToCommit of targetsToCommit ) {
@@ -95,7 +95,7 @@ async function openPR(repo, project, sourceBranch, targetBranch, commitMessage,
95
95
const sourceFile = path . join ( INTEGRATION_DIR , fileName ) ;
96
96
const targetFile = path . join ( fullPath , fileName ) ;
97
97
98
- if ( opt . options . dryrun ) {
98
+ if ( dryrun ) {
99
99
console . log ( `Fake copy file from ${ sourceFile } to ${ targetFile } ` ) ;
100
100
} else {
101
101
console . log ( `Copy file from ${ sourceFile } to ${ targetFile } ` ) ;
@@ -105,12 +105,12 @@ async function openPR(repo, project, sourceBranch, targetBranch, commitMessage,
105
105
}
106
106
107
107
for ( const targetToCommit of targetsToCommit ) {
108
- util . execInForeground ( `${ GIT } add ${ targetToCommit } ` , repoPath , opt . options . dryrun ) ;
108
+ util . execInForeground ( `${ GIT } add ${ targetToCommit } ` , repoPath , dryrun ) ;
109
109
}
110
110
111
- util . execInForeground ( `${ GIT } checkout -b ${ sourceBranch } ` , repoPath , opt . options . dryrun ) ;
112
- util . execInForeground ( `${ GIT } commit -m "${ commitMessage } "` , repoPath , opt . options . dryrun ) ;
113
- util . execInForeground ( `${ GIT } push --force origin ${ sourceBranch } ` , repoPath , opt . options . dryrun ) ;
111
+ util . execInForeground ( `${ GIT } checkout -b ${ sourceBranch } ` , repoPath , dryrun ) ;
112
+ util . execInForeground ( `${ GIT } commit -m "${ commitMessage } "` , repoPath , dryrun ) ;
113
+ util . execInForeground ( `${ GIT } push --force origin ${ sourceBranch } ` , repoPath , dryrun ) ;
114
114
115
115
const prefix = 'refs/heads/' ;
116
116
@@ -129,7 +129,7 @@ async function openPR(repo, project, sourceBranch, targetBranch, commitMessage,
129
129
130
130
if ( PR ) {
131
131
console . log ( 'PR already exists' ) ;
132
- } else if ( opt . options . dryrun ) {
132
+ } else if ( dryrun ) {
133
133
return [ - 1 , 'test' ] ; // return without creating PR for test runs
134
134
} else {
135
135
console . log ( 'PR does not exist; creating PR' ) ;
@@ -169,8 +169,13 @@ async function main() {
169
169
util . verifyMinimumNodeVersion ( ) ;
170
170
util . verifyMinimumGitVersion ( ) ;
171
171
createIntegrationFiles ( agentVersion ) ;
172
- util . execInForeground ( `${ GIT } config --global user.email "${ process . env . USEREMAIL } "` , null , opt . options . dryrun ) ;
173
- util . execInForeground ( `${ GIT } config --global user.name "${ process . env . USERNAME } "` , null , opt . options . dryrun ) ;
172
+
173
+ const dryrun = ( opt . options . dryrun . toString ( ) . toLowerCase ( ) === "true" ) ;
174
+
175
+ console . log ( `Dry run: ${ dryrun } ` ) ;
176
+
177
+ util . execInForeground ( `${ GIT } config --global user.email "${ process . env . USEREMAIL } "` , null , dryrun ) ;
178
+ util . execInForeground ( `${ GIT } config --global user.name "${ process . env . USERNAME } "` , null , dryrun ) ;
174
179
175
180
const sprint = await getCurrentSprint ( ) ;
176
181
@@ -191,7 +196,8 @@ async function main() {
191
196
path . join (
192
197
'DistributedTask' , 'Service' , 'Servicing' , 'Host' , 'Deployment' , 'Groups' , 'UpdateAgentPackage.xml'
193
198
) ,
194
- ]
199
+ ] ,
200
+ dryrun
195
201
) ;
196
202
197
203
const [ ccPrId , ccPrLink ] = await openPR (
@@ -202,7 +208,8 @@ async function main() {
202
208
path . join (
203
209
'tfs' , `m${ sprint } ` , 'PipelinesAgentRelease' , agentVersion , 'Publish.ps1'
204
210
)
205
- ]
211
+ ] ,
212
+ dryrun
206
213
) ;
207
214
208
215
console . log ( `##vso[task.setvariable variable=AdoPrId;isOutput=true]${ adoPrId } ` ) ;
0 commit comments