Skip to content

Commit b1e5854

Browse files
authored
[Bugfix:Developer] Lock tree sitter (#13)
* 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
1 parent 673dbe0 commit b1e5854

2 files changed

Lines changed: 32 additions & 6 deletions

File tree

build.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ mkdir -p "${BUILD_DIR}"
1212
mkdir -p "${INCLUDE_DIR}"
1313

1414
########################################################################
15+
# These variables specify the minimum version necessary for
16+
# dependencies between versions.
17+
source "${CUR_DIR}"/versions.sh
1518

19+
########################################################################
1620
# Clone the tree-sitter repos
1721
repos=( tree-sitter tree-sitter-python tree-sitter-c tree-sitter-cpp tree-sitter-java)
1822

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

2327
echo "clone or update ${repo}... "
24-
28+
LOCKED_BRANCH="${repo//-/_}"_hash
29+
cd "${CUR_DIR}"
2530
if [ -d "${dir}" ]; then
2631
echo "pulling changes ..."
2732
# IF THE REPO ALREADY EXISTS...
2833
pushd "${dir}"
2934

30-
CURRENT_BRANCH=$(git branch --show-current)
31-
3235
# PULL CHANGES
3336
git fetch
34-
git reset --hard HEAD
35-
git merge "origin/${CURRENT_BRANCH}"
37+
git reset --hard "${!LOCKED_BRANCH}"
3638

3739
popd
3840
else
3941
# THE REPO DID NOT EXIST
4042
echo "the repository did not previously exist cloning... "
41-
git clone --depth 1 "https://github.com/tree-sitter/${repo}" "${INCLUDE_DIR}/${repo}"
43+
git clone "https://github.com/tree-sitter/${repo}" "${INCLUDE_DIR}/${repo}"
44+
pushd "${dir}"
45+
git reset --hard "${!LOCKED_BRANCH}"
46+
popd
4247
fi
4348
done
4449

versions.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
########################################################################
3+
4+
# These variables specify the version of these dependencies that we
5+
# want. This affects both checking out the repo as well as installation
6+
# of built artificats.
7+
8+
# If tree sitter in the future has more consistant releases, or better ways
9+
# of locking the version, adjust this to be versions instead of commits
10+
11+
# TREE-SITTER REPOS
12+
# Python -- Merge pull request #193 from tree-sitter/tausbn/... -- Feb 28, 23
13+
export tree_sitter_python_hash=62827156d01c74dc1538266344e788da74536b8a
14+
# Tree-Sitter - Avoid unused value warning from array_pop -- Jun 14, 23
15+
export tree_sitter_hash=d0029a15273e526925a764033e9b7f18f96a7ce5
16+
# cpp -- Merge pull request #209 from amaanq/rewrite-it-in-c -- Jun 18, 23
17+
export tree_sitter_cpp_hash=2e29f23abcb5f92ddffb22de8b292f09ed78db01
18+
# C -- Merge pull request #141 from JasonBrownDeveloper/offsetof -- Jun 13, 23
19+
export tree_sitter_c_hash=f1b2a0b2102ff001a4ed9a26cd9a9405d09c590c
20+
# Java -- Merge pull request #144 from stelf/patch-1 -- April 19, 23
21+
export tree_sitter_java_hash=c194ee5e6ede5f26cf4799feead4a8f165dcf14d

0 commit comments

Comments
 (0)