Skip to content

Commit a35591a

Browse files
committed
Move to patches
- Switch submodule to track upstream - Add quilt to the process - Add patches The node-* ignore was ignoring one of the diffs so I removed it. This was added when we were curling Node as node-v{version}-darwin-x64 for the macOS build but this no longer happens (we use the Node action to install a specific version now so we just use the system-wide Node).
1 parent cbe2618 commit a35591a

26 files changed

+1896
-100
lines changed

.github/workflows/ci.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ jobs:
138138
id: vscode-rev
139139
run: echo "::set-output name=rev::$(git rev-parse HEAD:./lib/vscode)"
140140

141+
- name: Install quilt
142+
run: sudo apt update && sudo apt install quilt
143+
144+
- name: Patch Code
145+
run: quilt push -a
146+
141147
- name: Fetch Code build from cache
142148
id: cache-vscode-2
143149
uses: actions/cache@v2

.gitignore

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ release-packages/
88
release-gcp/
99
release-images/
1010
node_modules
11-
vendor/modules
12-
node-*
1311
/plugins
1412
/lib/coder-cloud-agent
1513
.home
1614
coverage
1715
**/.DS_Store
16+
17+
# Code packages itself here.
18+
/lib/vscode-reh-web-linux-x64/
19+
1820
# Failed e2e test videos are saved here
1921
test/test-results
22+
23+
# Quilt's internal data.
24+
/.pc

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "lib/vscode"]
22
path = lib/vscode
3-
url = https://github.com/coder/vscode
3+
url = https://github.com/microsoft/vscode

docs/CONTRIBUTING.md

