The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
#!/usr/bin/env bash
#
# Resolve and stage conflicts in either ratchet file.
# This script only reads index stages; Mage validates and merges the maps.
set -euo pipefail
# Find mage through this script's path: the cd below can land in a different repository.
bin_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
cd -- "$(git rev-parse --show-toplevel)"
ratchet_files=(
.clj-kondo/ratchets.edn
.clj-kondo/ratchets-test.edn
.clj-kondo/config/modules/ratchets.edn
)
conflicted_files=()
# One "<mode> <sha> <stage>\t<path>" line per unmerged stage: 1 = base, 2 = ours, 3 = theirs.
for ratchets_file in "${ratchet_files[@]}"; do
stages=$(git ls-files -u -- "$ratchets_file" | awk '{ print $3 }')
if [ -n "$stages" ]; then
conflicted_files+=("$ratchets_file")
if ! grep -qx -- 2 <<< "$stages" || ! grep -qx -- 3 <<< "$stages"; then
echo "$ratchets_file was deleted on one side and changed on the other; resolve it by hand" >&2
exit 1
fi
fi
done
if [ "${#conflicted_files[@]}" -eq 0 ]; then
echo "no ratchet file is conflicted" >&2
exit 1
fi
tmp_dir=$(mktemp -d)
trap 'rm -rf -- "$tmp_dir"' EXIT
for i in "${!conflicted_files[@]}"; do
ratchets_file=${conflicted_files[$i]}
stages=$(git ls-files -u -- "$ratchets_file" | awk '{ print $3 }')
git show ":2:$ratchets_file" > "$tmp_dir/ours-$i"
git show ":3:$ratchets_file" > "$tmp_dir/theirs-$i"
if grep -qx -- 1 <<< "$stages"; then
git show ":1:$ratchets_file" > "$tmp_dir/base-$i"
else
# Both sides added the file, so every policy is a one-sided change against an empty base.
printf '{}\n' > "$tmp_dir/base-$i"
fi
case $ratchets_file in
.clj-kondo/config/modules/ratchets.edn) kind=modules ;;
.clj-kondo/ratchets-test.edn) kind=test ;;
*) kind=kondo ;;
esac
"$bin_dir/mage" -ratchets-merge "$kind" \
"$tmp_dir/base-$i" \
"$tmp_dir/ours-$i" \
"$tmp_dir/theirs-$i" \
"$PWD/$ratchets_file"
done
git add -- "${conflicted_files[@]}"
printf 'staged merged %s\n' "${conflicted_files[@]}"