-
Notifications
You must be signed in to change notification settings - Fork 0
/
execute
executable file
·35 lines (24 loc) · 857 Bytes
/
execute
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
USAGE="Executes given command in all repos. Meta variable REPO can be used for repository name.\n"
USAGE+="Usage: albert $(basename "$0") \"bash code\"\n"
USAGE+="Example: albert $(basename "$0") \"echo REPO > repo-name.txt\""
([[ "$1" == "help" ]] || [[ "$2" == "help" ]] ) && { echo -e "$USAGE"; exit 0; }
[[ $# != 2 ]] && { echo -e "$USAGE"; exit 1; } # Show usage when argument count is wrong
MY_DIR="$(dirname "$0")"
source "$MY_DIR/util"
source "$MY_DIR/custom-bash-functions"
check_access_token
COMMAND="$2"
REPO_NAMES=$(get_repos)
for REPO in $REPO_NAMES; do
echo "$(tput bold)=====$REPO=====$(tput sgr0)"
cd "$ROOT_DIR" || root_dir_not_found
cd "$ROOT_DIR/$REPO"
if [ $? -ne 0 ]; then
git clone git@github.com:AutoScout24/$REPO.git
cd "$REPO"
fi
eval "${COMMAND//REPO/$REPO}"
cd "$ROOT_DIR"
continue
done;