Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 1, 2026

The docker compose container detection and removal code had identical sudo fallback patterns duplicated across two blocks (lines 77-83 and 86-93).

Changes

  • Extract helper function: Created try_docker_command() to encapsulate sudo fallback pattern

    • Tries command without sudo first (macOS, Linux with docker group)
    • Falls back to sudo on Linux if needed
    • Preserves USED_SUDO state across multiple calls for accurate reporting
  • Simplify container handling: Reduced ~50 lines to ~40 lines by reusing helper

    • Container detection: try_docker_command "docker compose ps -q"
    • Container removal: try_docker_command "docker compose down"
    • Both now use consistent error handling

Example

# Before: Duplicate sudo patterns
if docker compose down 2>/dev/null || docker-compose down 2>/dev/null; then
    echo "Containers stopped"
elif [[ "$OSTYPE" != "darwin"* ]] && (sudo docker compose down 2>/dev/null || sudo docker-compose down 2>/dev/null); then
    echo "Containers stopped (with sudo)"
fi

# After: Reusable helper
if try_docker_command "docker compose down" || try_docker_command "docker-compose down"; then
    [ "$USED_SUDO" = "true" ] && echo "(with sudo)"
fi

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits February 1, 2026 16:50
Co-authored-by: hessius <1499030+hessius@users.noreply.github.com>
Co-authored-by: hessius <1499030+hessius@users.noreply.github.com>
Co-authored-by: hessius <1499030+hessius@users.noreply.github.com>
Co-authored-by: hessius <1499030+hessius@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 1, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] WIP address feedback from review on version 1.1.0 Consolidate duplicated sudo fallback logic in uninstall.sh Feb 1, 2026
Copilot AI requested a review from hessius February 1, 2026 16:55
@hessius hessius marked this pull request as ready for review February 1, 2026 17:53
@hessius hessius merged commit afbf0f0 into version/1.1.0 Feb 1, 2026
2 checks passed
@hessius hessius deleted the copilot/sub-pr-117-056e2f74-f666-4e11-96f4-872bb8f4c6d1 branch February 1, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants