mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
feat(git-bulk): add new option to no follow symlinks (#1194)
* feat(git-bulk): add --no-follow-symlinks flag * docs(git-bulk): add --no-follow-symlinks description * docs(man): make ronn * docs(git-bulk): put --no-follow-symlinks at right place in usage() * fix(git-bulk): use readarray for find command 1. Use `readarray` such that we can handle paths with spaces 2. Remove the unnecessary `eval`
This commit is contained in:
parent
64687599ae
commit
8eed5f49ad
15
bin/git-bulk
15
bin/git-bulk
|
|
@ -9,12 +9,13 @@ guardedmode=false
|
|||
singlemode=false
|
||||
allwsmode=false
|
||||
quiet=false
|
||||
no_follow_symlinks=false
|
||||
|
||||
#
|
||||
# print usage message
|
||||
#
|
||||
usage() {
|
||||
echo 1>&2 "usage: git bulk [-q|--quiet] [-g] ([-a]|[-w <ws-name>]) <git command>"
|
||||
echo 1>&2 "usage: git bulk [--no-follow-symlinks] [-q|--quiet] [-g] ([-a]|[-w <ws-name>]) <git command>"
|
||||
echo 1>&2 " git bulk --addworkspace <ws-name> <ws-root-directory> (--from <URL or file>)"
|
||||
echo 1>&2 " git bulk --removeworkspace <ws-name>"
|
||||
echo 1>&2 " git bulk --addcurrent <ws-name>"
|
||||
|
|
@ -156,7 +157,15 @@ function executBulkOp () {
|
|||
local actual=$PWD
|
||||
[ "${quiet?}" != "true" ] && echo 1>&2 "Executing bulk operation in workspace ${inverse}$actual${reset}"
|
||||
|
||||
allGitFolders=( $(eval find -L . -name ".git" 2>/dev/null) )
|
||||
# build `find` flags depending on command-line options
|
||||
local find_flags=()
|
||||
if [[ "$no_follow_symlinks" == true ]]; then
|
||||
find_flags+=(-P)
|
||||
else
|
||||
find_flags+=(-L)
|
||||
fi
|
||||
# find all git repositories under the workspace on which we want to operate
|
||||
readarray allGitFolders < <(find "${find_flags[@]}" . -name ".git" 2>/dev/null)
|
||||
|
||||
for line in "${allGitFolders[@]}"; do
|
||||
local gitrepodir=${line::${#line}-5} # cut the .git part of find results to have the root git directory of that repository
|
||||
|
|
@ -182,6 +191,8 @@ while [ "${#}" -ge 1 ] ; do
|
|||
butilcommand="${1:2}" && break ;;
|
||||
--removeworkspace|--addcurrent|--addworkspace)
|
||||
butilcommand="${1:2}" && wsname="$2" && wsdir="$3" && if [ "$4" == "--from" ]; then source="$5"; fi && break ;;
|
||||
--no-follow-symlinks)
|
||||
no_follow_symlinks=true ;;
|
||||
-a)
|
||||
allwsmode=true ;;
|
||||
-g)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
.SH "NAME"
|
||||
\fBgit\-bulk\fR \- Run git commands on multiple repositories
|
||||
.SH "SYNOPSIS"
|
||||
\fBgit\-bulk\fR [\-g] ([\-a]|[\-w
|
||||
\fBgit\-bulk\fR [\-g] [\-\-no\-follow\-symlinks] ([\-a]|[\-w
|
||||
.br
|
||||
\fBgit\-bulk\fR \-\-addworkspace
|
||||
.br
|
||||
|
|
@ -33,6 +33,10 @@ Run a git command on all workspaces and their repositories\.
|
|||
.P
|
||||
Ask the user for confirmation on every execution\.
|
||||
.P
|
||||
\-\-no\-follow\-symlinks
|
||||
.P
|
||||
Do not traverse symbolic links under the workspace when searching for git repositories\.
|
||||
.P
|
||||
\-w <ws\-name>
|
||||
.P
|
||||
Run the git command on the specified workspace\. The workspace must be registered\.
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@
|
|||
</p>
|
||||
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
||||
|
||||
<p><code>git-bulk</code> [-g] ([-a]|[-w <ws-name>]) <git command> </git></ws-name><br>
|
||||
<p><code>git-bulk</code> [-g] [--no-follow-symlinks] ([-a]|[-w <ws-name>]) <git command> </git></ws-name><br>
|
||||
<code>git-bulk</code> --addworkspace <ws-name> <ws-root-directory> (--from <url or file>) </url></ws-root-directory></ws-name><br>
|
||||
<code>git-bulk</code> --removeworkspace <ws-name> <br>
|
||||
<code>git-bulk</code> --addcurrent <ws-name> <br>
|
||||
|
|
@ -106,6 +106,10 @@
|
|||
|
||||
<p>Ask the user for confirmation on every execution.</p>
|
||||
|
||||
<p>--no-follow-symlinks</p>
|
||||
|
||||
<p>Do not traverse symbolic links under the workspace when searching for git repositories.</p>
|
||||
|
||||
<p>-w <ws-name></p>
|
||||
|
||||
<p>Run the git command on the specified workspace. The workspace must be registered.</p>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ git-bulk(1) -- Run git commands on multiple repositories
|
|||
|
||||
## SYNOPSIS
|
||||
|
||||
`git-bulk` [-g] ([-a]|[-w <ws-name>]) <git command> <br/>
|
||||
`git-bulk` [-g] [--no-follow-symlinks] ([-a]|[-w <ws-name>]) <git command> <br/>
|
||||
`git-bulk` --addworkspace <ws-name> <ws-root-directory> (--from <URL or file>) <br/>
|
||||
`git-bulk` --removeworkspace <ws-name> <br/>
|
||||
`git-bulk` --addcurrent <ws-name> <br/>
|
||||
|
|
@ -28,6 +28,10 @@ git bulk adds convenient support for operations that you want to execute on mult
|
|||
|
||||
Ask the user for confirmation on every execution.
|
||||
|
||||
--no-follow-symlinks
|
||||
|
||||
Do not traverse symbolic links under the workspace when searching for git repositories.
|
||||
|
||||
-w <ws-name>
|
||||
|
||||
Run the git command on the specified workspace. The workspace must be registered.
|
||||
|
|
|
|||
Loading…
Reference in a new issue