Skip to content

[release] Added Features#15

Merged
justinkumpe merged 3 commits intomainfrom
dev
Dec 30, 2025
Merged

[release] Added Features#15
justinkumpe merged 3 commits intomainfrom
dev

Conversation

@justinkumpe
Copy link
Member

@justinkumpe justinkumpe commented Dec 30, 2025

Summary by Sourcery

Introduce versioning, update checks, and enhanced branch and UI management to the git-helper script.

New Features:

  • Add script version metadata and display it in the helper title.
  • Add automatic detection and optional installation of whiptail or dialog using the system package manager, with a persistent opt-out option.
  • Allow text-based checklist prompts to accept an 'all' selection to choose every option.
  • Provide a GitHub-based update check that compares the local script version to the latest version and informs the user how to upgrade.
  • Add a command to create a new branch from an arbitrary commit, branch, or tag.
  • Add a command to rename branches, with optional synchronization of the rename to the remote origin.

Enhancements:

  • Extend the branches menu with options for creating branches from specific sources and renaming branches.
  • Extend the utilities menu with an option to run the new update check.

@justinkumpe justinkumpe self-assigned this Dec 30, 2025
@justinkumpe justinkumpe added bug Something isn't working enhancement New feature or request labels Dec 30, 2025
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 30, 2025

Reviewer's Guide

Enhances the git-helper script with versioning, optional installation of UI dependencies, a GitHub-based update checker, improved text UI checklist behavior, and additional branch management commands, wiring them into the existing menus.

Sequence diagram for the GitHub-based update check

sequenceDiagram
  actor User
  participant Menu as menu_utils
  participant Script as git_helper
  participant GitHub as github_raw

  User->>Menu: select check_updates
  Menu->>Script: cmd_check_updates
  Script->>Script: echo Checking for updates
  Script->>Script: fetch_latest_version
  Script->>GitHub: HTTP GET raw git-helper.sh
  GitHub-->>Script: script contents
  Script->>Script: extract SCRIPT_VERSION from response
  Script->>Script: compare_versions current SCRIPT_VERSION, latest_version
  Script->>Script: evaluate comparison result
  alt versions equal
    Script->>User: ui_message latest version already installed
  else current older
    Script->>User: ui_message new version available and manual git pull instructions
  else current newer
    Script->>User: ui_message running development version newer than latest release
  end
Loading

Flow diagram for UI detection and optional installation

flowchart TD
  A[start script] --> B[detect_ui]
  B --> C{whiptail available?}
  C -->|yes| D[set UI_TOOL to whiptail]
  C -->|no| E{dialog available?}
  E -->|yes| F[set UI_TOOL to dialog]
  E -->|no| G[set UI_TOOL to text]

  G --> H{NEVER_INSTALL_FILE exists?}
  H -->|yes| I[keep UI_TOOL as text and return]
  H -->|no| J[prompt_ui_choice]

  J --> K{user choice}
  K -->|no| I
  K -->|never| L[create CONFIG_DIR and NEVER_INSTALL_FILE]
  L --> I
  K -->|yes| M[select_ui_tool]

  M --> N{selected_tool is whiptail or dialog?}
  N -->|invalid| I
  N -->|valid| O[install_ui_package selected_tool]

  O --> P{installation success?}
  P -->|no| Q[print message and continue in text mode]
  Q --> I
  P -->|yes| R[set UI_TOOL to selected_tool]
  R --> S[print success message and return]

  D --> T[continue script]
  F --> T
  I --> T
  S --> T
Loading

File-Level Changes

Change Details Files
Introduce script versioning and GitHub metadata to support update checks and version-aware UI.
  • Add SCRIPT_VERSION and GITHUB_REPO constants and include version string in the script TITLE
  • Add semantic version comparison helper to compare current and remote versions
git_helpers/git-helper.sh
Add optional, persisted UI dependency installation flow when neither whiptail nor dialog is installed.
  • Add configuration directory and sentinel file to track a user’s choice to never install UI tools
  • Implement package manager detection for major distributions and a helper to install a chosen UI package
  • Extend UI detection to prompt user to install whiptail or dialog, respecting the persisted 'never install' choice
git_helpers/git-helper.sh
Improve text-mode checklist interaction to support selecting all items at once.
  • Track all checklist keys in text mode and interpret 'all' input as selecting every available key
git_helpers/git-helper.sh
Add GitHub-based update checking utility and expose it in the utilities menu.
  • Fetch the latest script version from the GitHub main branch using curl and parse SCRIPT_VERSION from the remote file
  • Compare local vs remote versions and show appropriate messages/instructions via ui_message
  • Wire a new 'Check for updates' option in the utilities menu to invoke the update check command
git_helpers/git-helper.sh
Extend branch management with creating from arbitrary refs and renaming (including optional remote rename).
  • Add a command to create a new branch from a specific commit hash, another branch, or a tag with basic validation
  • Add a command to rename a branch, handling the current branch case and optionally pushing the rename to origin and deleting the old remote
  • Register the new branch commands in the branches menu so they’re accessible from the UI
git_helpers/git-helper.sh

Possibly linked issues

  • #feature/git_helper: PR defines SCRIPT_VERSION, shows it in title, and implements a GitHub-based update check with messaging and instructions.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `git_helpers/git-helper.sh:860-861` </location>
<code_context>
+  print_info "Renamed branch" "$b → $new_name"
+  
+  # Check if branch existed on remote
+  if git ls-remote --heads origin "$b" >/dev/null; then
+    if ui_yesno "$TITLE" "Push rename to remote (delete old '$b' and push new '$new_name')?"; then
+      git push origin -u "$new_name" 2>&1
+      git push origin --delete "$b" 2>&1 || true
</code_context>

<issue_to_address>
**issue (bug_risk):** Remote-branch existence check with `git ls-remote` will always succeed if `origin` exists, even when the branch doesn’t.

`git ls-remote --heads origin "$b"` returns 0 as long as `origin` is reachable, even if no matching ref exists, so this condition will be true for purely local branches.

To only prompt when the branch actually exists on `origin`, test for output instead of exit code, e.g.:

```bash
if git ls-remote --heads origin "$b" | grep -qE "refs/heads/$b$"; then
  # branch exists on remote
fi
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +860 to +861
if git ls-remote --heads origin "$b" >/dev/null; then
if ui_yesno "$TITLE" "Push rename to remote (delete old '$b' and push new '$new_name')?"; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Remote-branch existence check with git ls-remote will always succeed if origin exists, even when the branch doesn’t.

git ls-remote --heads origin "$b" returns 0 as long as origin is reachable, even if no matching ref exists, so this condition will be true for purely local branches.

To only prompt when the branch actually exists on origin, test for output instead of exit code, e.g.:

if git ls-remote --heads origin "$b" | grep -qE "refs/heads/$b$"; then
  # branch exists on remote
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

1 participant