Files
git.taskfile.build/bin/add-git-folder
T

30 lines
659 B
Bash
Executable File

#!/bin/bash
add-git-folder() {
if [[ -z "$1" ]]; then
echo '$1/branch is empty.'
exit
fi
if [[ -z "$2" ]]; then
echo '$2/url is empty.'
exit
fi
if [[ -z "$3" ]]; then
echo '$3/path is empty.'
exit
fi
local branch="$1"
local url="$2"
local path="$3"
# Clone the repo
git clone -b "$branch" "$url" "$path"
# Add entry to .gitmodules
git config -f .gitmodules submodule."$path".path "$path"
git config -f .gitmodules submodule."$path".url "$url"
git config -f .gitmodules submodule."$path".branch "$branch"
# Save commit ref
save-git-folder
}