Skip to content

Commit

Permalink
make git-sync and git-fetch work without arguments by defaulting to .
Browse files Browse the repository at this point in the history
  • Loading branch information
Okeanos committed Aug 20, 2024
1 parent fb99d1c commit 74280e9
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions stow/shell/.config/bash/functions
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,22 @@ function tre() {
# asynchrounously call git pull --rebase --autostash on any repository one level
# down from the specified path.
function git-sync {
if [[ -z "${1}" ]]; then
echo "ERROR: Please specify a path to sync"
return 1
local path="."
if [[ $# -ne 0 ]]; then
path="${1}"
fi
find "${1}" -maxdepth 2 -mindepth 2 -type d -name '.git' -print0 | xargs -P 8 -0 -I % bash -c 'git -C %/.. pull --rebase --autostash --quiet || echo "Failed updating: %"'
find "${path}" -maxdepth 2 -mindepth 2 -type d -name '.git' -print0 | \
xargs -P 8 -0 -I % bash -c 'git -C %/.. pull --rebase --autostash --quiet || echo "Failed updating: %"'
}

# `git-fetch` is a wrapper function around `find`, `xargs` that will
# asynchrounously call --all --prune --prune-tags --quiet on any repository one level
# down from the specified path.
function git-fetch {
if [[ -z "${1}" ]]; then
echo "ERROR: Please specify a path to sync"
return 1
local path="."
if [[ $# -ne 0 ]]; then
path="${1}"
fi
find "${1}" -maxdepth 2 -mindepth 2 -type d -name '.git' -print0 | xargs -P 8 -0 -I % bash -c 'git -C %/.. fetch --all --prune --prune-tags --quiet || echo "Failed updating: %"'
find "${path}" -maxdepth 2 -mindepth 2 -type d -name '.git' -print0 | \
xargs -P 8 -0 -I % bash -c 'git -C %/.. fetch --all --prune --prune-tags --quiet || echo "Failed updating: %"'
}

0 comments on commit 74280e9

Please sign in to comment.