Skip to content

Commit 18d1017

Browse files
pierreayPierre Ayoubhyperupcall
authored
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 <[email protected]> * 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 <[email protected]> Co-authored-by: Edwin Kofler <[email protected]>
1 parent a841845 commit 18d1017

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

bin/git-bulk

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ singlemode=false
1010
allwsmode=false
1111
quiet=false
1212
no_follow_symlinks=false
13+
no_follow_hidden=false
1314

1415
#
1516
# print usage message
1617
#
1718
usage() {
18-
echo 1>&2 "usage: git bulk [--no-follow-symlinks] [-q|--quiet] [-g] ([-a]|[-w <ws-name>]) <git command>"
19+
echo 1>&2 "usage: git bulk [--no-follow-symlinks] [--no-follow-hidden] [-q|--quiet] [-g] ([-a]|[-w <ws-name>]) <git command>"
1920
echo 1>&2 " git bulk --addworkspace <ws-name> <ws-root-directory> (--from <URL or file>)"
2021
echo 1>&2 " git bulk --removeworkspace <ws-name>"
2122
echo 1>&2 " git bulk --addcurrent <ws-name>"
@@ -172,7 +173,10 @@ function executBulkOp () {
172173
cd "$gitrepodir" || exit 1 # into git repo location
173174
local curdir=$PWD
174175
local leadingpath=${curdir#"${actual}"}
175-
guardedExecution "$@"
176+
# do not execute if we do not want to consider a ".git" directory under a hidden directory
177+
if [ $no_follow_hidden = false ] || ! [[ "$leadingpath" =~ "/." ]]; then
178+
guardedExecution "$@"
179+
fi
176180
cd "$rwsdir" || exit 1 # back to origin location of last find command
177181
done
178182
done
@@ -193,6 +197,8 @@ while [ "${#}" -ge 1 ] ; do
193197
butilcommand="${1:2}" && wsname="$2" && wsdir="$3" && if [ "$4" == "--from" ]; then source="$5"; fi && break ;;
194198
--no-follow-symlinks)
195199
no_follow_symlinks=true ;;
200+
--no-follow-hidden)
201+
no_follow_hidden=true ;;
196202
-a)
197203
allwsmode=true ;;
198204
-g)

etc/git-extras-completion.zsh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ _git-bulk() {
135135
'-g[Ask the user for confirmation on every execution (guarded mode).]' \
136136
'-w[Run the git command on the specified workspace.]:workspace-name:__gitex_workspace_names' \
137137
'-q[Suppress bulk output about current execution (quiet mode).]' \
138+
'--no-follow-symlinks[Do not traverse symbolic links when searching for git repositories.]' \
139+
'--no-follow-hidden[Do not traverse hidden directories when searching for git repositories.]' \
138140
'--addworkspace[Register a workspace for bulk operations.]' \
139141
'--removeworkspace[Remove the specified workspace.]:workspace-name:__gitex_workspace_names' \
140142
'--addcurrent[Adds the current directory as workspace to git bulk operations]' \

man/git-bulk.1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
.SH "NAME"
55
\fBgit\-bulk\fR \- Run git commands on multiple repositories
66
.SH "SYNOPSIS"
7-
\fBgit\-bulk\fR [\-g] [\-\-no\-follow\-symlinks] ([\-a]|[\-w
7+
\fBgit\-bulk\fR [\-g] [\-\-no\-follow\-symlinks] [\-\-no\-follow\-hidden] ([\-a]|[\-w
88
.br
99
\fBgit\-bulk\fR \-\-addworkspace
1010
.br
@@ -37,6 +37,10 @@ Ask the user for confirmation on every execution\.
3737
.P
3838
Do not traverse symbolic links under the workspace when searching for git repositories\.
3939
.P
40+
\-\-no\-follow\-hidden
41+
.P
42+
Do not traverse hidden (dotted) directories under the workspace when searching for git repositories\.
43+
.P
4044
\-w <ws\-name>
4145
.P
4246
Run the git command on the specified workspace\. The workspace must be registered\.

man/git-bulk.html

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/git-bulk.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ git-bulk(1) -- Run git commands on multiple repositories
33

44
## SYNOPSIS
55

6-
`git-bulk` [-g] [--no-follow-symlinks] ([-a]|[-w &lt;ws-name&gt;]) &lt;git command&gt; <br/>
6+
`git-bulk` [-g] [--no-follow-symlinks] [--no-follow-hidden] ([-a]|[-w &lt;ws-name&gt;]) &lt;git command&gt; <br/>
77
`git-bulk` --addworkspace &lt;ws-name&gt; &lt;ws-root-directory&gt; (--from &lt;URL or file&gt;) <br/>
88
`git-bulk` --removeworkspace &lt;ws-name&gt; <br/>
99
`git-bulk` --addcurrent &lt;ws-name&gt; <br/>
@@ -32,6 +32,10 @@ git bulk adds convenient support for operations that you want to execute on mult
3232

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

35+
--no-follow-hidden
36+
37+
Do not traverse hidden (dotted) directories under the workspace when searching for git repositories.
38+
3539
-w &lt;ws-name&gt;
3640

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

0 commit comments

Comments
 (0)