Skip to content

feat(git-bulk): Add compatibility to match workspaces using environnement variable #1191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion bin/git-bulk
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,14 @@ function wsnameToCurrent () {
while read -r workspace; do
if [ -z "$workspace" ]; then continue; fi
parseWsName "$workspace"
if echo "$PWD" | grep -o -q "$rwsdir"; then wsname="$rwsname" && return; fi
# compatibility with environment variable inside .gitconfig:
# use combination of `eval` and `realpath` to:
# 1. dereference possible environment variable contained in $rwsdir
# 2. match workspaces even across different symlinks
rwsdir_rp=$(eval realpath $rwsdir 2>/dev/null)
pwd_rp=$(eval realpath $PWD 2>/dev/null)
# if pwd and workspace directory match, use this workspace name as current workspace
if [[ "$pwd_rp" =~ "$rwsdir_rp" ]]; then wsname="$rwsname" && return; fi
done <<< "$(listall)"
# when here then not in workspace dir
echo 1>&2 "error: you are not in a workspace directory. your registered workspaces are:" && \
Expand Down
Loading