From 18d101732552c0bfba53cccb572de4f95c4ae9ae Mon Sep 17 00:00:00 2001 From: Pierre Ayoub Date: Wed, 5 Mar 2025 03:39:41 +0100 Subject: [PATCH] feat(git-bulk): add new option to not follow hidden directories (#1195) * feat(git-bulk): add --no-follow-hidden flag * docs(git-bulk): add --no-follow-hidden description * docs(man): make ronn * docs(git-bulk): put --no-follow-hidden at right place in usage() * refactor(git-bulk): logic optimization Remove unnecessary subshell Co-authored-by: Edwin Kofler * fix(git-bulk): bad test operator With the Bash' regexp matching operator `=~`, we need to use the Bash conditional expression evaluation command `[[ ]]`. * docs(completion.zsh): add --no-follow-hidden and --no-follow-symlink --------- Co-authored-by: Pierre Ayoub Co-authored-by: Edwin Kofler --- bin/git-bulk | 10 ++++++++-- etc/git-extras-completion.zsh | 2 ++ man/git-bulk.1 | 6 +++++- man/git-bulk.html | 6 +++++- man/git-bulk.md | 6 +++++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/bin/git-bulk b/bin/git-bulk index fe58e48..1f414ea 100755 --- a/bin/git-bulk +++ b/bin/git-bulk @@ -10,12 +10,13 @@ singlemode=false allwsmode=false quiet=false no_follow_symlinks=false +no_follow_hidden=false # # print usage message # usage() { - echo 1>&2 "usage: git bulk [--no-follow-symlinks] [-q|--quiet] [-g] ([-a]|[-w ]) " + echo 1>&2 "usage: git bulk [--no-follow-symlinks] [--no-follow-hidden] [-q|--quiet] [-g] ([-a]|[-w ]) " echo 1>&2 " git bulk --addworkspace (--from )" echo 1>&2 " git bulk --removeworkspace " echo 1>&2 " git bulk --addcurrent " @@ -172,7 +173,10 @@ function executBulkOp () { cd "$gitrepodir" || exit 1 # into git repo location local curdir=$PWD local leadingpath=${curdir#"${actual}"} - guardedExecution "$@" + # do not execute if we do not want to consider a ".git" directory under a hidden directory + if [ $no_follow_hidden = false ] || ! [[ "$leadingpath" =~ "/." ]]; then + guardedExecution "$@" + fi cd "$rwsdir" || exit 1 # back to origin location of last find command done done @@ -193,6 +197,8 @@ while [ "${#}" -ge 1 ] ; do butilcommand="${1:2}" && wsname="$2" && wsdir="$3" && if [ "$4" == "--from" ]; then source="$5"; fi && break ;; --no-follow-symlinks) no_follow_symlinks=true ;; + --no-follow-hidden) + no_follow_hidden=true ;; -a) allwsmode=true ;; -g) diff --git a/etc/git-extras-completion.zsh b/etc/git-extras-completion.zsh index 63e77f5..cbe72e1 100644 --- a/etc/git-extras-completion.zsh +++ b/etc/git-extras-completion.zsh @@ -135,6 +135,8 @@ _git-bulk() { '-g[Ask the user for confirmation on every execution (guarded mode).]' \ '-w[Run the git command on the specified workspace.]:workspace-name:__gitex_workspace_names' \ '-q[Suppress bulk output about current execution (quiet mode).]' \ + '--no-follow-symlinks[Do not traverse symbolic links when searching for git repositories.]' \ + '--no-follow-hidden[Do not traverse hidden directories when searching for git repositories.]' \ '--addworkspace[Register a workspace for bulk operations.]' \ '--removeworkspace[Remove the specified workspace.]:workspace-name:__gitex_workspace_names' \ '--addcurrent[Adds the current directory as workspace to git bulk operations]' \ diff --git a/man/git-bulk.1 b/man/git-bulk.1 index 0ed0a14..64a7d9b 100644 --- a/man/git-bulk.1 +++ b/man/git-bulk.1 @@ -4,7 +4,7 @@ .SH "NAME" \fBgit\-bulk\fR \- Run git commands on multiple repositories .SH "SYNOPSIS" -\fBgit\-bulk\fR [\-g] [\-\-no\-follow\-symlinks] ([\-a]|[\-w +\fBgit\-bulk\fR [\-g] [\-\-no\-follow\-symlinks] [\-\-no\-follow\-hidden] ([\-a]|[\-w .br \fBgit\-bulk\fR \-\-addworkspace .br @@ -37,6 +37,10 @@ Ask the user for confirmation on every execution\. .P Do not traverse symbolic links under the workspace when searching for git repositories\. .P +\-\-no\-follow\-hidden +.P +Do not traverse hidden (dotted) directories under the workspace when searching for git repositories\. +.P \-w .P Run the git command on the specified workspace\. The workspace must be registered\. diff --git a/man/git-bulk.html b/man/git-bulk.html index 66b0e17..b5165be 100644 --- a/man/git-bulk.html +++ b/man/git-bulk.html @@ -78,7 +78,7 @@

SYNOPSIS

-

git-bulk [-g] [--no-follow-symlinks] ([-a]|[-w ])
+

git-bulk [-g] [--no-follow-symlinks] [--no-follow-hidden] ([-a]|[-w ])
git-bulk --addworkspace (--from )
git-bulk --removeworkspace <ws-name>
git-bulk --addcurrent <ws-name>
@@ -110,6 +110,10 @@

Do not traverse symbolic links under the workspace when searching for git repositories.

+

--no-follow-hidden

+ +

Do not traverse hidden (dotted) directories under the workspace when searching for git repositories.

+

-w <ws-name>

Run the git command on the specified workspace. The workspace must be registered.

diff --git a/man/git-bulk.md b/man/git-bulk.md index f5550d5..68ac35c 100644 --- a/man/git-bulk.md +++ b/man/git-bulk.md @@ -3,7 +3,7 @@ git-bulk(1) -- Run git commands on multiple repositories ## SYNOPSIS -`git-bulk` [-g] [--no-follow-symlinks] ([-a]|[-w <ws-name>]) <git command>
+`git-bulk` [-g] [--no-follow-symlinks] [--no-follow-hidden] ([-a]|[-w <ws-name>]) <git command>
`git-bulk` --addworkspace <ws-name> <ws-root-directory> (--from <URL or file>)
`git-bulk` --removeworkspace <ws-name>
`git-bulk` --addcurrent <ws-name>
@@ -32,6 +32,10 @@ git bulk adds convenient support for operations that you want to execute on mult Do not traverse symbolic links under the workspace when searching for git repositories. + --no-follow-hidden + + Do not traverse hidden (dotted) directories under the workspace when searching for git repositories. + -w <ws-name> Run the git command on the specified workspace. The workspace must be registered.