- Added alias functions to all bin scripts using first-letter pattern (e.g., `av` for `activate-venv`, `cwl` for `commit-with-llm`) - Implemented collision resolution by extending aliases with additional letters when conflicts occur or when shadowing standard shell commands - Documented alias implementation approach in library.md with complete alias map for reference - Verified shell syntax with `bash -n` and ensured proper argument passing with `"$@"` - Updated prompt frontmatter to reflect completed state and model used (infomaniak/moonshotai/Kimi-K2.6)
41 lines
1.2 KiB
Bash
Executable File
41 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
checkout-git-folder() {
|
|
if [[ -z "$1" ]]; then
|
|
echo '$1/branch is empty.'
|
|
exit 1
|
|
fi
|
|
if [[ -z "$2" ]]; then
|
|
echo '$2/path is empty.'
|
|
exit 1
|
|
fi
|
|
|
|
local git_branch="$1"
|
|
local base_path="$2"
|
|
local git_folders=$(ls-git-folder "$base_path")
|
|
|
|
for git_folder in $git_folders; do
|
|
git_folder="${git_folder#./}"
|
|
|
|
local commit_ref=$(git config -f .gitmodules --get submodule."$git_folder".commit)
|
|
if [[ -z "$commit_ref" ]]; then
|
|
echo "No commit found in .gitmodules for submodule: $git_folder" >&2
|
|
continue
|
|
fi
|
|
|
|
local shallow=$(git config --file .gitmodules --get submodule."$git_folder".shallow)
|
|
|
|
if [[ "$shallow" = "true" ]]; then
|
|
git -C "$git_folder" stash >/dev/null 2>&1 || true
|
|
git -C "$git_folder" fetch origin "$git_branch:$git_branch" >/dev/null 2>&1
|
|
git -C "$git_folder" checkout "$commit_ref" >/dev/null 2>&1
|
|
else
|
|
git -C "$git_folder" stash >/dev/null 2>&1 || true
|
|
git -C "$git_folder" checkout "$commit_ref" >/dev/null 2>&1
|
|
fi
|
|
done
|
|
}
|
|
cgf() {
|
|
checkout-git-folder "$@"
|
|
}
|