Merge pull request #2640 from pi-hole/new/DebugAdditions

Add git status/diff to debug log
This commit is contained in:
Mark Drobnak 2019-02-18 19:28:21 -05:00 committed by GitHub
commit 58f198626a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -269,6 +269,9 @@ compare_local_version_to_git_version() {
# The commit they are on
local remote_commit
remote_commit=$(git describe --long --dirty --tags --always)
# Status of the repo
local local_status
local_status=$(git status -s)
# echo this information out to the user in a nice format
# If the current version matches what pihole -v produces, the user is up-to-date
if [[ "${remote_version}" == "$(pihole -v | awk '/${search_term}/ {print $6}' | cut -d ')' -f1)" ]]; then
@ -291,6 +294,16 @@ compare_local_version_to_git_version() {
fi
# echo the current commit
log_write "${INFO} Commit: ${remote_commit}"
# if `local_status` is non-null, then the repo is not clean, display details here
if [[ ${local_status} ]]; then
#Replace new lines in the status with 12 spaces to make the output cleaner
log_write "${INFO} Status: ${local_status//$'\n'/'\n '}"
local local_diff
local_diff=$(git diff)
if [[ ${local_diff} ]]; then
log_write "${INFO} Diff: ${local_diff//$'\n'/'\n '}"
fi
fi
# If git status failed,
else
# Return an error message