|
1 | | -#!/bin/bash |
2 | | -# https://unix.stackexchange.com/a/654932/19205 |
3 | | -# Using bash for -o pipefail |
| 1 | +#!/bin/sh |
4 | 2 |
|
5 | 3 | set -e |
6 | 4 | set -x |
7 | | -set -o pipefail |
8 | 5 |
|
9 | 6 | cd `dirname $0` |
10 | 7 |
|
11 | 8 | if [ -z "$1" ]; then |
12 | | - upstream_basedir=../duckdb |
| 9 | + duckdir=../duckdb |
13 | 10 | else |
14 | | - upstream_basedir="$1" |
15 | | -fi |
16 | | - |
17 | | -upstream_dir=.git/duckdb |
18 | | - |
19 | | -if [ "$upstream_basedir" != ".git/duckdb" ]; then |
20 | | - git clone "$upstream_basedir" "$upstream_dir" |
| 11 | + duckdir="$1" |
21 | 12 | fi |
22 | 13 |
|
23 | 14 | if [ -n "$(git status --porcelain)" ]; then |
24 | 15 | echo "Error: working directory not clean" |
25 | 16 | exit 1 |
26 | 17 | fi |
27 | 18 |
|
28 | | -if [ -n "$(git -C "$upstream_dir" status --porcelain)" ]; then |
29 | | - echo "Warning: working directory $upstream_dir not clean" |
| 19 | +if [ -n "$(git -C "$duckdir" status --porcelain)" ]; then |
| 20 | + echo "Warning: working directory $duckdir not clean" |
30 | 21 | fi |
31 | 22 |
|
32 | | -original=$(git -C "$upstream_dir" rev-parse --verify HEAD) |
33 | | - |
34 | | -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) |
35 | | - |
36 | | -message= |
| 23 | +commit=$(git -C "$duckdir" rev-parse HEAD) |
| 24 | +echo "Importing commit $commit" |
37 | 25 |
|
38 | | -for commit in $(git -C "$upstream_dir" log --first-parent --reverse --format="%H" ${base}..HEAD); do |
39 | | - echo "Importing commit $commit" |
| 26 | +base=$(git log -n 1 --format="%s" -- src/duckdb | sed 's#^.*duckdb/duckdb@##') |
40 | 27 |
|
41 | | - git -C "$upstream_dir" checkout "$commit" |
| 28 | +rm -rf src/duckdb |
42 | 29 |
|
43 | | - rm -rf src/duckdb |
| 30 | +echo "R: configure" |
| 31 | +python3 rconfigure.py |
44 | 32 |
|
45 | | - echo "R: configure" |
46 | | - DUCKDB_PATH="$upstream_dir" python3 rconfigure.py |
47 | | - |
48 | | - # Always vendor tags |
49 | | - if [ $(git -C "$upstream_dir" describe --tags | grep -c -- -) -eq 0 ]; then |
50 | | - message="chore: Update vendored sources (tag $(git -C "$upstream_dir" describe --tags)) to duckdb/duckdb@$commit" |
51 | | - changed=1 |
52 | | - break |
53 | | - fi |
54 | | - |
55 | | - if [ $(git status --porcelain -- src/duckdb | wc -l) -gt 1 ]; then |
56 | | - message="chore: Update vendored sources to duckdb/duckdb@$commit" |
57 | | - break |
58 | | - fi |
59 | | -done |
60 | | - |
61 | | -if [ "$message" = "" ]; then |
| 33 | +if [ $(git status --porcelain -- src/duckdb | wc -l) -le 1 ]; then |
62 | 34 | echo "No changes." |
63 | 35 | git checkout -- src/duckdb |
64 | | - rm -rf "$upstream_dir" |
65 | 36 | exit 0 |
66 | 37 | fi |
67 | 38 |
|
68 | 39 | git add . |
69 | 40 |
|
70 | 41 | ( |
71 | | - echo "$message" |
| 42 | + echo "chore: Update vendored sources to duckdb/duckdb@$commit" |
72 | 43 | echo |
73 | | - git -C "$upstream_dir" log --first-parent --format="%s" ${base}..${commit} | tee /dev/stderr | sed -r 's%(#[0-9]+)%duckdb/duckdb\1%g' |
| 44 | + git -C "$duckdir" log --first-parent --format="%s" ${base}..${commit} | sed -r 's%(#[0-9]+)%duckdb/duckdb\1%g' |
74 | 45 | ) | git commit --file /dev/stdin |
75 | | - |
76 | | -rm -rf "$upstream_dir" |
0 commit comments