Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,20 @@ usage: git bulk [-g] ([-a]|[-w <ws-name>]) <git command>
git bulk --listall
```

Register a workspace so that `git bulk` knows about it (notice that <ws-root-directory> must be absolute path):
Register a workspace so that `git bulk` knows about it (it will be registered in your `.gitconfig`):

```bash
$ git bulk --addworkspace personal ~/workspaces/personal
```

Notice that `<ws-root-directory>` must be an absolute path (or an environment variable pointing to an absolute path).
In the case of a **single quoted environment variable**, it will be dereferenced at `git-bulk` runtime, suitable for dynamic workspaces (*e.g.*, defined in your `.bashrc`).
As an illustration:

```bash
$ git bulk --addworkspace personal '$PERSONAL_WORKSPACE'
```

With option `--from` the URL to a single repository or a file containing multiple URLs can be added and they will be cloned directly into the workspace. Suitable for the initial setup of a multi-repo project.

```bash
Expand Down
16 changes: 13 additions & 3 deletions bin/git-bulk
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,17 @@ function checkWSName () {
# parse out wsname from workspacespec
function parseWsName () {
local wsspec="$1"
# Get the workspace value from its specification in the `.gitconfig`.
# May be an absolute path or a variable name of the form: `$VARNAME`
rwsdir=${wsspec#* }
if [[ ${rwsdir:0:1} == '$' ]]; then
# Dereference the `rwsdir` value which is a variable name.
rwsdir_varname=${rwsdir:1}
rwsdir=${!rwsdir_varname}
if [[ -z "${rwsdir}" ]]; then
echo 1>&2 "error: bad environment variable: $rwsdir_varname" && exit 1
fi
fi
rwsname=${wsspec#*.} && rwsname=${rwsname%% *}
}

Expand Down Expand Up @@ -142,19 +152,19 @@ function executBulkOp () {
listall | while read -r workspacespec; do
parseWsName "$workspacespec"
if [[ -n $wsname ]] && [[ $rwsname != "$wsname" ]]; then continue; fi
eval cd "\"$rwsdir\""
cd "$rwsdir" || exit 1
local actual=$PWD
[ "${quiet?}" != "true" ] && echo 1>&2 "Executing bulk operation in workspace ${inverse}$actual${reset}"

allGitFolders=( $(eval find -L . -name ".git") )

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
eval cd "\"$gitrepodir\"" # into git repo location
cd "$gitrepodir" || exit 1 # into git repo location
local curdir=$PWD
local leadingpath=${curdir#"${actual}"}
guardedExecution "$@"
eval cd "\"$rwsdir\"" # back to origin location of last find command
cd "$rwsdir" || exit 1 # back to origin location of last find command
done
done
}
Expand Down
12 changes: 10 additions & 2 deletions man/git-bulk.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with Ronn-NG/v0.9.1
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
.TH "GIT\-BULK" "1" "September 2024" "" "Git Extras"
.TH "GIT\-BULK" "1" "February 2025" "" "Git Extras"
.SH "NAME"
\fBgit\-bulk\fR \- Run git commands on multiple repositories
.SH "SYNOPSIS"
Expand Down Expand Up @@ -64,10 +64,14 @@ git bulk \-\-listall
List all registered repositories\.
.SH "EXAMPLES"
.nf
Register a workspace so that git bulk knows about it:
Register a workspace so that git bulk knows about it using an absolute path:

$ git bulk \-\-addworkspace personal ~/workspaces/personal

Or register a workspace using an environment variable pointing to an absolute path:

$ git bulk \-\-addworkspace personal '$PERSONAL_WORKSPACE'

Use option \-\-from in order to directly clone a repository or multiple repositories

$ git bulk \-\-addworkspace personal ~/workspaces/personal \-\-from https://github\.com/tj/git\-extras\.git
Expand Down Expand Up @@ -108,6 +112,10 @@ Remove all registered workspaces:

$ git bulk \-\-purge
.fi
.SH "FILES"
.IP "\[ci]" 4
\fB\.gitconfig\fR: Store the \fBgit\-bulk\fR registered workspaces under the \fBbulkworkspaces\fR key\.
.IP "" 0
.SH "AUTHOR"
Written by Niklas Schlimm <\fIns103@hotmail\.de\fR>
.SH "REPORTING BUGS"
Expand Down
16 changes: 14 additions & 2 deletions man/git-bulk.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion man/git-bulk.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ git bulk adds convenient support for operations that you want to execute on mult

## EXAMPLES

Register a workspace so that git bulk knows about it:
Register a workspace so that git bulk knows about it using an absolute path:

$ git bulk --addworkspace personal ~/workspaces/personal

Or register a workspace using an environment variable pointing to an absolute path:

$ git bulk --addworkspace personal '$PERSONAL_WORKSPACE'

Use option --from in order to directly clone a repository or multiple repositories

$ git bulk --addworkspace personal ~/workspaces/personal --from https://github.com/tj/git-extras.git
Expand Down Expand Up @@ -104,6 +108,10 @@ git bulk adds convenient support for operations that you want to execute on mult

$ git bulk --purge

## FILES

- `.gitconfig`: Store the `git-bulk` registered workspaces under the `bulkworkspaces` key.

## AUTHOR

Written by Niklas Schlimm &lt;<[email protected]>&gt;
Expand Down
2 changes: 1 addition & 1 deletion man/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ git-clear-soft(1) git-clear-soft
git-clear(1) git-clear
git-coauthor(1) git-coauthor
git-commits-since(1) git-commits-since
git-contrib(1) git-contrib
git-continue(1) git-continue
git-contrib(1) git-contrib
git-count(1) git-count
git-cp(1) git-cp
git-create-branch(1) git-create-branch
Expand Down
Loading