mirror of https://github.com/octoleo/hosts.git
Just use `diff` in `backups compare`.
This commit is contained in:
parent
7fc3b994b4
commit
fb67d7b510
19
hosts
19
hosts
|
@ -749,14 +749,15 @@ Subcommands:
|
||||||
backups List available backups.
|
backups List available backups.
|
||||||
backups create Create a new backup of the hosts file.
|
backups create Create a new backup of the hosts file.
|
||||||
backups compare Compare a backup file with the current hosts file.
|
backups compare Compare a backup file with the current hosts file.
|
||||||
The diff tool configured for git will be used if
|
|
||||||
one is set.
|
|
||||||
backups delete Delete the specified backup.
|
backups delete Delete the specified backup.
|
||||||
backups restore Replace the contents of the hosts file with a
|
backups restore Replace the contents of the hosts file with a
|
||||||
specified backup. The hosts file is automatically
|
specified backup. The hosts file is automatically
|
||||||
backed up before being overwritten unless the
|
backed up before being overwritten unless the
|
||||||
'--skip-backup' flag is specified.
|
'--skip-backup' flag is specified.
|
||||||
backups show Show the contents of the specified backup file.
|
backups show Show the contents of the specified backup file.
|
||||||
|
|
||||||
|
Description:
|
||||||
|
Manage backups.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
backups() {
|
backups() {
|
||||||
local _subcommand="${1:-}"
|
local _subcommand="${1:-}"
|
||||||
|
@ -804,19 +805,7 @@ backups() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local _difftool="diff"
|
diff -u "${HOSTS_PATH}" "${_hosts_dirname}/${_filename}"
|
||||||
|
|
||||||
if ! ((_use_diff))
|
|
||||||
then
|
|
||||||
if command -v git &>/dev/null
|
|
||||||
then
|
|
||||||
local _git_merge_tool
|
|
||||||
_git_merge_tool="$(git config --get merge.tool)"
|
|
||||||
[[ -n "${_git_merge_tool}" ]] && _difftool="${_git_merge_tool}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
"${_difftool}" "${HOSTS_PATH}" "${_hosts_dirname}/${_filename}"
|
|
||||||
;;
|
;;
|
||||||
delete)
|
delete)
|
||||||
if [[ -z "${1:-}" ]]
|
if [[ -z "${1:-}" ]]
|
||||||
|
|
|
@ -87,7 +87,7 @@ No backups found. Create a new backup:
|
||||||
printf "\${output}: '%s'\\n" "${output}"
|
printf "\${output}: '%s'\\n" "${output}"
|
||||||
printf "\${lines[1]}: '%s'\\n" "${lines[1]}"
|
printf "\${lines[1]}: '%s'\\n" "${lines[1]}"
|
||||||
[[ ${status} -eq 1 ]]
|
[[ ${status} -eq 1 ]]
|
||||||
[[ "${lines[1]}" =~ \<\ 0.0.0.0[[:space:]]+example.com ]]
|
[[ "${lines[2]}" == '@@ -8,4 +8,3 @@' ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "\`backups compare\` with missing backup exits with status 1" {
|
@test "\`backups compare\` with missing backup exits with status 1" {
|
||||||
|
|
Loading…
Reference in New Issue