-
-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathinstall-from-pr.sh
More file actions
executable file
·61 lines (49 loc) · 2.14 KB
/
Copy pathinstall-from-pr.sh
File metadata and controls
executable file
·61 lines (49 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
set -euo pipefail
# Installs a version of Cursorless from a PR branch, uninstalling production
# Cursorless first and using a special extension id to break update chain.
# Requires gh cli to be installed (https://cli.github.com/).
# Ensure we have a PR number
if [ $# -ne 1 ]; then
echo "Usage: $0 <pr-number>"
exit 1
fi
# Ensure gh cli is installed
if ! command -v gh &>/dev/null; then
echo "gh cli could not be found. See https://cli.github.com/"
exit 1
fi
# Use CURSORLESS_VSCODE_COMMAND if set, otherwise default to 'code'
vscode_command="${CURSORLESS_VSCODE_COMMAND:-code}"
# Ensure VSCode command is installed
if ! command -v "$vscode_command" &>/dev/null; then
echo "VSCode command '$vscode_command' not found"
echo "Install VS Code or set CURSORLESS_VSCODE_COMMAND to your VS Code binary (e.g., 'codium', 'cursor')"
echo "See: https://code.visualstudio.com/docs/editor/command-line"
exit 1
fi
pr_number="$1"
repo="cursorless-dev/cursorless"
# 1. Get latest check runs from PR, waiting for them to finish if necessary
checks=$(gh pr checks --repo "$repo" "$pr_number" || echo "still-running")
if [[ $checks == *still-running ]]; then
gh pr checks --repo "$repo" "$pr_number" --watch
checks=$(gh pr checks --repo "$repo" "$pr_number" || echo "still-running")
fi
# 2. Get desired check run (ubuntu-latest, stable)
check_number=$(echo "$checks" | grep -F 'Test (ubuntu-latest, stable)' | cut -d / -f8)
echo "Downloading vsix for PR $pr_number from check $check_number"
# Temp directory to put downloaded extension
tmpdir=$(mktemp -d 2>/dev/null || mktemp -d -t 'cursorless-vsix')
function finish {
rm -rf "$tmpdir"
}
trap finish EXIT
# 3. Download extension vsix
gh run download "$check_number" --repo "$repo" --name vsix --dir "$tmpdir"
# 4. Uninstall production cursorless
"$vscode_command" --uninstall-extension pokey.cursorless || echo "Cursorless not currently installed"
# 5. Install downloaded extension
"$vscode_command" --install-extension "$tmpdir/cursorless-development.vsix" --force
echo -e "\e[1;32mPlease restart VSCode\e[0m"
echo "To uninstall and revert to production Cursorless, run the adjacent uninstall-local.sh"