diff --git a/Commands.md b/Commands.md index de98cef4..1085ba7b 100644 --- a/Commands.md +++ b/Commands.md @@ -280,11 +280,20 @@ usage: git bulk [-g] ([-a]|[-w ]) git bulk --listall ``` - Register a workspace so that `git bulk` knows about it (notice that 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 `` 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 diff --git a/bin/git-bulk b/bin/git-bulk index e3bdd66d..0a596542 100755 --- a/bin/git-bulk +++ b/bin/git-bulk @@ -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%% *} } @@ -142,7 +152,7 @@ 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}" @@ -150,11 +160,11 @@ function executBulkOp () { 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 } diff --git a/man/git-bulk.1 b/man/git-bulk.1 index 1266608c..69a6a38c 100644 --- a/man/git-bulk.1 +++ b/man/git-bulk.1 @@ -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" @@ -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 @@ -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" diff --git a/man/git-bulk.html b/man/git-bulk.html index de121b14..7fe76890 100644 --- a/man/git-bulk.html +++ b/man/git-bulk.html @@ -58,6 +58,7 @@ DESCRIPTION OPTIONS EXAMPLES + FILES AUTHOR REPORTING BUGS SEE ALSO @@ -137,10 +138,14 @@

OPTIONS

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
@@ -182,6 +187,13 @@ 

EXAMPLES

$ git bulk --purge
+

FILES

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

AUTHOR

Written by Niklas Schlimm <ns103@hotmail.de>

@@ -196,7 +208,7 @@

SEE ALSO

  1. -
  2. September 2024
  3. +
  4. February 2025
  5. git-bulk(1)
diff --git a/man/git-bulk.md b/man/git-bulk.md index 80edda48..4dca4d32 100644 --- a/man/git-bulk.md +++ b/man/git-bulk.md @@ -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 @@ -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 <> diff --git a/man/index.txt b/man/index.txt index c4c71681..5e98b173 100644 --- a/man/index.txt +++ b/man/index.txt @@ -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