Repository navigation
🧹 Extract common logic in socktainer-symlink functions - #500
Conversation
Extracted duplicated logic that checks for the existence of the socktainer socket (`~/.socktainer/container.sock`) into a new private helper function `_check_socktainer_socket`. Replaced inline checks in `socktainer-symlink-docker`, `socktainer-symlink-podman`, `socktainer-export-docker`, and `socktainer-export-podman` to call this helper. Co-authored-by: kaovilai <11228024+kaovilai@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Warning Review limit reached
Next review available in: 55 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request refactors the Socktainer socket check logic in zsh/aliases/docker.zsh by extracting it into a helper function. The review feedback recommends renaming the helper function to avoid a leading underscore, which is reserved for Zsh's completion system, and simplifying the call sites by using || return instead of || return 1 to automatically propagate the exit status.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| function _check_socktainer_socket() { | ||
| if [[ ! -S "$HOME/.socktainer/container.sock" ]]; then | ||
| echo "❌ Socktainer socket not found at $HOME/.socktainer/container.sock — is socktainer running?" >&2 | ||
| return 1 | ||
| fi | ||
| return 0 | ||
| } |
There was a problem hiding this comment.
In Zsh, functions starting with a single leading underscore (e.g., _check_socktainer_socket) are conventionally reserved for the completion system (compsys). Defining general helper functions with this prefix can conflict with completion autoloading or pollute the completion namespace.
It is highly recommended to use a descriptive namespace prefix without a leading underscore (e.g., socktainer-check-socket) to avoid any potential conflicts.
function socktainer-check-socket() {
if [[ ! -S "$HOME/.socktainer/container.sock" ]]; then
echo "❌ Socktainer socket not found at $HOME/.socktainer/container.sock — is socktainer running?" >&2
return 1
fi
return 0
}
| } | ||
|
|
||
| function socktainer-symlink-docker() { | ||
| _check_socktainer_socket || return 1 |
| echo "❌ Socktainer socket not found at $HOME/.socktainer/container.sock — is socktainer running?" >&2 | ||
| return 1 | ||
| fi | ||
| _check_socktainer_socket || return 1 |
| echo "❌ Socktainer socket not found at $HOME/.socktainer/container.sock — is socktainer running?" >&2 | ||
| return 1 | ||
| fi | ||
| _check_socktainer_socket || return 1 |
| echo "❌ Socktainer socket not found at $HOME/.socktainer/container.sock — is socktainer running?" >&2 | ||
| return 1 | ||
| fi | ||
| _check_socktainer_socket || return 1 |
There was a problem hiding this comment.
Pull request overview
This PR refactors zsh/aliases/docker.zsh to reduce duplication in the socktainer helper functions by extracting the repeated “socket exists” check into a shared private helper.
Changes:
- Added a reusable helper function
_check_socktainer_socketto validate the socktainer socket path and emit a consistent error. - Updated
socktainer-symlink-*andsocktainer-export-*functions to call the new helper instead of repeating the same check.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function socktainer-symlink-podman() { | ||
| if [[ ! -S "$HOME/.socktainer/container.sock" ]]; then | ||
| echo "❌ Socktainer socket not found at $HOME/.socktainer/container.sock — is socktainer running?" >&2 | ||
| return 1 | ||
| fi | ||
| _check_socktainer_socket || return 1 | ||
| local podman_sock_dir="${TMPDIR%/}/storage-run-$(id -u)/podman" | ||
| mkdir -p "$podman_sock_dir" || { echo "Error: Failed to create podman socket directory $podman_sock_dir" >&2; return 1; } | ||
| ln -sf "$HOME/.socktainer/container.sock" "$podman_sock_dir/podman.sock" || { |
Extracted duplicated logic that checks for the existence of the socktainer socket (`~/.socktainer/container.sock`) into a new private helper function `_check_socktainer_socket`. Replaced inline checks in `socktainer-symlink-docker`, `socktainer-symlink-podman`, `socktainer-export-docker`, and `socktainer-export-podman` to call this helper. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: kaovilai <11228024+kaovilai@users.noreply.github.com>
🎯 What: Extracted the duplicate socket existence checks in the
socktainer-symlink-*andsocktainer-export-*functions into a reusable, private helper function_check_socktainer_socket.💡 Why: This improves the maintainability and readability of
zsh/aliases/docker.zshby removing boilerplate condition checks across multiple functions, making future modifications to socktainer logic easier.✅ Verification:
zsh -n zsh/aliases/docker.zshto ensure there are no syntax errors introduced.✨ Result: A cleaner script that follows DRY principles while preserving existing functionality.
PR created automatically by Jules for task 13440969520473177566 started by @kaovilai