Skip to content

Commit 1605d68

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 1605d68

2 files changed

Lines changed: 83 additions & 44 deletions

File tree

ci/build/update-vscode.sh

Lines changed: 69 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=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,43 @@ 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
75+
current=$(quilt top 2>/dev/null || echo "")
76+
local patch_action=""
77+
echo "Currently at ${current:-base}"
78+
if [[ $current != */webview.diff ]] ; then
79+
echo "Moving to patches/webview.diff..."
80+
local -i exit_code=0
81+
if quilt applied 2>/dev/null | grep --quiet webview.diff ; then
82+
quiet quilt pop webview || exit_code=$?
83+
patch_action=pop
84+
else
85+
quiet quilt push webview || exit_code=$?
86+
patch_action=push
87+
fi
88+
case $exit_code in
89+
# Successfully moved.
90+
0) ;;
91+
# Some error.
92+
*) return $exit_code ;;
93+
esac
94+
fi
95+
7596
local file=lib/vscode/src/vs/workbench/contrib/webview/browser/pre/index.html
7697
local hash
7798
hash=$(get-webview-script-hash "$file")
7899
echo "Calculated hash as $hash"
79100
# Use octothorpe as a delimiter since the hash may contain a slash.
80101
sed -i.bak "s#script-src 'sha256-[^']\+'#script-src 'sha256-$hash'#" "$file"
81102
quilt refresh
82-
# Get patched back up.
83-
quilt push -a
103+
104+
if [[ $patch_action != "" ]] ; then
105+
echo "Moving back to ${current:-base}..."
106+
case $patch_action in
107+
pop) quiet quilt push "$current" ;;
108+
push) quiet quilt pop "${current:--a}" ;;
109+
esac
110+
fi
84111
}
85112

86113
function run() {
@@ -91,8 +118,8 @@ function run() {
91118
local fn=$1 ; shift
92119
# Only run if an earlier step has not failed.
93120
if [[ $failed == 0 ]] ; then
94-
echo "[+] $name..."
95-
if $fn ; then
121+
echo "$name..."
122+
if $fn | indent ; then
96123
echo "- [X] $name" >> .cache/checklist
97124
else
98125
((failed++))
@@ -110,7 +137,7 @@ function run() {
110137

111138
function add_changelog() {
112139
local file=CHANGELOG.md
113-
if grep "Code $target_vscode_version" "$file" ; then
140+
if grep --quiet "Code $target_vscode_version" "$file" ; then
114141
echo "Changelog for $target_vscode_version already exists"
115142
else
116143
# TODO: This is not exactly robust. In particular, it needs to handle if
@@ -127,19 +154,28 @@ function main() {
127154
local target_node_version
128155
target_node_version=$(grep target lib/vscode/remote/.npmrc | awk -F= '{print $2}' | tr -d '"')
129156

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

140178
steps+=(
141-
"Update VS Code to $target_vscode_version" "update_vscode"
142-
"Refresh VS Code patches" "refresh_patches"
143179
"Set Node version to $target_node_version" "update_node"
144180
"Update CSP webview hash" "update_csp"
145181
"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)