Skip to content

Conversation

seefood
Copy link
Contributor

@seefood seefood commented Oct 4, 2025

Summary

Fixes #2318 by addressing all review feedback:

  • ✅ Renamed function from _remote_name() to _get-git-default-remote-name() (dash naming convention per @seefood)
  • ✅ Scoped function to operate on $BASH_IT directory instead of CWD (per @akinomyoga)
  • ✅ Added command prefix to git commands for safety
  • ✅ Updated all call sites in _bash-it-update-() and _bash-it-version()

Changes

The function now uses pushd "${BASH_IT}" to ensure it operates on the bash-it repository directory, not the current working directory. This was the main issue identified in the review.

Attribution

Original implementation by @hyperupcall in PR #2318.

This PR supersedes #2318 with the requested changes applied.

Test Plan

  • Function correctly detects remote name from bash-it repo
  • Shellcheck passes
  • All linting checks pass

🤖 Generated with Claude Code

hyperupcall and others added 2 commits October 4, 2025 22:33
Addresses review feedback on PR Bash-it#2318:
- Rename function to _get-git-default-remote-name (dash naming convention)
- Scope function to operate on BASH_IT directory, not CWD
- Add command prefix to git commands for safety

Original implementation by Edwin Kofler (@hyperupcall)

Co-Authored-By: Edwin Kofler <[email protected]>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Addresses @akinomyoga's review feedback on PR Bash-it#2344:

1. **Replace pushd/popd with git --git-dir/--work-tree**
   - More direct approach without changing shell directory
   - Avoids side effects from directory changes
   - Cleaner code without need for popd cleanup

2. **Simplify awk command**
   - Changed from: `awk 'NR==1 { name=$1; print name } $1 != name { exit 1 }'`
   - Changed to: `awk 'NR==1 { print $1 }'`
   - Use bash parameter expansion `${remote_name:-origin}` for fallback
   - Simpler, more readable, same behavior

**Testing:**
- ✅ Function correctly returns 'fork' for current repo
- ✅ Function correctly returns 'me' for test repo with non-standard remote
- ✅ Shellcheck passes with no warnings

Co-authored-by: akinomyoga <[email protected]>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@seefood
Copy link
Contributor Author

seefood commented Oct 7, 2025

Applied both review feedback items from @akinomyoga:

  1. ✅ Replaced pushd/popd with git --git-dir and --work-tree parameters
  2. ✅ Simplified awk command to awk 'NR==1 { print }' with bash parameter expansion fallback

The function is now cleaner (8 lines shorter) and doesn't change shell directory. All tests pass including shellcheck.

@seefood seefood requested a review from akinomyoga October 7, 2025 09:49
Copy link
Contributor

@akinomyoga akinomyoga left a comment

Choose a reason for hiding this comment

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

LGTM

@seefood seefood merged commit 632e68c into Bash-it:master Oct 7, 2025
6 checks passed
@seefood seefood deleted the feature/fix-remote-name-detection branch October 7, 2025 13:43
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.

3 participants