submodules support
This commit is contained in:
15
dot-add
15
dot-add
@@ -45,6 +45,21 @@ add_one() {
|
|||||||
local REL="${FILE#$HOME/}"
|
local REL="${FILE#$HOME/}"
|
||||||
local DEST="$DOTFILES_DIR/$PACKAGE/$REL"
|
local DEST="$DOTFILES_DIR/$PACKAGE/$REL"
|
||||||
|
|
||||||
|
# If the path is a git repo, add it as a submodule instead of moving files
|
||||||
|
if [[ -d "$FILE/.git" ]]; then
|
||||||
|
local REMOTE
|
||||||
|
REMOTE="$(git -C "$FILE" remote get-url origin 2>/dev/null || true)"
|
||||||
|
if [[ -z "$REMOTE" ]]; then
|
||||||
|
echo "Error: '$FILE' is a git repo but has no remote origin — can't add as submodule" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
mkdir -p "$(dirname "$DEST")"
|
||||||
|
rm -rf "$FILE"
|
||||||
|
git -C "$DOTFILES_DIR" submodule add "$REMOTE" "$PACKAGE/$REL"
|
||||||
|
echo "Added submodule: $REMOTE -> $DEST"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p "$(dirname "$DEST")"
|
mkdir -p "$(dirname "$DEST")"
|
||||||
mv "$FILE" "$DEST"
|
mv "$FILE" "$DEST"
|
||||||
echo "Moved: $FILE -> $DEST"
|
echo "Moved: $FILE -> $DEST"
|
||||||
|
|||||||
Reference in New Issue
Block a user