Be more verbose with debug script output

If output of `git status -s` is non-null display changes
if output of `git diff` is non-null, display diff

Signed-off-by: Adam Warner <adamw@rner.email>
This commit is contained in:
Adam Warner 2019-02-18 22:32:53 +00:00
parent 9748f19172
commit a145f1d931
No known key found for this signature in database
GPG key ID: F5410858022DA5EB

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