Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
d57593c1
Commit
d57593c1
authored
Jan 24, 2022
by
Francisco Giordano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lint
parent
7c47ac71
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
update-docs-branch.js
scripts/update-docs-branch.js
+11
-11
No files found.
scripts/update-docs-branch.js
View file @
d57593c1
...
@@ -5,16 +5,16 @@ const tryRead = cmd => { try { return read(cmd); } catch (e) { return undefined;
...
@@ -5,16 +5,16 @@ const tryRead = cmd => { try { return read(cmd); } catch (e) { return undefined;
const
releaseBranchRegex
=
/^release-v
(?<
version>
(?<
major>
\d
+
)\.(?<
minor>
\d
+
)(?:\.(?<
patch>
\d
+
))?)
$/
;
const
releaseBranchRegex
=
/^release-v
(?<
version>
(?<
major>
\d
+
)\.(?<
minor>
\d
+
)(?:\.(?<
patch>
\d
+
))?)
$/
;
const
currentBranch
=
read
(
`git rev-parse --abbrev-ref HEAD`
);
const
currentBranch
=
read
(
'git rev-parse --abbrev-ref HEAD'
);
const
match
=
currentBranch
.
match
(
releaseBranchRegex
);
const
match
=
currentBranch
.
match
(
releaseBranchRegex
);
if
(
!
match
)
{
if
(
!
match
)
{
console
.
error
(
`Not currently on a release branch`
);
console
.
error
(
'Not currently on a release branch'
);
process
.
exit
(
1
);
process
.
exit
(
1
);
}
}
if
(
/-.*$/
.
test
(
require
(
'../package.json'
).
version
))
{
if
(
/-.*$/
.
test
(
require
(
'../package.json'
).
version
))
{
console
.
error
(
`Refusing to update docs: prerelease detected`
);
console
.
error
(
'Refusing to update docs: prerelease detected'
);
process
.
exit
(
0
);
process
.
exit
(
0
);
}
}
...
@@ -22,7 +22,7 @@ const current = match.groups;
...
@@ -22,7 +22,7 @@ const current = match.groups;
const
docsBranch
=
`docs-v
${
current
.
major
}
.x`
;
const
docsBranch
=
`docs-v
${
current
.
major
}
.x`
;
// Fetch remotes and find the docs branch if it exists
// Fetch remotes and find the docs branch if it exists
run
(
`git fetch --all --no-tags`
);
run
(
'git fetch --all --no-tags'
);
const
matchingDocsBranches
=
tryRead
(
`git rev-parse --glob='*/
${
docsBranch
}
'`
);
const
matchingDocsBranches
=
tryRead
(
`git rev-parse --glob='*/
${
docsBranch
}
'`
);
if
(
!
matchingDocsBranches
)
{
if
(
!
matchingDocsBranches
)
{
...
@@ -32,24 +32,24 @@ if (!matchingDocsBranches) {
...
@@ -32,24 +32,24 @@ if (!matchingDocsBranches) {
const
[
publishedRef
,
...
others
]
=
new
Set
(
matchingDocsBranches
.
split
(
'
\
n'
));
const
[
publishedRef
,
...
others
]
=
new
Set
(
matchingDocsBranches
.
split
(
'
\
n'
));
if
(
others
.
length
>
0
)
{
if
(
others
.
length
>
0
)
{
console
.
error
(
console
.
error
(
`Found conflicting
${
docsBranch
}
branches.\n`
`Found conflicting
${
docsBranch
}
branches.\n`
+
+
`Either local branch is outdated or there are multiple matching remote branches.`
'Either local branch is outdated or there are multiple matching remote branches.'
,
);
);
process
.
exit
(
1
);
process
.
exit
(
1
);
}
}
const
publishedVersion
=
JSON
.
parse
(
read
(
`git show
${
publishedRef
}
:package.json`
)).
version
;
const
publishedVersion
=
JSON
.
parse
(
read
(
`git show
${
publishedRef
}
:package.json`
)).
version
;
const
publishedMinor
=
publishedVersion
.
match
(
/
\d
+
\.(?<
minor>
\d
+
)\.\d
+/
).
groups
.
minor
;
const
publishedMinor
=
publishedVersion
.
match
(
/
\d
+
\.(?<
minor>
\d
+
)\.\d
+/
).
groups
.
minor
;
if
(
current
.
minor
<
publishedMinor
)
{
if
(
current
.
minor
<
publishedMinor
)
{
console
.
error
(
`Refusing to update docs: newer version is published`
);
console
.
error
(
'Refusing to update docs: newer version is published'
);
process
.
exit
(
0
);
process
.
exit
(
0
);
}
}
run
(
`git checkout --quiet --detach`
);
run
(
'git checkout --quiet --detach'
);
run
(
`git reset --soft
${
publishedRef
}
`
);
run
(
`git reset --soft
${
publishedRef
}
`
);
run
(
`git checkout
${
docsBranch
}
`
);
run
(
`git checkout
${
docsBranch
}
`
);
}
}
run
(
`npm run prepare-docs`
);
run
(
'npm run prepare-docs'
);
run
(
`git add -f docs`
);
// --force needed because generated docs files are gitignored
run
(
'git add -f docs'
);
// --force needed because generated docs files are gitignored
run
(
`git commit -m "Update docs"`
);
run
(
'git commit -m "Update docs"'
);
run
(
`git checkout
${
currentBranch
}
`
);
run
(
`git checkout
${
currentBranch
}
`
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment