|
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 |
|
@@ -64,19 +81,27 @@ main() {
|
64 | 81 | echo "Going to try to update vscode for you..."
|
65 | 82 | echo -e "Running: git subtree pull --prefix lib/vscode vscode release/${VSCODE_VERSION_TO_UPDATE} --squash\n"
|
66 | 83 | # Try to run subtree update command
|
67 |
| - git subtree pull --prefix lib/vscode vscode release/"${VSCODE_VERSION_TO_UPDATE}" --squash --message "chore(vscode): update to $VSCODE_EXACT_VERSION" |
| 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) |
68 | 93 |
|
69 | 94 | echo "Forcing a commit with conflicts"
|
70 | 95 | echo "Note: this is intentional"
|
71 | 96 | echo "If we don't do this, code review is impossible."
|
72 | 97 | echo "For more info, see docs: docs/CONTRIBUTING.md#updating-vs-code"
|
73 |
| - git add . && git commit -am "chore(vscode): commit conflicts from $VSCODE_EXACT_VERSION update" |
| 98 | + git add . && git commit -am "chore(vscode): update to $VSCODE_EXACT_VERSION" |
74 | 99 |
|
75 | 100 | # Note: we can't open a draft PR unless their are changes.
|
76 | 101 | # Hence why we do this after the subtree update.
|
77 | 102 | echo "Opening a draft PR on GitHub"
|
78 | 103 | # To read about these flags, visit the docs: https://cli.github.com/manual/gh_pr_create
|
79 |
| - 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 |
| 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 |
80 | 105 | }
|
81 | 106 |
|
82 | 107 | main "$@"
|
0 commit comments