Skip to content

Commit

Permalink
chore: Restore vendor script, new script for step-by-step vendoring
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Mar 23, 2024
1 parent 38057b1 commit bd72827
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 48 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RELEASE.md
\.github
^\.gitattributes$
^vendor\.sh$
^vendor-one\.sh$
^rconfigure\.py$
^src/\.editorconfig$
^\.vscode$
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/vendor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
- main
paths:
- ".github/workflows/vendor.yaml"
- "vendor.sh"
- "vendor-one.sh"
workflow_dispatch:
schedule:
- cron: "*/5 * * * *"
Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:
id: vendor
run: |
git pull --rebase
./vendor.sh .git/duckdb
./vendor-one.sh .git/duckdb
rm -rf .git/duckdb
git push --dry-run
# Check if ahead of upstream branch
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Then run the following commands

``` sh
~ (cd duckdb && git checkout {{desired_branch}})
~ (cd ducdkb-r && ./vendor.sh)
~ (cd ducdkb-r && ./vendor-one.sh)
~ (cd duckdb-r && R CMD INSTALL .)
```

Expand Down
76 changes: 76 additions & 0 deletions vendor-one.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash
# https://unix.stackexchange.com/a/654932/19205
# Using bash for -o pipefail

set -e
set -x
set -o pipefail

cd `dirname $0`

if [ -z "$1" ]; then
upstream_basedir=../duckdb
else
upstream_basedir="$1"
fi

upstream_dir=.git/duckdb

if [ "$upstream_basedir" != ".git/duckdb" ]; then
git clone "$upstream_basedir" "$upstream_dir"
fi

if [ -n "$(git status --porcelain)" ]; then
echo "Error: working directory not clean"
exit 1
fi

if [ -n "$(git -C "$upstream_dir" status --porcelain)" ]; then
echo "Warning: working directory $upstream_dir not clean"
fi

original=$(git -C "$upstream_dir" rev-parse --verify HEAD)

base=$(git log -n 3 --format="%s" -- src/duckdb | tee /dev/stderr | sed -nr '/^.*duckdb.duckdb@([0-9a-f]+)$/{s//\1/;p;}' | head -n 1)

message=

for commit in $(git -C "$upstream_dir" log --first-parent --reverse --format="%H" ${base}..HEAD); do
echo "Importing commit $commit"

git -C "$upstream_dir" checkout "$commit"

rm -rf src/duckdb

echo "R: configure"
DUCKDB_PATH="$upstream_dir" python3 rconfigure.py

# Always vendor tags
if [ $(git -C "$upstream_dir" describe --tags | grep -c -- -) -eq 0 ]; then
message="chore: Update vendored sources (tag $(git -C "$upstream_dir" describe --tags)) to duckdb/duckdb@$commit"
changed=1
break
fi

if [ $(git status --porcelain -- src/duckdb | wc -l) -gt 1 ]; then
message="chore: Update vendored sources to duckdb/duckdb@$commit"
break
fi
done

if [ "$message" = "" ]; then
echo "No changes."
git checkout -- src/duckdb
rm -rf "$upstream_dir"
exit 0
fi

git add .

(
echo "$message"
echo
git -C "$upstream_dir" log --first-parent --format="%s" ${base}..${commit} | tee /dev/stderr | sed -r 's%(#[0-9]+)%duckdb/duckdb\1%g'
) | git commit --file /dev/stdin

rm -rf "$upstream_dir"
59 changes: 14 additions & 45 deletions vendor.sh
Original file line number Diff line number Diff line change
@@ -1,76 +1,45 @@
#!/bin/bash
# https://unix.stackexchange.com/a/654932/19205
# Using bash for -o pipefail
#!/bin/sh

set -e
set -x
set -o pipefail

cd `dirname $0`

if [ -z "$1" ]; then
upstream_basedir=../duckdb
duckdir=../duckdb
else
upstream_basedir="$1"
fi

upstream_dir=.git/duckdb

if [ "$upstream_basedir" != ".git/duckdb" ]; then
git clone "$upstream_basedir" "$upstream_dir"
duckdir="$1"
fi

if [ -n "$(git status --porcelain)" ]; then
echo "Error: working directory not clean"
exit 1
fi

if [ -n "$(git -C "$upstream_dir" status --porcelain)" ]; then
echo "Warning: working directory $upstream_dir not clean"
if [ -n "$(git -C "$duckdir" status --porcelain)" ]; then
echo "Warning: working directory $duckdir not clean"
fi

original=$(git -C "$upstream_dir" rev-parse --verify HEAD)

base=$(git log -n 3 --format="%s" -- src/duckdb | tee /dev/stderr | sed -nr '/^.*duckdb.duckdb@([0-9a-f]+)$/{s//\1/;p;}' | head -n 1)

message=
commit=$(git -C "$duckdir" rev-parse HEAD)
echo "Importing commit $commit"

for commit in $(git -C "$upstream_dir" log --first-parent --reverse --format="%H" ${base}..HEAD); do
echo "Importing commit $commit"
base=$(git log -n 1 --format="%s" -- src/duckdb | sed 's#^.*duckdb/duckdb@##')

git -C "$upstream_dir" checkout "$commit"
rm -rf src/duckdb

rm -rf src/duckdb
echo "R: configure"
python3 rconfigure.py

echo "R: configure"
DUCKDB_PATH="$upstream_dir" python3 rconfigure.py

# Always vendor tags
if [ $(git -C "$upstream_dir" describe --tags | grep -c -- -) -eq 0 ]; then
message="chore: Update vendored sources (tag $(git -C "$upstream_dir" describe --tags)) to duckdb/duckdb@$commit"
changed=1
break
fi

if [ $(git status --porcelain -- src/duckdb | wc -l) -gt 1 ]; then
message="chore: Update vendored sources to duckdb/duckdb@$commit"
break
fi
done

if [ "$message" = "" ]; then
if [ $(git status --porcelain -- src/duckdb | wc -l) -le 1 ]; then
echo "No changes."
git checkout -- src/duckdb
rm -rf "$upstream_dir"
exit 0
fi

git add .

(
echo "$message"
echo "chore: Update vendored sources to duckdb/duckdb@$commit"
echo
git -C "$upstream_dir" log --first-parent --format="%s" ${base}..${commit} | tee /dev/stderr | sed -r 's%(#[0-9]+)%duckdb/duckdb\1%g'
git -C "$duckdir" log --first-parent --format="%s" ${base}..${commit} | sed -r 's%(#[0-9]+)%duckdb/duckdb\1%g'
) | git commit --file /dev/stdin

rm -rf "$upstream_dir"

0 comments on commit bd72827

Please sign in to comment.