forked from lichess-org/lila-docker
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |