FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TypeScript/scripts/open-user-pr.ts at arrayReduce · UmeshP53/TypeScript · GitHub
UmeshP53
/
TypeScript
Public
forked from
microsoft/TypeScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
TypeScript
/
scripts
/
open-user-pr.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
64 lines (59 loc) · 2.41 KB
Breadcrumbs
TypeScript
/
scripts
/
open-user-pr.ts
Copy path
File metadata and controls
64 lines (59 loc) · 2.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import
cp
=
require
(
"child_process"
)
;
import
Octokit
=
require
(
"@octokit/rest"
)
;
const
opts
=
{
timeout
:
100_000
,
shell
:
true
,
stdio
:
"inherit"
}
function
runSequence
(
tasks
:
[
string
,
string
[
]
]
[
]
)
{
for
(
const
task
of
tasks
)
{
console
.
log
(
`
${
task
[
0
]
}
${
task
[
1
]
.
join
(
" "
)
}
`
)
;
const
result
=
cp
.
spawnSync
(
task
[
0
]
,
task
[
1
]
,
opts
)
;
if
(
result
.
status
!==
0
)
throw
new
Error
(
`
${
task
[
0
]
}
${
task
[
1
]
.
join
(
" "
)
}
failed:
${
result
.
stderr
&&
result
.
stderr
.
toString
(
)
}
`
)
;
}
}
function
padNum
(
number
:
number
)
{
const
str
=
""
+
number
;
return
str
.
length
>=
2
?
str
:
"0"
+
str
;
}
const
userName
=
process
.
env
.
GH_USERNAME
;
const
reviewers
=
[
"weswigham"
,
"sandersn"
,
"mhegazy"
]
const
now
=
new
Date
(
)
;
const
branchName
=
`user-update-
${
now
.
getFullYear
(
)
}
${
padNum
(
now
.
getMonth
(
)
)
}
${
padNum
(
now
.
getDay
(
)
)
}
`
;
const
remoteUrl
=
`https://
${
process
.
argv
[
2
]
}
@github.com/
${
userName
}
/TypeScript.git`
;
runSequence
(
[
[
"git"
,
[
"checkout"
,
"."
]
]
,
// reset any changes
[
"node"
,
[
"./node_modules/jake/bin/cli.js"
,
"baseline-accept"
]
]
,
// accept baselines
[
"git"
,
[
"checkout"
,
"-b"
,
branchName
]
]
,
// create a branch
[
"git"
,
[
"add"
,
"."
]
]
,
// Add all changes
[
"git"
,
[
"commit"
,
"-m"
,
`"Update user baselines"`
]
]
,
// Commit all changes
[
"git"
,
[
"remote"
,
"add"
,
"fork"
,
remoteUrl
]
]
,
// Add the remote fork
[
"git"
,
[
"push"
,
"--set-upstream"
,
"fork"
,
branchName
,
"-f"
]
]
// push the branch
]
)
;
const
gh
=
new
Octokit
(
)
;
gh
.
authenticate
(
{
type
:
"token"
,
token
:
process
.
argv
[
2
]
}
)
;
gh
.
pullRequests
.
create
(
{
owner
:
process
.
env
.
TARGET_FORK
,
repo
:
"TypeScript"
,
maintainer_can_modify
:
true
,
title
:
`🤖 User test baselines have changed`
,
head
:
`
${
userName
}
:
${
branchName
}
`
,
base
:
"master"
,
body
:
`Please review the diff and merge if no changes are unexpected.
You can view the build log [here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=
${
process
.
env
.
BUILD_BUILDID
}
&_a=summary).
cc
${
reviewers
.
map
(
r
=>
"@"
+
r
)
.
join
(
" "
)
}
`
,
}
)
.
then
(
r
=>
{
const
num
=
r
.
data
.
number
;
console
.
log
(
`Pull request
${
num
}
created.`
)
;
return
gh
.
pullRequests
.
createReviewRequest
(
{
owner
:
process
.
env
.
TARGET_FORK
,
repo
:
"TypeScript"
,
number
:
num
,
reviewers
,
}
)
;
}
)
.
then
(
(
)
=>
{
console
.
log
(
`Reviewers requested, done.`
)
;
}
)
.
catch
(
e
=>
{
console
.
error
(
e
)
;
process
.
exit
(
1
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL