-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck
executable file
·50 lines (40 loc) · 868 Bytes
/
check
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
if [[ $# -lt 1 ]]
then
echo "Usage: ./check [github username]"
exit 1
fi
user=$1
repos=$(gh repo list --json name $user -L 999 | grep -o -E ":\"([a-zA-Z0-9\._-])+\"" | cut -c3- | sed 's/.$//') # Do weird linux magic to parse JSON
repocount=$(gh repo list $user -L 999 | wc -l)
count=$(./count $user -c)
if [[ $? -ne 0 ]]
then
echo $count
exit 1
fi
if [[ $repocount -ne $count ]]
then
echo "$user/ only has $count repositories out of $repocount synced."
echo "Here are the missing repositories to be synced:"
missingRepos=()
for repo in $repos
do
if ! [[ -d $user/$repo ]]
then
echo -e "*\t$repo"
missingRepos+=( $repo )
fi
done
echo ""
echo "Cloning them all..."
for repo in ${missingRepos[@]}
do
./clone $user $repo
done
else
echo "Everything is fully synced!"
fi
echo ""
echo "Updating everything..."
./pull $user