Skip to content

🧹 Extract common logic in socktainer-symlink functions - #500

Merged
kaovilai merged 1 commit into
mainfrom
refactor-socktainer-socket-check-13440969520473177566
Jul 15, 2026
Merged

kaovilai merged 1 commit into
mainfrom
refactor-socktainer-socket-check-13440969520473177566

Conversation

@kaovilai

Copy link
Copy Markdown
Owner

🎯 What: Extracted the duplicate socket existence checks in the socktainer-symlink-* and socktainer-export-* functions into a reusable, private helper function _check_socktainer_socket.

💡 Why: This improves the maintainability and readability of zsh/aliases/docker.zsh by removing boilerplate condition checks across multiple functions, making future modifications to socktainer logic easier.

✅ Verification:

  • Ran zsh -n zsh/aliases/docker.zsh to ensure there are no syntax errors introduced.
  • Verified that functionality and exit codes (return 1) are preserved upon failure.

✨ Result: A cleaner script that follows DRY principles while preserving existing functionality.


PR created automatically by Jules for task 13440969520473177566 started by @kaovilai

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>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@kaovilai, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c6f02e60-bfed-4e5e-b8e8-63e9d4dd73fe

📥 Commits

Reviewing files that changed from the base of the PR and between 90d636e and 14e33cf.

📒 Files selected for processing (1)
  • zsh/aliases/docker.zsh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor-socktainer-socket-check-13440969520473177566

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread zsh/aliases/docker.zsh
Comment on lines +35 to +41
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
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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
}

Comment thread zsh/aliases/docker.zsh
}

function socktainer-symlink-docker() {
_check_socktainer_socket || return 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update the call site to use the renamed helper function. Additionally, we can simplify || return 1 to || return since return without arguments automatically propagates the exit status of the last executed command.

  socktainer-check-socket || return

Comment thread zsh/aliases/docker.zsh
echo "❌ Socktainer socket not found at $HOME/.socktainer/container.sock — is socktainer running?" >&2
return 1
fi
_check_socktainer_socket || return 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update the call site to use the renamed helper function and simplify the return statement.

  socktainer-check-socket || return

Comment thread zsh/aliases/docker.zsh
echo "❌ Socktainer socket not found at $HOME/.socktainer/container.sock — is socktainer running?" >&2
return 1
fi
_check_socktainer_socket || return 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update the call site to use the renamed helper function and simplify the return statement.

  socktainer-check-socket || return

Comment thread zsh/aliases/docker.zsh
echo "❌ Socktainer socket not found at $HOME/.socktainer/container.sock — is socktainer running?" >&2
return 1
fi
_check_socktainer_socket || return 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update the call site to use the renamed helper function and simplify the return statement.

  socktainer-check-socket || return

@github-actions github-actions Bot mentioned this pull request Jun 24, 2026
@kaovilai
kaovilai marked this pull request as ready for review July 15, 2026 19:30
Copilot AI review requested due to automatic review settings July 15, 2026 19:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_socket to validate the socktainer socket path and emit a consistent error.
  • Updated socktainer-symlink-* and socktainer-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.

Comment thread zsh/aliases/docker.zsh
Comment on lines 57 to 61
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" || {
@kaovilai
kaovilai merged commit 087748a into main Jul 15, 2026
16 checks passed
@kaovilai
kaovilai deleted the refactor-socktainer-socket-check-13440969520473177566 branch October 9, 2026 16:21
kaovilai added a commit that referenced this pull request Oct 9, 2026
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>
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