Skip to content

Commit 4a7d874

Browse files
author
Sekiphp
committed
Autoupdater faster
1 parent 8595137 commit 4a7d874

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

autoupdater.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
clear
33

44
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
5-
changed=0
5+
REMOTE_HASH="$( curl -s https://api.github.com/repos/Sekiphp/useful-scripts/commits/master | grep -m1 -o -P '(?<="sha": ")[^"]+' )"
6+
LOCAL_HASH="$( git rev-parse HEAD)"
67

7-
git -C "$DIR" remote update && git -C "$DIR" status -uno | grep -q 'Your branch is behind' && changed=1
8-
if [ $changed = 0 ];
8+
if [ "$REMOTE_HASH" == "$LOCAL_HASH" ];
99
then
1010
echo "Useful-scripts is up to date!"
1111
else
@@ -21,7 +21,7 @@ else
2121

2222
if [[ "$cmd" = "Y" ]];
2323
then
24-
git -C "$DIR" pull
24+
git -C "$DIR" fetch
2525
echo "Updated successfully";
2626
fi
2727
fi

0 commit comments

Comments
 (0)