[feature/git_helper-13] Added Update Check#14
Merged
justinkumpe merged 1 commit intodevfrom Dec 30, 2025
Merged
Conversation
Reviewer's GuideAdds a versioned update-check mechanism that pulls the latest script version from GitHub, improves UI-tool detection with optional package installation and persistent opt-out, and introduces a new branch-creation flow that allows creating a branch from a commit, branch, or tag while wiring these features into the existing menus. Sequence diagram for improved UI tool detection and optional installationsequenceDiagram
actor User
participant GitHelperScript
participant SystemPackageManager
participant ConfigFilesystem
User->>GitHelperScript: run git-helper.sh
GitHelperScript->>GitHelperScript: detect_ui()
alt whiptail installed
GitHelperScript->>GitHelperScript: UI_TOOL = whiptail
GitHelperScript-->>User: continue with whiptail UI
else dialog installed
GitHelperScript->>GitHelperScript: UI_TOOL = dialog
GitHelperScript-->>User: continue with dialog UI
else no UI tool installed
GitHelperScript->>GitHelperScript: UI_TOOL = text
GitHelperScript->>ConfigFilesystem: check NEVER_INSTALL_FILE
alt never install recorded
GitHelperScript-->>User: continue with text UI
else not recorded
GitHelperScript-->>User: prompt_ui_choice()
alt user chooses yes
GitHelperScript-->>User: select_ui_tool()
User-->>GitHelperScript: choose whiptail or dialog
GitHelperScript->>SystemPackageManager: install_ui_package(selected_tool)
alt installation succeeds
GitHelperScript->>GitHelperScript: UI_TOOL = selected_tool
GitHelperScript-->>User: Successfully installed selected_tool
else installation fails
GitHelperScript-->>User: Installation failed, continue with text UI
end
else user chooses no
GitHelperScript-->>User: continue with text UI
else user chooses never
GitHelperScript->>ConfigFilesystem: create NEVER_INSTALL_FILE
GitHelperScript-->>User: continue with text UI
end
end
end
Sequence diagram for the new update check commandsequenceDiagram
actor User
participant GitHelperScript
participant GitHubRaw
User->>GitHelperScript: select check_updates
GitHelperScript->>GitHelperScript: cmd_check_updates()
GitHelperScript->>GitHelperScript: fetch_latest_version()
alt curl not available
GitHelperScript-->>User: ui_message "Failed to check for updates"
else curl available
GitHelperScript->>GitHubRaw: GET raw git-helper.sh
GitHubRaw-->>GitHelperScript: script contents
GitHelperScript->>GitHelperScript: extract latest_version from SCRIPT_VERSION
alt latest_version empty
GitHelperScript-->>User: ui_message "Could not retrieve version information"
else latest_version found
GitHelperScript->>GitHelperScript: compare_versions(SCRIPT_VERSION, latest_version)
alt versions equal
GitHelperScript-->>User: ui_message "You are running the latest version"
else current older
GitHelperScript-->>User: ui_message with update instructions
else current newer
GitHelperScript-->>User: ui_message "development version newer than latest release"
end
end
end
Sequence diagram for creating a branch from commit, branch, or tagsequenceDiagram
actor User
participant GitHelperScript
participant Git
User->>GitHelperScript: open Branches menu
GitHelperScript-->>User: show menu including branch_create_from
User->>GitHelperScript: select branch_create_from
GitHelperScript->>GitHelperScript: cmd_branch_create_from()
GitHelperScript-->>User: ui_input "New branch name"
User-->>GitHelperScript: enter name
alt branch name empty
GitHelperScript-->>User: cancel operation
else name provided
GitHelperScript-->>User: ui_menu "Branch from..." (commit, branch, tag, cancel)
User-->>GitHelperScript: choose option
alt commit selected
GitHelperScript-->>User: ui_input "Commit hash"
User-->>GitHelperScript: enter commit hash
alt hash not empty
GitHelperScript->>Git: git checkout -b name hash
Git-->>GitHelperScript: branch created
GitHelperScript-->>User: print_info "Created branch from commit"
end
else branch selected
GitHelperScript->>GitHelperScript: pick_branch()
GitHelperScript-->>User: branch picker UI
User-->>GitHelperScript: select source branch
alt source not empty
GitHelperScript->>Git: git checkout -b name source_branch
Git-->>GitHelperScript: branch created
GitHelperScript-->>User: print_info "Created branch from branch"
end
else tag selected
GitHelperScript-->>User: ui_input "Tag name"
User-->>GitHelperScript: enter tag
alt tag resolves
GitHelperScript->>Git: git rev-parse tag
Git-->>GitHelperScript: success
GitHelperScript->>Git: git checkout -b name tag
Git-->>GitHelperScript: branch created
GitHelperScript-->>User: print_info "Created branch from tag"
else tag missing
GitHelperScript-->>User: ui_message "Tag not found"
end
else cancel selected
GitHelperScript-->>User: return to Branches menu
end
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `git_helpers/git-helper.sh:17` </location>
<code_context>
HEIGHT=20
WIDTH=78
MENU_HEIGHT=12
+CONFIG_DIR="${XDG_CONFIG_HOME:-.config}/git-helper"
+NEVER_INSTALL_FILE="$CONFIG_DIR/never-install-ui"
+
</code_context>
<issue_to_address>
**issue (bug_risk):** CONFIG_DIR falls back to a relative directory instead of the XDG default of ~/.config when XDG_CONFIG_HOME is unset.
With `${XDG_CONFIG_HOME:-.config}` the config path becomes relative to the current working directory (e.g. `./.config/git-helper`), so state files end up wherever the script is run instead of in the standard XDG location. To follow the spec and use `$HOME/.config` as the fallback, you could do:
```bash
default_config_dir="${XDG_CONFIG_HOME:-$HOME/.config}"
CONFIG_DIR="$default_config_dir/git-helper"
```
</issue_to_address>
### Comment 2
<location> `git_helpers/git-helper.sh:406-408` </location>
<code_context>
+}
+
+# Fetch the latest version from GitHub
+fetch_latest_version() {
+ if ! command -v curl >/dev/null 2>&1; then
+ echo "curl not available for update check" >&2
+ return 1
+ fi
+
+ local raw_url="https://raw.githubusercontent.com/$GITHUB_REPO/main/git_helpers/git-helper.sh"
+ local response
+ response=$(curl -s "$raw_url" 2>/dev/null) || return 1
+
+ # Extract SCRIPT_VERSION from the file
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Network call for update check has no timeout, risking the script hanging indefinitely on bad networks.
Since `curl` is called without any timeout, this function can block for a long time on flaky or firewalled networks and make `cmd_check_updates` appear frozen. Consider adding connect and overall timeouts, for example:
```bash
response=$(curl -s --connect-timeout 5 --max-time 10 "$raw_url" 2>/dev/null) || return 1
```
```suggestion
local raw_url="https://raw.githubusercontent.com/$GITHUB_REPO/main/git_helpers/git-helper.sh"
local response
response=$(curl -s --connect-timeout 5 --max-time 10 "$raw_url" 2>/dev/null) || return 1
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
030d34e to
0ec01a1
Compare
0ec01a1 to
0e4fc05
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Add versioning and update-check functionality to the git-helper script, enhance UI tool detection with optional guided installation, and extend branch management utilities.
New Features: