Skip to content

Commit

Permalink
[Bugfix:Developer] Lock tree sitter (#13)
Browse files Browse the repository at this point in the history
* lock tree sitter to hash of most recent commit

* add scanner.c to test

* testing fix

* change identifier

* update branch usage

* spacing change to fix var name

* re-add string changes:

* change to string, and relocate locked_branch

* adjust path

* adjusting cloningg and resetting

* uncomment popd

* pushd and popd instead of cd

* shellcheck changes

* linting and spacing changes
  • Loading branch information
IDzyre authored Jun 22, 2023
1 parent 673dbe0 commit b1e5854
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
17 changes: 11 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ mkdir -p "${BUILD_DIR}"
mkdir -p "${INCLUDE_DIR}"

########################################################################
# These variables specify the minimum version necessary for
# dependencies between versions.
source "${CUR_DIR}"/versions.sh

########################################################################
# Clone the tree-sitter repos
repos=( tree-sitter tree-sitter-python tree-sitter-c tree-sitter-cpp tree-sitter-java)

Expand All @@ -21,24 +25,25 @@ do
dir="${INCLUDE_DIR}/${repo}"

echo "clone or update ${repo}... "

LOCKED_BRANCH="${repo//-/_}"_hash
cd "${CUR_DIR}"
if [ -d "${dir}" ]; then
echo "pulling changes ..."
# IF THE REPO ALREADY EXISTS...
pushd "${dir}"

CURRENT_BRANCH=$(git branch --show-current)

# PULL CHANGES
git fetch
git reset --hard HEAD
git merge "origin/${CURRENT_BRANCH}"
git reset --hard "${!LOCKED_BRANCH}"

popd
else
# THE REPO DID NOT EXIST
echo "the repository did not previously exist cloning... "
git clone --depth 1 "https://github.com/tree-sitter/${repo}" "${INCLUDE_DIR}/${repo}"
git clone "https://github.com/tree-sitter/${repo}" "${INCLUDE_DIR}/${repo}"
pushd "${dir}"
git reset --hard "${!LOCKED_BRANCH}"
popd
fi
done

Expand Down
21 changes: 21 additions & 0 deletions versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
########################################################################

# These variables specify the version of these dependencies that we
# want. This affects both checking out the repo as well as installation
# of built artificats.

# If tree sitter in the future has more consistant releases, or better ways
# of locking the version, adjust this to be versions instead of commits

# TREE-SITTER REPOS
# Python -- Merge pull request #193 from tree-sitter/tausbn/... -- Feb 28, 23
export tree_sitter_python_hash=62827156d01c74dc1538266344e788da74536b8a
# Tree-Sitter - Avoid unused value warning from array_pop -- Jun 14, 23
export tree_sitter_hash=d0029a15273e526925a764033e9b7f18f96a7ce5
# cpp -- Merge pull request #209 from amaanq/rewrite-it-in-c -- Jun 18, 23
export tree_sitter_cpp_hash=2e29f23abcb5f92ddffb22de8b292f09ed78db01
# C -- Merge pull request #141 from JasonBrownDeveloper/offsetof -- Jun 13, 23
export tree_sitter_c_hash=f1b2a0b2102ff001a4ed9a26cd9a9405d09c590c
# Java -- Merge pull request #144 from stelf/patch-1 -- April 19, 23
export tree_sitter_java_hash=c194ee5e6ede5f26cf4799feead4a8f165dcf14d

0 comments on commit b1e5854

Please sign in to comment.