Skip to content

Commit 612b831

Browse files
committed
feat(update-vscode): add step to commit files
1 parent f19ae17 commit 612b831

File tree

1 file changed

+44
-5
lines changed

1 file changed

+44
-5
lines changed

ci/dev/update-vscode.sh

+44-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4+
# This function expects two arguments
5+
# 1. the vscode version we're updating to
6+
# 2. the list of merge conflict files
7+
make_pr_body(){
8+
local BODY="This PR updates vscode to $1
9+
10+
## TODOS
11+
12+
- [ ] test editor locally
13+
- [ ] test terminal locally
14+
- [ ] make notes about any significant changes in docs/CONTRIBUTING.md#notes-about-changes
15+
16+
## Files with conflicts (fix these)
17+
$2"
18+
echo "$BODY"
19+
}
20+
421
main() {
522
cd "$(dirname "$0")/../.."
623

@@ -37,6 +54,12 @@ main() {
3754

3855
echo -e "Great! We'll prep a PR for updating to $VSCODE_EXACT_VERSION\n"
3956

57+
# For some reason the subtree update doesn't work
58+
# unless we fetch all the branches
59+
echo -e "Fetching vscode branches..."
60+
echo -e "Note: this might take a while"
61+
git fetch vscode
62+
4063
# Check if GitHub CLI is installed
4164
if ! command -v gh &> /dev/null; then
4265
echo "GitHub CLI could not be found."
@@ -55,14 +78,30 @@ main() {
5578
git push origin "$CURRENT_BRANCH"
5679
fi
5780

58-
echo "Opening a draft PR on GitHub"
59-
# To read about these flags, visit the docs: https://cli.github.com/manual/gh_pr_create
60-
gh pr create --base master --title "feat(vscode): update to version $VSCODE_EXACT_VERSION" --body "This PR updates vscode to version: $VSCODE_EXACT_VERSION" --reviewer @cdr/code-server-reviewers --repo cdr/code-server --draft
61-
6281
echo "Going to try to update vscode for you..."
6382
echo -e "Running: git subtree pull --prefix lib/vscode vscode release/${VSCODE_VERSION_TO_UPDATE} --squash\n"
6483
# Try to run subtree update command
65-
git subtree pull --prefix lib/vscode vscode release/"${VSCODE_VERSION_TO_UPDATE}" --squash --message "chore(vscode): update to $VSCODE_VERSION_TO_UPDATE"
84+
# Note: we add `|| true` because we want the script to keep running even if the squash fails
85+
# We know the squash fails everytime because there will always be merge conflicts
86+
git subtree pull --prefix lib/vscode vscode release/"${VSCODE_VERSION_TO_UPDATE}" --squash || true
87+
88+
# Get the files with conflicts before we commit them
89+
# so we can list them in the PR body
90+
CONFLICTS=$(git diff --name-only --diff-filter=U | while read line; do echo "- $line"; done)
91+
92+
PR_BODY=$(make_pr_body $VSCODE_EXACT_VERSION $CONFLICTS)
93+
94+
echo "Forcing a commit with conflicts"
95+
echo "Note: this is intentional"
96+
echo "If we don't do this, code review is impossible."
97+
echo "For more info, see docs: docs/CONTRIBUTING.md#updating-vs-code"
98+
git add . && git commit -am "chore(vscode): update to $VSCODE_EXACT_VERSION"
99+
100+
# Note: we can't open a draft PR unless their are changes.
101+
# Hence why we do this after the subtree update.
102+
echo "Opening a draft PR on GitHub"
103+
# To read about these flags, visit the docs: https://cli.github.com/manual/gh_pr_create
104+
gh pr create --base master --title "feat(vscode): update to version $VSCODE_EXACT_VERSION" --body $PR_BODY --reviewer @cdr/code-server-reviewers --repo cdr/code-server --draft
66105
}
67106
68107
main "$@"

0 commit comments

Comments
 (0)