From a90b85c64d394fafcd8c2b92c7ee09ed383b5a03 Mon Sep 17 00:00:00 2001 From: Pierre Ayoub Date: Thu, 13 Feb 2025 10:44:37 +0100 Subject: [PATCH 1/3] feat(git-bulk): add compatibility match against environnement variable --- bin/git-bulk | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/git-bulk b/bin/git-bulk index e3bdd66d6..5a1443210 100755 --- a/bin/git-bulk +++ b/bin/git-bulk @@ -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 environnement variable inside .gitconfig: + # use combination of `eval` and `realpath` to: + # 1. dereference possible environnement 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:" && \ From f7102e28ca6b5ef12aee624ff13281f95462d2b6 Mon Sep 17 00:00:00 2001 From: Pierre Ayoub Date: Thu, 13 Feb 2025 11:23:52 +0100 Subject: [PATCH 2/3] fix(git-bulk): restore old matching pattern behavior --- bin/git-bulk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-bulk b/bin/git-bulk index 5a1443210..235ae007b 100755 --- a/bin/git-bulk +++ b/bin/git-bulk @@ -127,7 +127,7 @@ function wsnameToCurrent () { 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 + 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:" && \ From 685512152e34590e3f395bf813d00e1485f5142b Mon Sep 17 00:00:00 2001 From: Pierre Ayoub Date: Sat, 15 Feb 2025 20:09:00 +0100 Subject: [PATCH 3/3] fix(git-bulk): typo --- bin/git-bulk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/git-bulk b/bin/git-bulk index 235ae007b..111cccfc9 100755 --- a/bin/git-bulk +++ b/bin/git-bulk @@ -120,9 +120,9 @@ function wsnameToCurrent () { while read -r workspace; do if [ -z "$workspace" ]; then continue; fi parseWsName "$workspace" - # compatibility with environnement variable inside .gitconfig: + # compatibility with environment variable inside .gitconfig: # use combination of `eval` and `realpath` to: - # 1. dereference possible environnement variable contained in $rwsdir + # 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)