Skip to content

Commit a7db67a

Browse files
kRHYME7rubiin
authored andcommitted
feat: Add 'hyde-shell version' to get local version
fix feat: hyde-shell --version should return HyDE's current install.sh -r #916 Closes #916
1 parent e93a8ea commit a7db67a

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed

Configs/.local/bin/hyde-shell

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,52 @@ list_script() {
144144
find "$LIB_DIR/hyde" -type f \( -name "*.sh" -o -name "*.py" \) -exec basename {} \;
145145
}
146146

147+
get_version() {
148+
# shellcheck source=/dev/null
149+
if [[ ! -f "${XDG_STATE_HOME:-$HOME/.local/state}/hyde/version" ]]; then
150+
echo "HyDE version file not found. Please update HyDE."
151+
exit 1
152+
fi
153+
source "${XDG_STATE_HOME:-$HOME/.local/state}/hyde/version"
154+
# Extract only the date part from HYDE_VERSION using Bash parameter expansion
155+
# HYDE_VERSION_DATE="${HYDE_VERSION%%-*}"
156+
cat <<VERSION
157+
HyDE, your Development Environment
158+
159+
Version: $HYDE_VERSION
160+
Branch: $HYDE_BRANCH
161+
Commit Hash: $HYDE_COMMIT_HASH
162+
Remote: $HYDE_REMOTE
163+
Restore Date: $HYDE_VERSION_LAST_CHECKED
164+
Last Commit Message: $HYDE_VERSION_COMMIT_MSG
165+
166+
Tools:
167+
hydectl: $(hydectl version || echo "hydectl not found")
168+
$(hyprland -v | head -n1 || echo "hyprland not found")
169+
$(if hyprctl_output=$(hyprctl version 2>/dev/null | head -n1); then echo "$hyprctl_output (Running Instance)"; else echo "hyprctl not found or not running"; fi)
170+
$(hyde-ipc --version || echo "hyde-ipc not found")
171+
172+
173+
HyDE updates every friday, so please check for updates regularly.
174+
Run 'hyde-shell release-notes' to see the latest changes.
175+
HyDE is a community-driven project, and contributions are welcome.
176+
177+
VERSION
178+
179+
}
180+
181+
get_release_notes() {
182+
# shellcheck source=/dev/null
183+
if [[ ! -f "${XDG_STATE_HOME:-$HOME/.local/state}/hyde/version" ]]; then
184+
echo "HyDE version file not found. Please update HyDE."
185+
exit 1
186+
fi
187+
source "${XDG_STATE_HOME:-$HOME/.local/state}/hyde/version"
188+
echo "HyDE Release Notes:"
189+
echo "$HYDE_RELEASE_NOTES"
190+
}
191+
192+
147193
if [[ ! "${BASH_SOURCE[0]}" != "${0}" ]]; then
148194

149195
case $1 in
@@ -161,6 +207,12 @@ if [[ ! "${BASH_SOURCE[0]}" != "${0}" ]]; then
161207
shift
162208
call_wallbashScript "$@"
163209
;;
210+
--release-notes | release-notes)
211+
get_release_notes
212+
;;
213+
--version | version| -v)
214+
get_version
215+
;;
164216
--help | help | -h)
165217
USAGE
166218
;;

Scripts/restore_cfg.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,6 @@ json)
217217
;;
218218
esac
219219
echo ""
220+
221+
print_log -g "[version]" -b " :: " "saving version info..."
222+
"${scrDir}/version.sh" --cache || echo "Failed to save version info."

Scripts/version.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
3+
HYDE_CLONE_PATH=$(git rev-parse --show-toplevel)
4+
HYDE_BRANCH=$(git rev-parse --abbrev-ref HEAD)
5+
HYDE_REMOTE=$(git config --get remote.origin.url)
6+
HYDE_VERSION=$(git describe --tags --always)
7+
HYDE_COMMIT_HASH=$(git rev-parse HEAD)
8+
HYDE_VERSION_COMMIT_MSG=$(git log -1 --pretty=%B)
9+
HYDE_VERSION_LAST_CHECKED=$(date +%Y-%m-%d\ %H:%M%S\ %z)
10+
11+
generate_release_notes() {
12+
local latest_tag
13+
local commits
14+
15+
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null)
16+
17+
if [[ -z "$latest_tag" ]]; then
18+
echo "No release tags found"
19+
return
20+
fi
21+
22+
echo "=== Changes since $latest_tag ==="
23+
24+
commits=$(git log --oneline --pretty=format:"• %s" "$latest_tag"..HEAD 2>/dev/null)
25+
26+
if [[ -z "$commits" ]]; then
27+
echo "No commits since last release"
28+
return
29+
fi
30+
31+
echo "$commits"
32+
}
33+
34+
HYDE_RELEASE_NOTES=$(generate_release_notes)
35+
36+
echo "HyDE $HYDE_VERSION built from branch $HYDE_BRANCH at commit ${HYDE_COMMIT_HASH:0:12} ($HYDE_VERSION_COMMIT_MSG)"
37+
echo "Date: $HYDE_VERSION_LAST_CHECKED"
38+
echo "Repository: $HYDE_CLONE_PATH"
39+
echo "Remote: $HYDE_REMOTE"
40+
echo ""
41+
42+
if [[ "$1" == "--cache" ]]; then
43+
state_dir="${XDG_STATE_HOME:-$HOME/.local/state}/hyde"
44+
mkdir -p "$state_dir"
45+
version_file="$state_dir/version"
46+
47+
cat >"$version_file" <<EOL
48+
HYDE_CLONE_PATH='$HYDE_CLONE_PATH'
49+
HYDE_BRANCH='$HYDE_BRANCH'
50+
HYDE_REMOTE='$HYDE_REMOTE'
51+
HYDE_VERSION='$HYDE_VERSION'
52+
HYDE_VERSION_LAST_CHECKED='$HYDE_VERSION_LAST_CHECKED'
53+
HYDE_VERSION_COMMIT_MSG='$HYDE_VERSION_COMMIT_MSG'
54+
HYDE_COMMIT_HASH='$HYDE_COMMIT_HASH'
55+
HYDE_RELEASE_NOTES='$HYDE_RELEASE_NOTES'
56+
EOL
57+
58+
echo -e "Version cache output to $version_file\n"
59+
60+
elif [[ "$1" == "--release-notes" ]]; then
61+
echo "$HYDE_RELEASE_NOTES"
62+
63+
fi

0 commit comments

Comments
 (0)