1
1
#! /usr/bin/env bash
2
2
set -euo pipefail
3
3
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
+
4
21
main () {
5
22
cd " $( dirname " $0 " ) /../.."
6
23
@@ -37,6 +54,12 @@ main() {
37
54
38
55
echo -e " Great! We'll prep a PR for updating to $VSCODE_EXACT_VERSION \n"
39
56
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
+
40
63
# Check if GitHub CLI is installed
41
64
if ! command -v gh & > /dev/null; then
42
65
echo " GitHub CLI could not be found."
@@ -55,14 +78,30 @@ main() {
55
78
git push origin " $CURRENT_BRANCH "
56
79
fi
57
80
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
-
62
81
echo " Going to try to update vscode for you..."
63
82
echo -e " Running: git subtree pull --prefix lib/vscode vscode release/${VSCODE_VERSION_TO_UPDATE} --squash\n"
64
83
# 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
66
105
}
67
106
68
107
main " $@ "
0 commit comments