Created
March 16, 2019 11:34
-
-
Save niqdev/14928a372548a47378dc4411dbb15cc5 to your computer and use it in GitHub Desktop.
Update all git and mercurial repositories in a directory
This file contains hidden or 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
#!/bin/bash | |
# unofficial bash strict mode | |
set -euo pipefail | |
IFS=$'\n\t' | |
# run from any directory (no symlink allowed) | |
CURRENT_PATH=$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd -P) | |
cd ${CURRENT_PATH} | |
function update_mercurial { | |
local DIRECTORY=$1 | |
if [ -d ".hg" ]; then | |
echo "[+] update MERCURIAL repository" | |
hg st | |
hg up default | |
hg pull -u | |
fi | |
} | |
function update_git { | |
local DIRECTORY=$1 | |
if [ -d ".git" ]; then | |
echo "[+] update GIT repository" | |
git st | |
git checkout master | |
git pull --rebase | |
fi | |
} | |
function main { | |
for DIRECTORY in $(find . -mindepth 1 -maxdepth 1 -type d); do | |
echo "[*] scan $DIRECTORY" | |
cd $DIRECTORY | |
pwd | |
update_mercurial $DIRECTORY | |
update_git $DIRECTORY | |
cd .. | |
echo -e "[-] done\n" | |
sleep 1s | |
done | |
} | |
main |
Author
niqdev
commented
Apr 30, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment