add --git sync option
This commit is contained in:
16
MANUAL
16
MANUAL
@@ -29,6 +29,12 @@ OPTIONS
|
|||||||
Setup mode for SFTP workflow. Creates helper scripts but skips
|
Setup mode for SFTP workflow. Creates helper scripts but skips
|
||||||
lazygit upload and .gitignore modifications.
|
lazygit upload and .gitignore modifications.
|
||||||
|
|
||||||
|
--git
|
||||||
|
Git clone mode. Clones the repository from the remote server using
|
||||||
|
SSH with password authentication. Uploads lazygit to the server and
|
||||||
|
marks it as assume-unchanged (both locally and on server). Only
|
||||||
|
generates ssh.sh helper script.
|
||||||
|
|
||||||
MODES
|
MODES
|
||||||
Default mode:
|
Default mode:
|
||||||
- Syncs terminal info (xterm-ghostty or xterm-kitty)
|
- Syncs terminal info (xterm-ghostty or xterm-kitty)
|
||||||
@@ -49,6 +55,13 @@ MODES
|
|||||||
- No helper scripts
|
- No helper scripts
|
||||||
- No configuration files
|
- No configuration files
|
||||||
|
|
||||||
|
--git mode:
|
||||||
|
- Clones git repository via SSH with password
|
||||||
|
- Uploads lazygit to server
|
||||||
|
- Marks lazygit as assume-unchanged (server + local)
|
||||||
|
- Generates: ssh.sh only
|
||||||
|
- No tar archive, no sftp.json, no other scripts
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
Full setup with all scripts:
|
Full setup with all scripts:
|
||||||
./sync-project.sh
|
./sync-project.sh
|
||||||
@@ -59,6 +72,9 @@ EXAMPLES
|
|||||||
SFTP workflow without git tools:
|
SFTP workflow without git tools:
|
||||||
./sync-project.sh --sftp-only
|
./sync-project.sh --sftp-only
|
||||||
|
|
||||||
|
Clone git repository from server:
|
||||||
|
./sync-project.sh --git
|
||||||
|
|
||||||
GENERATED SCRIPTS
|
GENERATED SCRIPTS
|
||||||
remote-local.sh Pull files from server
|
remote-local.sh Pull files from server
|
||||||
local-remote.sh Push files to server
|
local-remote.sh Push files to server
|
||||||
|
|||||||
@@ -24,8 +24,10 @@ elif [ "$1" = "--git" ]; then
|
|||||||
ssh -t $SERVER_USER@$SERVER_HOST \
|
ssh -t $SERVER_USER@$SERVER_HOST \
|
||||||
"cd $SERVER_PATH && ./lazygit"
|
"cd $SERVER_PATH && ./lazygit"
|
||||||
|
|
||||||
# After that sync remote with --delete flag
|
# After that sync remote with --delete flag (if script exists)
|
||||||
bash remote-local.sh --delete
|
if [ -f "remote-local.sh" ]; then
|
||||||
|
bash remote-local.sh --delete
|
||||||
|
fi
|
||||||
elif [ "$1" = "--todo" ]; then
|
elif [ "$1" = "--todo" ]; then
|
||||||
todoSearch
|
todoSearch
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ SSH_OPTS="-o StrictHostKeyChecking=accept-new"
|
|||||||
# Parse command line arguments
|
# Parse command line arguments
|
||||||
SFTP_ONLY=false
|
SFTP_ONLY=false
|
||||||
FILES_ONLY=false
|
FILES_ONLY=false
|
||||||
|
GIT_ONLY=false
|
||||||
|
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
@@ -36,6 +37,10 @@ for arg in "$@"; do
|
|||||||
FILES_ONLY=true
|
FILES_ONLY=true
|
||||||
echo -e "${YELLOW}Files only mode enabled${NC}"
|
echo -e "${YELLOW}Files only mode enabled${NC}"
|
||||||
;;
|
;;
|
||||||
|
--git)
|
||||||
|
GIT_ONLY=true
|
||||||
|
echo -e "${YELLOW}Git clone mode enabled${NC}"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -99,6 +104,69 @@ if [ -z "$LOCAL_FOLDER" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Git clone mode - clone repository and setup lazygit
|
||||||
|
if [ "$GIT_ONLY" = true ]; then
|
||||||
|
echo "Cloning repository..."
|
||||||
|
GIT_SSH_COMMAND="sshpass -p '${SSH_PASSWORD}' ssh $SSH_OPTS" \
|
||||||
|
git clone ${SERVER_HOST}:${SERVER_PROJECT_PATH} "${LOCAL_FOLDER}"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo -e "${RED}Failed to clone repository${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${GREEN}Repository cloned successfully${NC}"
|
||||||
|
|
||||||
|
# Extract username and host from SERVER_HOST
|
||||||
|
USERNAME="${SERVER_HOST%@*}"
|
||||||
|
HOST="${SERVER_HOST#*@}"
|
||||||
|
|
||||||
|
cd "${LOCAL_FOLDER}"
|
||||||
|
|
||||||
|
# Upload lazygit to server
|
||||||
|
echo "Uploading lazygit to server..."
|
||||||
|
sshpass -p "${SSH_PASSWORD}" scp $SSH_OPTS "${SCRIPT_DIR}/lazygit" ${SERVER_HOST}:${SERVER_PROJECT_PATH}
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo -e "${RED}Failed to upload lazygit${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${GREEN}lazygit uploaded successfully${NC}"
|
||||||
|
|
||||||
|
# Mark lazygit as assume-unchanged on server
|
||||||
|
echo "Marking lazygit as assume-unchanged on server..."
|
||||||
|
sshpass -p "${SSH_PASSWORD}" ssh $SSH_OPTS ${SERVER_HOST} \
|
||||||
|
"cd ${SERVER_PROJECT_PATH} && git update-index --assume-unchanged lazygit"
|
||||||
|
|
||||||
|
# Pull to get lazygit locally, then mark as assume-unchanged
|
||||||
|
echo "Syncing and marking lazygit as assume-unchanged locally..."
|
||||||
|
GIT_SSH_COMMAND="sshpass -p '${SSH_PASSWORD}' ssh $SSH_OPTS" git pull
|
||||||
|
git update-index --assume-unchanged lazygit
|
||||||
|
|
||||||
|
echo -e "${GREEN}lazygit configured successfully${NC}"
|
||||||
|
|
||||||
|
# Generate ssh.sh script
|
||||||
|
echo "
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
SERVER_USER=\"${USERNAME}\"
|
||||||
|
SERVER_HOST=\"${HOST}\"
|
||||||
|
SERVER_PASSWORD=\"${SSH_PASSWORD}\"
|
||||||
|
SERVER_PATH=\"${SERVER_PROJECT_PATH}/\"
|
||||||
|
REMOTE_PROGRESS=\".remote-in-progress\"
|
||||||
|
" > "ssh.sh"
|
||||||
|
|
||||||
|
# Append the ssh.sh template
|
||||||
|
cat "${SCRIPT_DIR}/scripts/ssh.sh" >> "ssh.sh"
|
||||||
|
echo -e "${GREEN}ssh.sh created successfully${NC}"
|
||||||
|
|
||||||
|
echo -e "${GREEN}Git clone complete!${NC}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Sync terminal info on full sync (no flags)
|
# Sync terminal info on full sync (no flags)
|
||||||
if [ "$SFTP_ONLY" = false ] && [ "$FILES_ONLY" = false ]; then
|
if [ "$SFTP_ONLY" = false ] && [ "$FILES_ONLY" = false ]; then
|
||||||
# Detect terminal type
|
# Detect terminal type
|
||||||
|
|||||||
Reference in New Issue
Block a user