feat(git): add comprehensive git folder management commands and update documentation

This commit is contained in:
Janik von Rotz committed 2026-03-04 09:36:40 +01:00
1 parent 793b608732
commit 84f7ebfccb
15 files changed
+342 -10

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
list-git-folder() {
if [[ -z "$1" ]]; then
echo '$1/path is empty.'
exit
fi
# Define column widths
local path_width=35
local url_width=50
local branch_width=8
# Print table header
printf "| %-${path_width}s | %-${url_width}s | %-${branch_width}s |\n" "PATH" "URL" "BRANCH"
echo "|$(printf '%*s' $((path_width + 2)) '' | tr ' ' '-')|$(printf '%*s' $((url_width + 2)) '' | tr ' ' '-')|$(printf '%*s' $((branch_width + 2)) '' | tr ' ' '-')|"
local git_folders=$(ls-git-folder "$1")
for git_folder in $git_folders; do
local url=$(git config --file .gitmodules --get "submodule.$git_folder.url")
url=${url#git@github.com:}
url=${url%.git}
local branch=$(git -C "$git_folder" branch --show-current 2>/dev/null || echo "detached")
printf "| %-${path_width}s | %-${url_width}s | %-${branch_width}s |\n" "$git_folder" "$url" "${branch:-detached}"
done
}