refactor: move the sources to mobi/giza, paths only (fork, Phase 3a)
docs/scripts/giza-rename.sh --moves-only: com/machankura/bennu becomes mobi/giza in all six source sets, the nine files named Bennu* are named Giza*, and the Room schema directory moves to mobi.giza.compose.database.GizaDatabase. Every source file is a 100% rename, so log --follow and blame go straight through. This commit does not compile on purpose: the next one rewrites the contents. The script, which does both, comes with it so a merge from Bennu can re-run it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
78d913aaf2
commit
30d5feaf87
921 files changed
+111
No files matched your search
Executable
+111
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# The mechanical part of the Giza fork: docs/giza-rebrand.md, Phase 3.
|
||||
#
|
||||
# docs/scripts/giza-rename.sh moves, then rewrites
|
||||
# docs/scripts/giza-rename.sh --moves-only moves only (commit 3a)
|
||||
#
|
||||
# Moves com/machankura/bennu to mobi/giza in every source set, renames the files and the
|
||||
# Room schema directory that carry the name, and rewrites packages, imports, the Res package
|
||||
# and the thirteen Bennu identifiers to match.
|
||||
#
|
||||
# Idempotent: on a tree that is already renamed it finds nothing and changes nothing. That
|
||||
# is the point of it being a script. A merge from Bennu (Phase 9) brings files Bennu added
|
||||
# after the fork in under com/machankura/bennu and in Bennu's names; re-running this over
|
||||
# the merge moves and rewrites them the way the fork itself was.
|
||||
#
|
||||
# What it never touches: user-facing strings (Phase 4 words those by hand), anything under
|
||||
# lightning-kmp-app/, the mantra/ derivation tags, fr.acinq.*, and this file and the plan,
|
||||
# which name the old spellings on purpose.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/../.." || exit 1
|
||||
|
||||
MOVES_ONLY=0
|
||||
[[ "${1:-}" == "--moves-only" ]] && MOVES_ONLY=1
|
||||
|
||||
SOURCE_SETS=(androidMain commonMain commonTest iosMain jvmMain jvmTest)
|
||||
OLD_SCHEMAS=composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase
|
||||
NEW_SCHEMAS=composeApp/schemas/mobi.giza.compose.database.GizaDatabase
|
||||
|
||||
conflicts=0
|
||||
|
||||
# Moves one file, with git when git knows it. Refuses to overwrite: a file at both paths
|
||||
# after a merge is two versions of one file, and which one wins is a person's decision.
|
||||
move_file() {
|
||||
local from=$1 to=$2
|
||||
if [[ -e "$to" ]]; then
|
||||
echo "giza-rename: both $from and $to exist; resolve by hand" >&2
|
||||
conflicts=$((conflicts + 1))
|
||||
return
|
||||
fi
|
||||
mkdir -p "$(dirname "$to")"
|
||||
if git ls-files --error-unmatch "$from" >/dev/null 2>&1; then
|
||||
git mv "$from" "$to"
|
||||
else
|
||||
mv "$from" "$to"
|
||||
fi
|
||||
}
|
||||
|
||||
# Moves a whole tree: in one git mv when nothing is there yet, which is the fork itself,
|
||||
# and file by file when something is, which is a merge.
|
||||
move_tree() {
|
||||
local from=$1 to=$2
|
||||
[[ -d "$from" ]] || return 0
|
||||
if [[ ! -e "$to" ]]; then
|
||||
mkdir -p "$(dirname "$to")"
|
||||
git mv "$from" "$to"
|
||||
else
|
||||
while IFS= read -r -d '' file; do
|
||||
move_file "$file" "$to/${file#"$from"/}"
|
||||
done < <(find "$from" -type f -print0)
|
||||
fi
|
||||
find "$from" -depth -type d -empty -delete 2>/dev/null || true
|
||||
}
|
||||
|
||||
for set in "${SOURCE_SETS[@]}"; do
|
||||
root=composeApp/src/$set/kotlin
|
||||
move_tree "$root/com/machankura/bennu" "$root/mobi/giza"
|
||||
# com/machankura and com, if nothing else lives there now.
|
||||
rmdir "$root/com/machankura" "$root/com" 2>/dev/null || true
|
||||
done
|
||||
|
||||
# Files whose names carry the brand: BennuDatabase.kt, BennuApp.kt and the rest.
|
||||
while IFS= read -r -d '' file; do
|
||||
base=$(basename "$file")
|
||||
move_file "$file" "$(dirname "$file")/${base//Bennu/Giza}"
|
||||
done < <(find composeApp/src -type f -name '*Bennu*' -print0)
|
||||
|
||||
# Room names the schema directory after the database class's fully qualified name, so it
|
||||
# moves with the package and the class together.
|
||||
move_tree "$OLD_SCHEMAS" "$NEW_SCHEMAS"
|
||||
|
||||
if (( MOVES_ONLY )); then
|
||||
(( conflicts == 0 )) || exit 1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Every text file git knows that still names the old packages, Res or identifiers, but for
|
||||
# the two files that name them on purpose.
|
||||
mapfile -t files < <(
|
||||
git grep -lIE 'com[./]machankura[./]bennu|bennu\.composeapp\.generated\.resources|Bennu(Database|Global|Application|App|Converters|NavHost|NavigationSuite|Theme|Shapes)|bennuGlobal|NotYetOnBennu|defaultBennuDir' \
|
||||
-- . ':!lightning-kmp-app' ':!docs/giza-rebrand.md' ':!docs/scripts/giza-rename.sh' || true
|
||||
)
|
||||
|
||||
if (( ${#files[@]} > 0 )); then
|
||||
# The order matters only where one pattern's output could match another's input, and
|
||||
# none does: each replacement spells Giza, and every pattern looks for Bennu.
|
||||
sed -i -E \
|
||||
-e 's#com\.machankura\.bennu\.#mobi.giza.#g' \
|
||||
-e 's#com/machankura/bennu/#mobi/giza/#g' \
|
||||
-e 's#bennu\.composeapp\.generated\.resources#mobi.giza.compose.resources#g' \
|
||||
-e 's#\bBennu(Database|DatabaseConstructor|DatabaseJvmTest|Global|Application|App|Converters|NavHost|NavigationSuite|Theme|Shapes)\b#Giza\1#g' \
|
||||
-e 's#\bbennuGlobal\b#gizaGlobal#g' \
|
||||
-e 's#\bNotYetOnBennu\b#NotYetOnGiza#g' \
|
||||
-e 's#\bdefaultBennuDir\b#defaultGizaDir#g' \
|
||||
"${files[@]}"
|
||||
echo "giza-rename: rewrote ${#files[@]} files"
|
||||
fi
|
||||
|
||||
(( conflicts == 0 )) || exit 1
|
||||
Reference in new issue
Block a user