Skip to content

Commit

Permalink
Status pull (#2)
Browse files Browse the repository at this point in the history
* Add status and pull commands to lila-docker script

* Update lila-docker script to use `./pull-all` instead of `bash pull-all.sh` for the "status" and "pull" commands

* Update README.md

* Update lila-docker

* Update pull-all
  • Loading branch information
Carbrex authored Jun 28, 2024
1 parent 60959ec commit 6239f77
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lila-docker
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ show_help() {
echo " gitpod public Make http port 8080 public on the Gitpod instance"
echo " ui Compile the frontend code. Runs in watch mode to automatically recompile on changes"
echo " add-services Add new services to the existing setup"
echo " status Show the status of all git repositories in ./repos"
echo " pull Pull the latest changes from all git repositories in ./repos"
echo " fast-setup Setup opinionated services without any prompts"
}

Expand Down Expand Up @@ -280,6 +282,12 @@ case "$@" in
"add-services")
add_services
;;
"status")
./pull-all
;;
"pull")
./pull-all --pull
;;
"fast-setup")
fast_setup
;;
Expand All @@ -290,4 +298,4 @@ case "$@" in
show_help
exit 1
;;
esac
esac
59 changes: 59 additions & 0 deletions pull-all
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash -e

cd "$(dirname "$0")"
initial_dir=$(pwd)

# Check if --pull flag is passed
pull_flag=false
if [[ $1 == "--pull" ]]; then
pull_flag=true
fi

for dir in ./repos/*; do
# echo "Checking $dir"
if [[ -d "$dir" ]]; then
cd "$dir"
# check if the directory is a git repo
if [[ ! -d ".git" ]]; then
echo "Directory $dir is not a git repo."
cd "$initial_dir"
continue
fi
# check if the git repo is dirty
if [[ $(git diff --stat) != '' ]]; then
echo "Repo $dir is dirty."
cd "$initial_dir"
continue
fi
# check if repo has a main branch or master branch
main_or_master=""
if [[ $(git branch --list main) ]]; then
main_or_master="main"
elif [[ $(git branch --list master) ]]; then
main_or_master="master"
else
echo "Repo $dir does not have a main or master branch."
cd "$initial_dir"
continue
fi
# if repo is not on main or master branch, don't do anything
if [[ $(git branch --show-current) != "$main_or_master" ]]; then
echo "Repo $dir is not on $main_or_master branch."
cd "$initial_dir"
continue
fi
# check if repo is up to date
if [[ $(git rev-list HEAD...upstream/$main_or_master --count) -eq 0 ]]; then
echo "Repo $dir is up to date."
cd "$initial_dir"
continue
fi

echo "The repo $dir is behind the remote. Pulling changes."
if [[ $pull_flag == true ]]; then
git pull
fi
cd "$initial_dir"
pwd
fi
done

0 comments on commit 6239f77

Please sign in to comment.