Added script that converts git submodules to regular git repos.

Last used on /media/bay/taha/projects/ansible/roles/public
with the script located in the root of that directory,
and invoked as:
```
./submodule-to-repo.sh tailscale
```
master
Taha Ahmed 2 years ago
parent 2db7a877c8
commit 2aded2bfc5

@ -449,7 +449,8 @@ runtime=$(( $endtime - $starttime ))
# send push message via Gotify CLI
# if runtime is longer than X minutes (suitable limit perhaps 3 min)
if (( $runtime > 180 )); then
gotify push --quiet --title "$dir_wd" --priority 5 "chertex.sh $@ \nCompleted in $runtime s"
gotify push --quiet --title "$dir_wd" --priority 5 "chertex.sh $@ \nCompleted in $runtime s"
msg "Push notification sent to Gotify"
fi
msg "${On_Cyan}-------------------------------------${NOFORMAT}"

@ -0,0 +1,59 @@
#!/usr/bin/env bash
set -euo pipefail
msg() {
echo >&2 -e "${1-}"
}
die() {
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
simpledelay.sh 2 # short delay to aid reading last message in case terminal closes on exit
exit "$code"
}
parse_params() {
while :; do
case "${1-}" in
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done
args=("$@")
return 0
}
parse_params "$@"
this_submod=${args[0]}
this_subtmp="${args[0]}_tmp"
# https://stackoverflow.com/a/16162228
msg "moving $this_submod to $this_subtmp"
mv $this_submod $this_subtmp
msg "git submodule deinit"
git submodule deinit $this_submod
msg "git rm $this_submod"
git rm $this_submod
msg "moving back $this_submod"
mv $this_subtmp $this_submod
msg "remove the existing .git file"
rm $this_submod/.git
msg "move the .git folder from modules into $this_submod"
mv .git/modules/$this_submod $this_submod/.git
msg "remove the worktree line from .git/config"
sed -i '/worktree/d' $this_submod/.git/config
msg "add $this_submod to .gitignore"
echo "$this_submod" >> .gitignore
Loading…
Cancel
Save