Skip to content

Commit d58300c

Browse files
committed
Update contribution steps for updating
You can now more easily run the update script to finish out an update and the documentation is updated to match.
1 parent 93ce398 commit d58300c

2 files changed

Lines changed: 82 additions & 44 deletions

File tree

ci/build/update-vscode.sh

Lines changed: 68 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@
22

33
set -Eeuo pipefail
44

5-
function remove_patches() {
5+
function quiet() {
6+
"$@" >/dev/null
7+
}
8+
9+
function indent() {
10+
local count=${1-2}
11+
local space
12+
space=$(printf "%${count}s")
13+
sed "s/^/$space| /g"
14+
}
15+
16+
function unapply_patches() {
617
local -i exit_code=0
7-
quilt pop -af || exit_code=$?
18+
quiet quilt pop -af || exit_code=$?
819
case $exit_code in
9-
# Sucessfully removed.
20+
# Sucessfully unapplied.
1021
0) ;;
11-
# No more patches to remove.
22+
# No more patches to unapply.
1223
2) ;;
1324
# Some error.
1425
*) return $exit_code ;;
@@ -17,7 +28,7 @@ function remove_patches() {
1728

1829
function update_vscode() {
1930
pushd lib/vscode
20-
if ! git checkout "$target_vscode_version" ; then
31+
if ! git checkout 2>&1 "$target_vscode_version" ; then
2132
echo "$target_vscode_version does not exist locally, fetching..."
2233
git fetch --all --prune
2334
git checkout "$target_vscode_version"
@@ -27,9 +38,8 @@ function update_vscode() {
2738

2839
function refresh_patches() {
2940
local -i exit_code=0
30-
while quilt push ; ! (( exit_code=$? )) ; do
41+
while quiet quilt push ; ! (( exit_code=$? )) ; do
3142
quilt refresh
32-
echo # Extra new line for separation.
3343
done
3444
case $exit_code in
3545
# No more patches to apply.
@@ -43,7 +53,7 @@ function update_node() {
4353
local node_version
4454
node_version=$(cat .node-version)
4555
if [[ $node_version == "$target_node_version" ]] ; then
46-
echo "$node_version already matches $target_node_version"
56+
echo "Already set to $target_node_version"
4757
else
4858
echo "Updating from $node_version to $target_node_version..."
4959
echo "$target_node_version" > .node-version
@@ -61,26 +71,42 @@ function get-webview-script-hash() {
6171
}
6272

6373
function update_csp() {
64-
local -i exit_code=0
65-
# Move back to the webview patch so it can be refreshed.
66-
quilt pop webview || exit_code=$?
67-
case $exit_code in
68-
# Successfully moved.
69-
0) ;;
70-
# Already at the patch.
71-
2) ;;
72-
# Some error.
73-
*) return $exit_code ;;
74-
esac
74+
local current=$(quilt top 2>/dev/null || echo "")
75+
local patch_action=""
76+
echo "Currently at ${current:-base}"
77+
if [[ $current != */webview.diff ]] ; then
78+
echo "Moving to patches/webview.diff..."
79+
local -i exit_code=0
80+
if quilt applied 2>/dev/null | grep --quiet webview.diff ; then
81+
quiet quilt pop webview || exit_code=$?
82+
patch_action=pop
83+
else
84+
quiet quilt push webview || exit_code=$?
85+
patch_action=push
86+
fi
87+
case $exit_code in
88+
# Successfully moved.
89+
0) ;;
90+
# Some error.
91+
*) return $exit_code ;;
92+
esac
93+
fi
94+
7595
local file=lib/vscode/src/vs/workbench/contrib/webview/browser/pre/index.html
7696
local hash
7797
hash=$(get-webview-script-hash "$file")
7898
echo "Calculated hash as $hash"
7999
# Use octothorpe as a delimiter since the hash may contain a slash.
80100
sed -i.bak "s#script-src 'sha256-[^']\+'#script-src 'sha256-$hash'#" "$file"
81101
quilt refresh
82-
# Get patched back up.
83-
quilt push -a
102+
103+
if [[ $patch_action != "" ]] ; then
104+
echo "Moving back to ${current:-base}..."
105+
case $patch_action in
106+
pop) quiet quilt push "$current" ;;
107+
push) quiet quilt pop "${current:--a}" ;;
108+
esac
109+
fi
84110
}
85111

