mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 20:15:07 +00:00
feat(version): show commit hash for nightly installs (#517)
Display commit hash in parentheses after "Nightly" channel label to help users identify exact version when testing nightly builds.
This commit is contained in:
27
install.sh
27
install.sh
@@ -217,6 +217,17 @@ get_source_version() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_source_commit_hash() {
|
||||||
|
# Try to get from local git repo first
|
||||||
|
if [[ -d "$SOURCE_DIR/.git" ]]; then
|
||||||
|
git -C "$SOURCE_DIR" rev-parse --short HEAD 2> /dev/null && return
|
||||||
|
fi
|
||||||
|
# Fallback to GitHub API
|
||||||
|
curl -fsSL --connect-timeout 3 \
|
||||||
|
"https://api.github.com/repos/tw93/mole/commits/main" 2> /dev/null |
|
||||||
|
sed -n 's/.*"sha"[[:space:]]*:[[:space:]]*"\([a-f0-9]\{7\}\).*/\1/p' | head -1
|
||||||
|
}
|
||||||
|
|
||||||
get_latest_release_tag() {
|
get_latest_release_tag() {
|
||||||
local tag
|
local tag
|
||||||
if ! command -v curl > /dev/null 2>&1; then
|
if ! command -v curl > /dev/null 2>&1; then
|
||||||
@@ -288,12 +299,14 @@ resolve_install_channel() {
|
|||||||
|
|
||||||
write_install_channel_metadata() {
|
write_install_channel_metadata() {
|
||||||
local channel="$1"
|
local channel="$1"
|
||||||
|
local commit_hash="${2:-}"
|
||||||
local metadata_file="$CONFIG_DIR/install_channel"
|
local metadata_file="$CONFIG_DIR/install_channel"
|
||||||
|
|
||||||
local tmp_file
|
local tmp_file
|
||||||
tmp_file=$(mktemp "${CONFIG_DIR}/install_channel.XXXXXX") || return 1
|
tmp_file=$(mktemp "${CONFIG_DIR}/install_channel.XXXXXX") || return 1
|
||||||
{
|
{
|
||||||
printf 'CHANNEL=%s\n' "$channel"
|
printf 'CHANNEL=%s\n' "$channel"
|
||||||
|
[[ -n "$commit_hash" ]] && printf 'COMMIT_HASH=%s\n' "$commit_hash"
|
||||||
} > "$tmp_file" || {
|
} > "$tmp_file" || {
|
||||||
rm -f "$tmp_file" 2> /dev/null || true
|
rm -f "$tmp_file" 2> /dev/null || true
|
||||||
return 1
|
return 1
|
||||||
@@ -751,9 +764,12 @@ perform_install() {
|
|||||||
installed_version="$source_version"
|
installed_version="$source_version"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local install_channel
|
local install_channel commit_hash=""
|
||||||
install_channel="$(resolve_install_channel)"
|
install_channel="$(resolve_install_channel)"
|
||||||
if ! write_install_channel_metadata "$install_channel"; then
|
if [[ "$install_channel" == "nightly" ]]; then
|
||||||
|
commit_hash=$(get_source_commit_hash)
|
||||||
|
fi
|
||||||
|
if ! write_install_channel_metadata "$install_channel" "$commit_hash"; then
|
||||||
log_warning "Could not write install channel metadata"
|
log_warning "Could not write install channel metadata"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -840,9 +856,12 @@ perform_update() {
|
|||||||
updated_version="$target_version"
|
updated_version="$target_version"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local install_channel
|
local install_channel commit_hash=""
|
||||||
install_channel="$(resolve_install_channel)"
|
install_channel="$(resolve_install_channel)"
|
||||||
if ! write_install_channel_metadata "$install_channel"; then
|
if [[ "$install_channel" == "nightly" ]]; then
|
||||||
|
commit_hash=$(get_source_commit_hash)
|
||||||
|
fi
|
||||||
|
if ! write_install_channel_metadata "$install_channel" "$commit_hash"; then
|
||||||
log_warning "Could not write install channel metadata"
|
log_warning "Could not write install channel metadata"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
15
mole
15
mole
@@ -99,6 +99,13 @@ get_install_channel() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_install_commit() {
|
||||||
|
local channel_file="$SCRIPT_DIR/install_channel"
|
||||||
|
if [[ -f "$channel_file" ]]; then
|
||||||
|
sed -n 's/^COMMIT_HASH=\(.*\)$/\1/p' "$channel_file" | head -1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Background update notice
|
# Background update notice
|
||||||
check_for_updates() {
|
check_for_updates() {
|
||||||
local msg_cache="$HOME/.cache/mole/update_message"
|
local msg_cache="$HOME/.cache/mole/update_message"
|
||||||
@@ -222,7 +229,13 @@ show_version() {
|
|||||||
|
|
||||||
printf '\nMole version %s\n' "$VERSION"
|
printf '\nMole version %s\n' "$VERSION"
|
||||||
if [[ "$channel" == "nightly" ]]; then
|
if [[ "$channel" == "nightly" ]]; then
|
||||||
printf 'Channel: Nightly\n'
|
local commit
|
||||||
|
commit=$(get_install_commit)
|
||||||
|
if [[ -n "$commit" ]]; then
|
||||||
|
printf 'Channel: Nightly (%s)\n' "$commit"
|
||||||
|
else
|
||||||
|
printf 'Channel: Nightly\n'
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
printf 'macOS: %s\n' "$os_ver"
|
printf 'macOS: %s\n' "$os_ver"
|
||||||
printf 'Architecture: %s\n' "$arch"
|
printf 'Architecture: %s\n' "$arch"
|
||||||
|
|||||||
Reference in New Issue
Block a user