@@ -12,28 +12,35 @@ function padNum(num: number) {
1212const userName = process . env . GH_USERNAME ;
1313const reviewers = process . env . REQUESTING_USER ? [ process . env . REQUESTING_USER ] : [ "weswigham" , "sandersn" , "RyanCavanaugh" ] ;
1414const now = new Date ( ) ;
15- const branchName = `user-update-${ process . env . TARGET_FORK } -${ now . getFullYear ( ) } ${ padNum ( now . getMonth ( ) + 1 ) } ${ padNum ( now . getDate ( ) ) } ${ process . env . TARGET_BRANCH ? "-" + process . env . TARGET_BRANCH : "" } ` ;
15+ const masterBranchname = `user-baseline-updates` ;
16+ const branchName = process . env . TARGET_FORK . toLowerCase ( ) === "microsoft" && ( process . env . TARGET_BRANCH || "master" ) === "master"
17+ ? masterBranchname
18+ : `user-update-${ process . env . TARGET_FORK } -${ now . getFullYear ( ) } ${ padNum ( now . getMonth ( ) + 1 ) } ${ padNum ( now . getDate ( ) ) } ${ process . env . TARGET_BRANCH ? "-" + process . env . TARGET_BRANCH : "" } ` ;
1619const remoteUrl = `https://${ process . argv [ 2 ] } @github.com/${ userName } /TypeScript.git` ;
20+ const baseRef = branchName === masterBranchname ? "master" : masterBranchname ;
1721runSequence ( [
22+ [ "git" , [ "remote" , "add" , "fork" , remoteUrl ] ] , // Add the remote fork
1823 [ "git" , [ "checkout" , "." ] ] , // reset any changes
24+ [ "git" , [ "fetch" , baseRef === "master" ? "origin" : "fork" , baseRef ] ] , // fetch target ref in case it's not present locally
25+ [ "git" , [ "checkout" , baseRef ] ] , // move head to target
1926 [ "node" , [ "./node_modules/gulp/bin/gulp.js" , "baseline-accept" ] ] , // accept baselines
2027 [ "git" , [ "checkout" , "-b" , branchName ] ] , // create a branch
2128 [ "git" , [ "add" , "." ] ] , // Add all changes
2229 [ "git" , [ "commit" , "-m" , `"Update user baselines"` ] ] , // Commit all changes
23- [ "git" , [ "remote" , "add" , "fork" , remoteUrl ] ] , // Add the remote fork
2430 [ "git" , [ "push" , "--set-upstream" , "fork" , branchName , "-f" ] ] // push the branch
2531] ) ;
2632
2733const gh = new Octokit ( {
2834 auth : process . argv [ 2 ]
2935} ) ;
36+ const prOwner = branchName === masterBranchname ? "microsoft" : userName ;
3037gh . pulls . create ( {
31- owner : process . env . TARGET_FORK ! ,
38+ owner : prOwner ,
3239 repo : "TypeScript" ,
3340 maintainer_can_modify : true ,
3441 title : `🤖 User test baselines have changed` + ( process . env . TARGET_BRANCH ? ` for ${ process . env . TARGET_BRANCH } ` : "" ) ,
3542 head : `${ userName } :${ branchName } ` ,
36- base : process . env . TARGET_BRANCH || "master" ,
43+ base : branchName === masterBranchname ? "master" : masterBranchname ,
3744 body :
3845`${ process . env . SOURCE_ISSUE ? `This test run was triggerd by a request on https://github.com/Microsoft/TypeScript/pull/${ process . env . SOURCE_ISSUE } ` + "\n" : "" } Please review the diff and merge if no changes are unexpected.
3946You can view the build log [here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=${ process . env . BUILD_BUILDID } &_a=summary).
@@ -44,7 +51,7 @@ cc ${reviewers.map(r => "@" + r).join(" ")}`,
4451 console . log ( `Pull request ${ num } created.` ) ;
4552 if ( ! process . env . SOURCE_ISSUE ) {
4653 await gh . pulls . createReviewRequest ( {
47- owner : process . env . TARGET_FORK ! ,
54+ owner : prOwner ,
4855 repo : "TypeScript" ,
4956 pull_number : num ,
5057 reviewers,
@@ -53,7 +60,7 @@ cc ${reviewers.map(r => "@" + r).join(" ")}`,
5360 else {
5461 await gh . issues . createComment ( {
5562 issue_number : + process . env . SOURCE_ISSUE ,
56- owner : "Microsoft " ,
63+ owner : "microsoft " ,
5764 repo : "TypeScript" ,
5865 body : `The user suite test run you requested has finished and _failed_. I've opened a [PR with the baseline diff from master](${ r . data . html_url } ).`
5966 } ) ;
0 commit comments