+66-96
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
- [Creating pull requests](#creating-pull-requests)
88
- [Commits and commit history](#commits-and-commit-history)
99
- [Development workflow](#development-workflow)
10-
- [Updates to VS Code](#updates-to-vs-code)
10+
- [Version updates to Code](#version-updates-to-code)
11+
- [Patching Code](#patching-code)
1112
- [Build](#build)
1213
- [Help](#help)
1314
- [Test](#test)
@@ -16,7 +17,7 @@
1617
- [Integration tests](#integration-tests)
1718
- [End-to-end tests](#end-to-end-tests)
1819
- [Structure](#structure)
19-
- [Modifications to VS Code](#modifications-to-vs-code)
20+
- [Modifications to Code](#modifications-to-code)
2021
- [Currently Known Issues](#currently-known-issues)
2122

2223
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -44,6 +45,8 @@ Here is what is needed:
4445
signature
4546
verification](https://docs.github.com/en/github/authenticating-to-github/managing-commit-signature-verification)
4647
or follow [this tutorial](https://joeprevite.com/verify-commits-on-github)
48+
- `quilt`
49+
- Used to manage patches to Code
4750
- `rsync` and `unzip`
4851
- Used for code-server releases
4952
- `bats`
@@ -57,7 +60,7 @@ If you're developing code-server on Linux, make sure you have installed or insta
5760
sudo apt-get install build-essential g++ libx11-dev libxkbfile-dev libsecret-1-dev python-is-python3
5861
```
5962

60-
These are required by VS Code. See [their Wiki](https://github.com/microsoft/vscode/wiki/How-to-Contribute#prerequisites) for more information.
63+
These are required by Code. See [their Wiki](https://github.com/microsoft/vscode/wiki/How-to-Contribute#prerequisites) for more information.
6164

6265
## Creating pull requests
6366

@@ -78,26 +81,46 @@ we'll guide you.
7881

7982
## Development workflow
8083

81-
The current development workflow is a bit tricky because we have this repo and we use our `coder/vscode` fork inside it with [`yarn link`](https://classic.yarnpkg.com/lang/en/docs/cli/link/).
82-
83-
Here are these steps you should follow to get your dev environment setup:
84-
8584
1. `git clone https://github.com/coder/code-server.git` - Clone `code-server`
8685
2. `git submodule update --init` - Clone `vscode` submodule
8786
3. `yarn` - Install dependencies
88-
4. `yarn watch` - This will spin up code-server on localhost:8080 which you can start developing. It will live reload changes to the source.
87+
4. `quilt patch -a` - Apply patches to the `vscode` submodule.
88+
5. `yarn watch` - Launch code-server localhost:8080. code-server will be live
89+
reloaded when changes are made; the browser needs to be refreshed manually.
8990

90-
### Updates to VS Code
91+
When pulling down changes that include modifications to the patches you will
92+
need to apply them with `quilt`. If you pull down changes that update the
93+
`vscode` submodule you will need to run `git submodule update --init` and
94+
re-apply the patches.
9195

92-
If changes are made and merged into `main` in the [`coder/vscode`](https://github.com/coder/vscode) repo, then you'll need to update the version in the `code-server` repo by following these steps:
96+
### Version updates to Code
9397

94-
1. Update the `lib/vscode` submodule to the latest `main`.
98+
1. Update the `lib/vscode` submodule to the desired upstream version branch.
9599
2. From the code-server **project root**, run `yarn install`.
96-
3. Test code-server locally to make sure everything works.
97-
4. Check the Node.js version that's used by Electron (which is shipped with VS
100+
3. Apply the patches (`quilt push -a`) or restore your stashed changes. At this
101+
stage you may need to resolve conflicts. For example use `quilt push -f`,
102+
manually apply the rejected portions, then `quilt refresh`.
103+
4. Test code-server locally to make sure everything works.
104+
5. Check the Node.js version that's used by Electron (which is shipped with VS
98105
Code. If necessary, update your version of Node.js to match.
99-
5. Commit the updated submodule to `code-server`.
100-
6. Open a PR.
106+
6. Commit the updated submodule and patches to `code-server`.
107+
7. Open a PR.
108+
109+
### Patching Code
110+
111+
0. You can go through the patch stack with `quilt push` and `quilt pop`.
112+
1. Create a new patch (`quilt new {name}.diff`) or use an existing patch.
113+
2. Add the file(s) you are patching (`quilt add [-P patch] {file}`). A file
114+
**must** be added before you make changes to it.
115+
3. Make your changes. Patches do not need to be independent of each other but
116+
each patch must result in a working code-server without any broken in-between
117+
states otherwise they are difficult to test and modify.
118+
4. Add your changes to the patch (`quilt refresh`)
119+
5. Add a comment in the patch about the reason for the patch and how to
120+
reproduce the behavior it fixes or adds. Every patch should have an e2e test
121+
as well.
122+
6. Do not modify dependencies in patches as those changes will be ignored. If
123+
we need to modify dependencies we can do it in a post-build step.
101124

102125
### Build
103126

@@ -193,99 +216,46 @@ code-server running locally. In CI, this is taken care of for you.
193216

194217
## Structure
195218

196-
The `code-server` script serves as an HTTP API for login and starting a remote VS
219+
The `code-server` script serves as an HTTP API for login and starting a remote
197220
Code process.
198221

199222
The CLI code is in [src/node](../src/node) and the HTTP routes are implemented
200223
in [src/node/routes](../src/node/routes).
201224

202-
Most of the meaty parts are in the VS Code portion of the codebase under
225+
Most of the meaty parts are in the Code portion of the codebase under
203226
[lib/vscode](../lib/vscode), which we describe next.
204227

205-
### Modifications to VS Code
206-
207-
In v1 of code-server, we had a patch of VS Code that split the codebase into a
208-
front-end and a server. The front-end consisted of the UI code, while the server
209-
ran the extensions and exposed an API to the front-end for file access and all
210-
UI needs.
211-
212-
Over time, Microsoft added support to VS Code to run it on the web. They have
213-
made the front-end open source, but not the server. As such, code-server v2 (and
214-
later) uses the VS Code front-end and implements the server. We do this by using
215-
a Git subtree to fork and modify VS Code. This code lives under
216-
[lib/vscode](../lib/vscode).
217-
218-
Some noteworthy changes in our version of VS Code include:
219-
220-
- Adding our build file, [`lib/vscode/coder.js`](../lib/vscode/coder.js), which includes build steps specific to code-server
221-
- Node.js version detection changes in [`build/lib/node.ts`](../lib/vscode/build/lib/node.ts) and [`build/lib/util.ts`](../lib/vscode/build/lib/util.ts)
222-
- Allowing extra extension directories
223-
- Added extra arguments to [`src/vs/platform/environment/common/argv.ts`](../lib/vscode/src/vs/platform/environment/common/argv.ts) and to [`src/vs/platform/environment/node/argv.ts`](../lib/vscode/src/vs/platform/environment/node/argv.ts)
224-
- Added extra environment state to [`src/vs/platform/environment/common/environment.ts`](../lib/vscode/src/vs/platform/environment/common/environment.ts);
225-
- Added extra getters to [`src/vs/platform/environment/common/environmentService.ts`](../lib/vscode/src/vs/platform/environment/common/environmentService.ts)
226-
- Added extra scanning paths to [`src/vs/platform/extensionManagement/node/extensionsScanner.ts`](../lib/vscode/src/vs/platform/extensionManagement/node/extensionsScanner.ts)
227-
- Additions/removals from [`package.json`](../lib/vscode/package.json):
228-
- Removing `electron`, `keytar` and `native-keymap` to avoid pulling in desktop dependencies during build on Linux
229-
- Removing `gulp-azure-storage` and `gulp-tar` (unsued in our build process, may pull in outdated dependencies)
230-
- Adding `proxy-agent`, `proxy-from-env` (for proxying) and `rimraf` (used during build/install steps)
231-
- Adding our branding/custom URLs/version:
232-
- [`product.json`](../lib/vscode/product.json)
233-
- [`src/vs/base/common/product.ts`](../lib/vscode/src/vs/base/common/product.ts)
234-
- [`src/vs/workbench/browser/parts/dialogs/dialogHandler.ts`](../lib/vscode/src/vs/workbench/browser/parts/dialogs/dialogHandler.ts)
235-
- [`src/vs/workbench/contrib/welcome/page/browser/vs_code_welcome_page.ts`](../lib/vscode/src/vs/workbench/contrib/welcome/page/browser/vs_code_welcome_page.ts)
236-
- [`src/vs/workbench/contrib/welcome/page/browser/welcomePage.ts`](../lib/vscode/src/vs/workbench/contrib/welcome/page/browser/welcomePage.ts)
237-
- Removing azure/macOS signing related dependencies from [`build/package.json`](../lib/vscode/build/package.json)
238-
- Modifying `.gitignore` to allow us to add files to `src/vs/server` and modifying `.eslintignore` to ignore lint on the shared files below (we use different formatter settings than VS Code).
239-
- Sharing some files with our codebase via symlinks:
240-
- [`src/vs/base/common/ipc.d.ts`](../lib/vscode/src/vs/base/common/ipc.d.ts) points to [`typings/ipc.d.ts`](../typings/ipc.d.ts)
241-
- [`src/vs/base/common/util.ts`](../lib/vscode/src/vs/base/common/util.ts) points to [`src/common/util.ts`](../src/common/util.ts)
242-
- [`src/vs/base/node/proxy_agent.ts`](../lib/vscode/src/vs/base/node/proxy_agent.ts) points to [`src/node/proxy_agent.ts`](../src/node/proxy_agent.ts)
243-
- Allowing socket changes by adding `setSocket` in [`src/vs/base/parts/ipc/common/ipc.net.ts`](../lib/vscode/src/vs/base/parts/ipc/common/ipc.net.ts)
244-
- We use this for connection persistence in our server-side code.
245-
- Added our server-side Node.JS code to `src/vs/server`.
246-
- This code includes the logic to spawn the various services (extension host, terminal, etc.) and some glue
247-
- Added [`src/vs/workbench/browser/client.ts`](../lib/vscode/src/vs/workbench/browser/client.ts) to hold some server customizations.
248-
- Includes the functionality for the Log Out command and menu item
249-
- Also, imported and called `initialize` from the main web file, [`src/vs/workbench/browser/web.main.ts`](../lib/vscode/src/vs/workbench/browser/web.main.ts)
250-
- Added a (hopefully temporary) hotfix to [`src/vs/workbench/common/resources.ts`](../lib/vscode/src/vs/workbench/common/resources.ts) to get context menu actions working for the Git integration.
251-
- Added connection type to WebSocket query parameters in [`src/vs/platform/remote/common/remoteAgentConnection.ts`](../lib/vscode/src/vs/platform/remote/common/remoteAgentConnection.ts)
252-
- Added `CODE_SERVER*` variables to the sanitization list in [`src/vs/base/common/processes.ts`](../lib/vscode/src/vs/base/common/processes.ts)
253-
- Fix localization support:
254-
- Added file [`src/vs/workbench/services/localizations/browser/localizationsService.ts`](../lib/vscode/src/vs/workbench/services/localizations/browser/localizationsService.ts).
255-
- Modified file [`src/vs/base/common/platform.ts`](../lib/vscode/src/vs/base/common/platform.ts)
256-
- Modified file [`src/vs/base/node/languagePacks.js`](../lib/vscode/src/vs/base/node/languagePacks.js)
257-
- Added code to allow server to inject settings to [`src/vs/platform/product/common/product.ts`](../lib/vscode/src/vs/platform/product/common/product.ts)
258-
- Extension fixes:
259-
- Avoid disabling extensions by extensionKind in [`src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts`](../lib/vscode/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts) (Needed for vscode-icons)
260-
- Remove broken symlinks in [`extensions/postinstall.js`](../lib/vscode/extensions/postinstall.js)
261-
- Add tip about extension gallery in [`src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts`](../lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts)
262-
- Use our own server for GitHub authentication in [`extensions/github-authentication/src/githubServer.ts`](../lib/vscode/extensions/github-authentication/src/githubServer.ts)
263-
- Settings persistence on the server in [`src/vs/workbench/services/environment/browser/environmentService.ts`](../lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts)
264-
- Add extension install fallback in [`src/vs/workbench/services/extensionManagement/common/extensionManagementService.ts`](../lib/vscode/src/vs/workbench/services/extensionManagement/common/extensionManagementService.ts)
265-
- Add proxy-agent monkeypatch and keep extension host indefinitely running in [`src/vs/workbench/services/extensions/node/extensionHostProcessSetup.ts`](../lib/vscode/src/vs/workbench/services/extensions/node/extensionHostProcessSetup.ts)
266-
- Patch build system to avoid removing extension dependencies for `yarn global add` users in [`build/lib/extensions.ts`](../lib/vscode/build/lib/extensions.ts)
267-
- Allow all extensions to use proposed APIs in [`src/vs/workbench/services/environment/browser/environmentService.ts`](../lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts)
268-
- Make storage writes async to allow extensions to wait for them to complete in [`src/vs/platform/storage/common/storage.ts`](../lib/vscode/src/vs/platform/storage/common/storage.ts)
269-
- Specify webview path in [`src/vs/code/browser/workbench/workbench.ts`](../lib/vscode/src/vs/code/browser/workbench/workbench.ts)
270-
- URL readability improvements for folder/workspace in [`src/vs/code/browser/workbench/workbench.ts`](../lib/vscode/src/vs/code/browser/workbench/workbench.ts)
271-
- Socket/Authority-related fixes (for remote proxying etc.):
272-
- [`src/vs/code/browser/workbench/workbench.ts`](../lib/vscode/src/vs/code/browser/workbench/workbench.ts)
273-
- [`src/vs/platform/remote/browser/browserSocketFactory.ts`](../lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts)
274-
- [`src/vs/base/common/network.ts`](../lib/vscode/src/vs/base/common/network.ts)
275-
- Added code to write out IPC path in [`src/vs/workbench/api/node/extHostCLIServer.ts`](../lib/vscode/src/vs/workbench/api/node/extHostCLIServer.ts)
276-
277-
As the web portion of VS Code matures, we'll be able to shrink and possibly
278-
eliminate our modifications. In the meantime, upgrading the VS Code version requires
279-
us to ensure that our changes are still applied and work as intended. In the future,
280-
we'd like to run VS Code unit tests against our builds to ensure that features
281-
work as expected.
228+
### Modifications to Code
229+
230+
Our modifications to Code can be found in the [patches](../patches) directory.
231+
We pull in Code as a submodule pointing to an upstream release branch.
232+
233+
In v1 of code-server, we had Code as a submodule and used a single massive patch
234+
that split the codebase into a front-end and a server. The front-end consisted
235+
of the UI code, while the server ran the extensions and exposed an API to the
236+
front-end for file access and all UI needs.
237+
238+
Over time, Microsoft added support to Code to run it on the web. They had made
239+
the front-end open source, but not the server. As such, code-server v2 (and
240+
later) uses the Code front-end and implements the server. We did this by using a
241+
Git subtree to fork and modify Code.
242+
243+
Microsoft eventually made the server open source and we were able to reduce our
244+
changes significantly. Some time later we moved back to a submodule and patches
245+
(managed by `quilt` this time instead of the mega-patch).
246+
247+
As the web portion of Code continues to mature, we'll be able to shrink and
248+
possibly eliminate our patches. In the meantime, upgrading the Code version
249+
requires us to ensure that our changes are still applied correctly and work as
250+
intended. In the future, we'd like to run Code unit tests against our builds to
251+
ensure that features work as expected.
282252

283253
> We have [extension docs](../ci/README.md) on the CI and build system.
284254
285-
If the functionality you're working on does NOT depend on code from VS Code, please
255+
If the functionality you're working on does NOT depend on code from Code, please
286256
move it out and into code-server.
287257

288258
### Currently Known Issues
289259

290-
- Creating custom VS Code extensions and debugging them doesn't work
260+
- Creating custom Code extensions and debugging them doesn't work
291261
- Extension profiling and tips are currently disabled

lib/vscode

Submodule vscode updated 67 files

0 commit comments

Comments
 (0)