From 8da4d3c9184d5a74ee0967e3ab22f71f6d887d91 Mon Sep 17 00:00:00 2001 From: Georg Wagner Date: Fri, 3 Sep 2021 18:51:23 +0200 Subject: [PATCH] create "-git" package version log after build & update avoid creating a log after the second run only and do it directly after build or update of a git package, this allows immediate updates if autogit hasn't been run since the last git commit. --- autogit | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/autogit b/autogit index 08c6d15..f30aa95 100644 --- a/autogit +++ b/autogit @@ -205,6 +205,27 @@ function maincheck() { fi fi fi + # Check if it's a Git Package to create a log for updating + cd "$DIR/packages/$GITDIR/$p" + gitfile=.gitcheck + gitcheck="$(echo "$p" | tee "$gitfile")" + if [[ -n "$gitcheck" ]]; then + if grep -E *'-git' "$gitfile" &>/dev/null; then # If result matches (Name has a -git string) + gitpkgname="$(cat PKGBUILD | grep 'source=' | awk -F"/" '{print $NF}' | cut -f1 -d".")" + cd "$gitpkgname" + + # Create a gitlog to check for updates + gitversionfile=.gitversioncheck + gitversioncheck="$(git show | head -1 | tee "$gitversionfile")" + # Generate a gitcheck file for a update reference + if [[ -n "$gitversioncheck" ]]; then + cd .. + rm -rf "$gitfile" &>/dev/null + echo -e "\e[2m[Git-Version Updated]\e[0m" + return 1 + fi + fi + fi else echo "Package does not exist local, downloading ..." mkdir -p "$DIR/packages/$GITDIR/$p" && cd "$DIR/packages/$GITDIR/$p" @@ -275,6 +296,27 @@ function maincheck() { fi fi fi + # Check if it's a Git Package to create a log for updating + cd "$DIR/packages/$GITDIR/$p" + gitfile=.gitcheck + gitcheck="$(echo "$p" | tee "$gitfile")" + if [[ -n "$gitcheck" ]]; then + if grep -E *'-git' "$gitfile" &>/dev/null; then # If result matches (Name has a -git string) + gitpkgname="$(cat PKGBUILD | grep 'source=' | awk -F"/" '{print $NF}' | cut -f1 -d".")" + cd "$gitpkgname" + + # Create a gitlog to check for updates + gitversionfile=.gitversioncheck + gitversioncheck="$(git show | head -1 | tee "$gitversionfile")" + # Generate a gitcheck file for a update reference + if [[ -n "$gitversioncheck" ]]; then + cd .. + rm -rf "$gitfile" &>/dev/null + echo -e "\e[2m[Git-Version]\e[0m" + return 1 + fi + fi + fi fi } #