Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] update & autoupdate #61

Merged
merged 3 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions scripts/core/src/git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,31 @@ git::current_commit_hash() {
git rev-parse HEAD "$@"
}

git::is_valid_commit() {
local -r commit="${1:-HEAD}"
git::is_in_repo && [[ $(git cat-file -t "$commit") == commit ]]
}

# shellcheck disable=SC2120
git::get_commit_tag() {
local commit
if git::is_in_repo; then
commit="${1:-}"
{ [[ -n "$commit" ]] && shift; } || commit="$(git::current_commit_hash)"
local -r commit="${1:-HEAD}"

git show-ref --tags "$@" | grep "$commit" | awk '{print $2}' | sed 's#refs/tags/##'
fi
git::is_in_repo && git::is_valid_commit "$commit" && git tag --points-at "$commit"
}

git::get_current_latest_tag() {
git::get_all_local_tags | head -n1
local version latest

for version in $(git::get_all_local_tags); do
if
[[ -z "${latest:-}" ]] ||
[[ $(platform::semver_compare "$latest" "$version" 2> /dev/null) -eq -1 ]]
then
latest="$version"
fi
done

echo "$latest"
}

# shellcheck disable=SC2120
Expand Down
2 changes: 0 additions & 2 deletions scripts/core/src/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ update::check_if_is_stable_update() {
# shellcheck disable=SC2120
update::update_sloth_repository() {
local current_directory current_branch update_submodules return_code
set +e

# Defaults values that are needed here
current_directory="$(pwd)"
Expand Down Expand Up @@ -120,7 +119,6 @@ update::check_consistency_with_sloth_version() {

update::update_local_sloth_module() {
local current_sloth_hash local_sloth_version remote_sloth_minor remote_sloth_tag
set +e # Avoid crash if any function fail

current_sloth_hash="$(git::get_local_HEAD_hash)"
local_sloth_version="$(git::sloth_repository_exec git::get_commit_tag)"
Expand Down