Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(installation): Optimize Rustlings Installation in Gitpod Workspaces #1766

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,35 +135,42 @@ else
echo "SUCCESS: Rust is up to date"
fi

Path=${1:-rustlings/}
echo "Cloning Rustlings at $Path..."
git clone -q https://github.com/rust-lang/rustlings "$Path"
# We don't need to clone if installing in Gitpod.io environment
if [[ -z ${GITPOD_WORKSPACE_ID} ]]
then
Path=${1:-rustlings/}

cd "$Path"
echo "Cloning Rustlings at $Path..."
git clone -q https://github.com/rust-lang/rustlings "$Path"

Version=$(curl -s https://api.github.com/repos/rust-lang/rustlings/releases/latest | ${PY} -c "import json,sys;obj=json.load(sys.stdin);print(obj['tag_name']) if 'tag_name' in obj else sys.exit(f\"Error: {obj['message']}\");")
CargoBin="${CARGO_HOME:-$HOME/.cargo}/bin"
cd "$Path"

if [[ -z ${Version} ]]
then
echo "The latest tag version could not be fetched remotely."
echo "Using the local git repository..."
Version=$(ls -tr .git/refs/tags/ | tail -1)
if [[ -z ${Version} ]]
Version=$(curl -s https://api.github.com/repos/rust-lang/rustlings/releases/latest | ${PY} -c "import json,sys;obj=json.load(sys.stdin);print(obj['tag_name']) if 'tag_name' in obj else sys.exit(f\"Error: {obj['message']}\");")
CargoBin="${CARGO_HOME:-$HOME/.cargo}/bin"

if [[ -z ${Version} ]]
then
echo "No valid tag version found"
echo "Rustlings will be installed using the main branch"
Version="main"
echo "The latest tag version could not be fetched remotely."
echo "Using the local git repository..."
Version=$(ls -tr .git/refs/tags/ | tail -1)
if [[ -z ${Version} ]]
then
echo "No valid tag version found"
echo "Rustlings will be installed using the main branch"
Version="main"
else
Version="tags/${Version}"
fi
else
Version="tags/${Version}"
fi

echo "Checking out version $Version..."
git checkout -q ${Version}
else
Version="tags/${Version}"
echo "GITPOD_WORKSPACE_ID found. Skipping git clone and git checkout."
fi

echo "Checking out version $Version..."
git checkout -q ${Version}

echo "Installing the 'rustlings' executable..."
cargo install --force --path .

Expand Down
1 change: 1 addition & 0 deletions rustlings
Submodule rustlings added at 9a743f
Loading