Skip to content

Commit 299e17e

Browse files
committed
refactor: update script command to get git branch
1 parent a1dca6d commit 299e17e

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

.github/PULL_REQUEST_TEMPLATE/release_template.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!-- Note: this variable $CODE_SERVER_VERSION_TO_UPDATE will be set when you run the release-prep.sh script with `yarn release:prep` -->
2+
23
This PR is to generate a new release of `code-server` at `$CODE_SERVER_VERSION_TO_UPDATE`
34

45
## Screenshot

ci/build/release-prep.sh

+12-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# 2. Update the version of code-server (package.json, docs, etc.)
66
# 3. Update the code coverage badge in the README
77
# 4. Open a draft PR using the release_template.md and view in browser
8-
# If you want to perform a dry run of this script run DRY_RUN=0 yarn release:prep
8+
# If you want to perform a dry run of this script run DRY_RUN=1 yarn release:prep
99

1010
set -euo pipefail
1111

@@ -78,10 +78,7 @@ main() {
7878
read -r -p "What version of code-server do you want to update to?"$'\n' CODE_SERVER_VERSION_TO_UPDATE
7979

8080
echo -e "Great! We'll prep a PR for updating to $CODE_SERVER_VERSION_TO_UPDATE\n"
81-
# I can't tell you why but
82-
# when searching with rg, the version needs to in this format: '3\.7\.5'
83-
# that's why we have the parameter expansion with the regex
84-
$CMD rg -g '!yarn.lock' -g '!*.svg' --files-with-matches "${CODE_SERVER_CURRENT_VERSION//\./\\.}" | $CMD xargs sd "$CODE_SERVER_CURRENT_VERSION" "$CODE_SERVER_VERSION_TO_UPDATE"
81+
$CMD rg -g '!yarn.lock' -g '!*.svg' --files-with-matches --fixed-strings "${CODE_SERVER_CURRENT_VERSION}" | $CMD xargs sd "$CODE_SERVER_CURRENT_VERSION" "$CODE_SERVER_VERSION_TO_UPDATE"
8582

8683
# Ensure the tests are passing and code coverage is up-to-date
8784
echo -e "Running unit tests and updating code coverage...\n"
@@ -91,12 +88,19 @@ main() {
9188
# Updates the svg to be green for the badge
9289
$CMD sd "red.svg" "green.svg" ../../README.md
9390

94-
$CMD git add . && $CMD git commit -am "chore(release): bump version to $CODE_SERVER_VERSION_TO_UPDATE"
91+
$CMD git commit -am "chore(release): bump version to $CODE_SERVER_VERSION_TO_UPDATE"
9592

96-
CURRENT_BRANCH=$(git branch --show-current)
9793
# Note: we need to set upstream as well or the gh pr create step will fail
9894
# See: https://github.com/cli/cli/issues/575
99-
$CMD git push -u origin "$CURRENT_BRANCH"
95+
CURRENT_BRANCH=$(git branch | grep '\*' | cut -d' ' -f2-)
96+
if [[ -z $(git config "branch.${CURRENT_BRANCH}.remote") ]]; then
97+
echo "Doesn't look like you've pushed this branch to remote"
98+
echo -e "Pushing now using: git push origin $CURRENT_BRANCH\n"
99+
# Note: we need to set upstream as well or the gh pr create step will fail
100+
# See: https://github.com/cli/cli/issues/575
101+
echo "Please set the upstream and re-run the script"
102+
exit 1
103+
fi
100104

101105
# This runs from the root so that's why we use this path vs. ../../
102106
RELEASE_TEMPLATE_STRING=$(cat ./.github/PULL_REQUEST_TEMPLATE/release_template.md)

ci/dev/update-vscode.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ main() {
8181
# Push branch to remote if not already pushed
8282
# If we don't do this, the opening a draft PR step won't work
8383
# because it will stop and ask where you want to push the branch
84-
CURRENT_BRANCH=$(git branch --show-current)
85-
if [[ -z $(git ls-remote --heads origin "$CURRENT_BRANCH") ]]; then
84+
CURRENT_BRANCH=$(git branch | grep '\*' | cut -d' ' -f2-)
85+
if [[ -z $(git config "branch.${CURRENT_BRANCH}.remote") ]]; then
8686
echo "Doesn't look like you've pushed this branch to remote"
8787
echo -e "Pushing now using: git push origin $CURRENT_BRANCH\n"
8888
# Note: we need to set upstream as well or the gh pr create step will fail
8989
# See: https://github.com/cli/cli/issues/575
90-
git push -u origin "$CURRENT_BRANCH"
90+
echo "Please set the upstream and re-run the script"
91+
exit 1
9192
fi
9293

9394
echo "Going to try to update vscode for you..."

0 commit comments

Comments
 (0)