Commit 0b0af4df authored by Marc Cornellà's avatar Marc Cornellà

fix(updater): fix check for latest commit in local repository

The previous check simply compared whether the last commit of the branch
was the same in the local and the remote repository.

This commit also checks whether the remote commit is an ancestor of the
local commit. This fixes the case where the local repository has new
commits after the last published commit.
parent ff298365
...@@ -75,8 +75,17 @@ function is_update_available() { ...@@ -75,8 +75,17 @@ function is_update_available() {
fi fi
) || return 1 ) || return 1
# Compare local and remote HEADs # Compare local and remote HEADs (if they're equal there are no updates)
[[ "$local_head" != "$remote_head" ]] [[ "$local_head" != "$remote_head" ]] || return 1
# If local and remote HEADs don't match, check if there's a common ancestor
# If the merge-base call fails, $remote_head might not be downloaded so assume there are updates
local base
base=$(cd -q "$ZSH"; git merge-base $local_head $remote_head 2>/dev/null) || return 0
# If the common ancestor ($base) is not $remote_head,
# the local HEAD is older than the remote HEAD
[[ $base != $remote_head ]]
} }
function update_last_updated_file() { function update_last_updated_file() {
......
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