Fix git pull and remote hash retrieval in watch script
This commit is contained in:
7
watch.sh
7
watch.sh
@@ -1,5 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Configuration
|
||||
BRANCH="main" # Set your branch name here
|
||||
|
||||
# Function to get the current git commit hash
|
||||
get_git_hash() {
|
||||
git rev-parse HEAD 2>/dev/null
|
||||
@@ -7,7 +10,7 @@ get_git_hash() {
|
||||
|
||||
# Function to start the application
|
||||
start_app() {
|
||||
git pull
|
||||
git pull origin $BRANCH 2>/dev/null || true
|
||||
source bin/activate
|
||||
pip install -r requirements.txt
|
||||
python init.py &
|
||||
@@ -47,7 +50,7 @@ while true; do
|
||||
git fetch origin 2>/dev/null
|
||||
|
||||
# Get the remote hash
|
||||
REMOTE_HASH=$(git rev-parse origin/$(git rev-parse --abbrev-ref HEAD) 2>/dev/null)
|
||||
REMOTE_HASH=$(git rev-parse origin/$BRANCH 2>/dev/null)
|
||||
|
||||
if [ "$CURRENT_HASH" != "$REMOTE_HASH" ]; then
|
||||
echo "Git changes detected! Restarting..."
|
||||
|
||||
Reference in New Issue
Block a user