86112
function run() {
@@ -91,8 +117,8 @@ function run() {
91117
local fn=$1 ; shift
92118
# Only run if an earlier step has not failed.
93119
if [[ $failed == 0 ]] ; then
94-
echo "[+] $name..."
95-
if $fn ; then
120+
echo "$name..."
121+
if $fn | indent ; then
96122
echo "- [X] $name" >> .cache/checklist
97123
else
98124
((failed++))
@@ -110,7 +136,7 @@ function run() {
110136

111137
function add_changelog() {
112138
local file=CHANGELOG.md
113-
if grep "Code $target_vscode_version" "$file" ; then
139+
if grep --quiet "Code $target_vscode_version" "$file" ; then
114140
echo "Changelog for $target_vscode_version already exists"
115141
else
116142
# TODO: This is not exactly robust. In particular, it needs to handle if
@@ -127,19 +153,28 @@ function main() {
127153
local target_node_version
128154
target_node_version=$(grep target lib/vscode/remote/.npmrc | awk -F= '{print $2}' | tr -d '"')
129155

130-
local target_vscode_version
131-
target_vscode_version="${VERSION#v}"
132-
133156
declare -a steps
134-
# Removing patches only needs to be done locally; in CI we start from a fresh
135-
# clone each time.
136-
if [[ ! ${CI-} ]] ; then
137-
steps+=("Remove patches" "remove_patches")
157+
158+
# If version is not set, assume we are already at the target version and the
159+
# user is just trying to resolve conflics.
160+
local target_vscode_version
161+
if [[ ${VERSION-} ]] ; then
162+
# Removing patches only needs to be done locally; in CI we start from a
163+
# fresh clone each time.
164+
if [[ ! ${CI-} ]] ; then
165+
steps+=("Unapplying patches" "unapply_patches")
166+
fi
167+
target_vscode_version="${VERSION#v}"
168+
steps+=(
169+
"Update VS Code to $target_vscode_version" "update_vscode"
170+
"Refresh VS Code patches" "refresh_patches"
171+
)
172+
else
173+
target_vscode_version="$(git -C lib/vscode describe --tags --exact-match)"
174+
echo "Detected VS Code version $target_vscode_version"
138175
fi
139176

140177
steps+=(
141-
"Update VS Code to $target_vscode_version" "update_vscode"
142-
"Refresh VS Code patches" "refresh_patches"
143178
"Set Node version to $target_node_version" "update_node"
144179
"Update CSP webview hash" "update_csp"
145180
"Add changelog note" "add_changelog"

docs/CONTRIBUTING.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,20 @@ commits first if you are doing this).
9393

9494
### Version updates to Code
9595

96-
1. Remove any patches with `quilt pop -a`.
97-
2. Update the `lib/vscode` submodule to the desired upstream version branch.
98-
1. `cd lib/vscode && git checkout release/1.66 && cd ../..`
99-
2. `git add lib && git commit -m "chore: update to Code <version>"`
100-
3. Apply the patches one at a time (`quilt push`). If the application succeeds
101-
but the lines changed, update the patch with `quilt refresh`. If there are
102-
conflicts, then force apply with `quilt push -f`, manually add back the
103-
rejected code, then run `quilt refresh`.
104-
4. From the code-server **project root**, run `npm install`.
105-
5. Check the Node.js version that's used by Electron (which is shipped with VS
106-
Code. If necessary, update our version of Node.js to match.
96+
PRs will be automatically created with updates to VS Code. If a patch cannot be
97+
automatically resolved, it will be necessary to clone the branch, resolve the
98+
conflicts manually, and finish the update. To do this:
99+
100+
1. Apply as many patches as possible `quilt push -a`.
101+
2. Once you hit a conflict, force apply with `quilt push -f`, manually add back
102+
the rejected code, then run `quilt refresh`.
103+
3. Once all patches have been resolved, run `./ci/build/update.sh` to finish the
104+
update process.
105+
4. Commit all changes, push them up to the branch, and update the checklist in
106+
the PR description.
107+
108+
Once the PR is ready, manually verify that the unreleased changelog section
109+
contains all the changes going into this version before merging.
107110

108111
### Patching Code
109112

0 commit comments

Comments
 (0)