Skip to content

Instantly share code, notes, and snippets.

@Y-Less
Created August 20, 2018 21:03
Show Gist options
  • Save Y-Less/c28aefd63a43689b2768364a03d8a240 to your computer and use it in GitHub Desktop.
Save Y-Less/c28aefd63a43689b2768364a03d8a240 to your computer and use it in GitHub Desktop.
File used to split YSI in to multiple repos with full history. I actually split it up and ran it in 10 parallel versions.
declare -a arr=(
"YSI-Coding/y_functional",
"YSI-Coding/y_hooks",
"YSI-Coding/y_inline",
"YSI-Coding/y_malloc",
"YSI-Coding/y_remote",
"YSI-Coding/y_stringhash",
"YSI-Coding/y_timers",
"YSI-Coding/y_unique",
"YSI-Coding/y_va",
"YSI-Core/y_als",
"YSI-Core/y_cell",
"YSI-Core/y_debug",
"YSI-Core/y_master",
"YSI-Core/y_profiling",
"YSI-Core/y_testing",
"YSI-Core/y_utils",
"YSI-Data/y_bintree",
"YSI-Data/y_bit",
"YSI-Data/y_foreach",
"YSI-Data/y_hashmap",
"YSI-Data/y_iterate",
"YSI-Data/y_jaggedarray",
"YSI-Data/y_playerarray",
"YSI-Data/y_playerset",
"YSI-Data/y_sortedarray",
"YSI-Data/y_sparsearray",
"YSI-Extra/y_extra",
"YSI-Extra/y_files",
"YSI-Extra/y_streamer_plugin",
"YSI-Game/y_vehicledata",
"YSI-Players/y_groups",
"YSI-Players/y_languages",
"YSI-Players/y_text",
"YSI-Players/y_users",
"YSI-Server/y_colors",
"YSI-Server/y_colours",
"YSI-Server/y_flooding",
"YSI-Server/y_lock",
"YSI-Server/y_punycode",
"YSI-Server/y_scriptinit",
"YSI-Server/y_stringise",
"YSI-Server/y_stringize",
"YSI-Server/y_td",
"YSI-Storage/y_amx",
"YSI-Storage/y_bitmap",
"YSI-Storage/y_ini",
"YSI-Storage/y_php",
"YSI-Storage/y_svar",
"YSI-Storage/y_uvar",
"YSI-Storage/y_xml",
"YSI-Visual/y_areas",
"YSI-Visual/y_classes",
"YSI-Visual/y_commands",
"YSI-Visual/y_dialog",
"YSI-Visual/y_loader",
"YSI-Visual/y_properties",
"YSI-Visual/y_races",
"YSI-Visual/y_zonenames",
"YSI-Visual/y_zonepulse"
)
do_rm() {
IFS='.' read -ra p <<< "$3"
if [[ "${p[0]}" == "YSI_$1/$2" ]];
then
IFS='/' read -ra x <<< "$3"
if [[ "${p[1]}" == "md" ]];
then
mv "$3" "YSI-$1/README.md"
else
mv "$3" "YSI-$1/"
fi
#else
# rm -r "$3"
fi
}
do_dir() {
if [[ "$2" == "$3.inc" ]];
then
mv "$3" "YSI-$1/"
elif [[ "YSI-$1" == "$3" ]];
then
:
#echo "NOPE"
#echo "$3"
elif [[ "YSI_$1" == "$3" ]];
then
git ls-tree --name-only HEAD "YSI_$1/" | xargs -I@ bash -c "$(declare -f do_rm) ; do_rm $1 $2 @ ;"
ls "YSI-$1/"
else
rm -r "$3"
fi
}
do_part() {
if [ ! -e YSI-$1 ]; then
mkdir YSI-$1
git ls-tree --name-only HEAD | xargs -I@ bash -c "$(declare -f do_dir) ; do_dir $1 $2 @ ;"
if [ -e YSI_$1 ]; then
rmdir YSI_$1
fi
fi
}
for i in ${arr[@]}
do
IFS='/' read -ra l <<< "$i"
echo "YSI-${l[0]}/${l[1]}"
cp -r "Source" "YSI-${l[0]}@${l[1]}"
cd "YSI-${l[0]}@${l[1]}"
# git filter-branch --prune-empty --tree-filter "bash -c \"$(declare -f do_part) ; do_part ${l[0]} ${l[1]} @ ;\""
git filter-branch --prune-empty --tree-filter "
if [ ! -e YSI-${l[0]} ]; then
mkdir YSI-${l[0]}
fi
git ls-tree --name-only \$GIT_COMMIT | xargs -I files /d/work/dir.sh ${l[0]} ${l[1]} files
if [ -e YSI_${l[0]} ]; then
rmdir YSI_${l[0]}
fi
"
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment