Commit 5151c299 authored by Michael Völske's avatar Michael Völske

check for update on every run

parent a97fc63e
......@@ -7,6 +7,8 @@
# Project general
# Author: Steve Göring
#
webiscmd_libs_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
webiscmdrootpath="$(${webiscmd_libs_dir}/readlink-f.py $webiscmd_libs_dir/../)/"
#
# Logging macros,
......@@ -266,6 +268,17 @@ is_var_set() {
[ ! -z "${!1+x}" ]
}
# Check if the git repository in CWD
# has unpulled commits on any remote
# branch, without actually fetching
# anything.
#
git_repo_has_updates() {
git fetch --dry-run 2>&1 | grep -q '\->'
}
#
# Printout settings and check configuration.
#
......
#!/bin/bash
# Update the webis command from Git
#
# Update Webis command
#
# Copyright 2015-today
#
# Project WEBIS
# Author: Steve Göring
#
# Load libaries and toolkits.
#
scriptPath=${0%/*}
scriptPath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. ${scriptPath}/../../libs/bashhelper.sh
. ${scriptPath}/../../libs/shflags
......@@ -46,19 +39,13 @@ eval set -- "${FLAGS_ARGV}"
#
#
main() {
webiscmdrootpath="$(${scriptPath}/../../libs/readlink-f.py $scriptPath/../../)/"
logInfo "${scriptPath}"
cd "$webiscmdrootpath"
logInfo "Checking for updates... ${webiscmdrootpath}"
LOCAL=$(git rev-parse '@{0}')
REMOTE=$(git ls-remote origin HEAD | cut -f1)
BASE=$(git merge-base '@{0}' '@{u}')
if [ "$LOCAL" = "$REMOTE" ] || [ "$REMOTE" = "$BASE" ]; then
logInfo "No update needed."
else
if git_repo_has_updates; then
logInfo "Updating webis-cmd."
git pull --rebase origin master
else
logInfo "No update needed."
fi
}
......
#!/bin/sh
#!/bin/bash
# -*- coding: utf-8 ; mode: python -*-
"true" '''\'
rootpath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. ${rootpath}/libs/bashhelper.sh
if $(cd "$webiscmdrootpath" ; git_repo_has_updates ); then
logWarn "Your webis-cmd is outdated. Please run 'webis core update'"
fi
# try running as python3, if that fails fall back to (any) python
command -v python3 > /dev/null
if [ $? -eq 0 ]; then
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment