How to git pull multiple repositories in parallel without getting multiple gnome-keyring unlock prompts?

514 Views Asked by At

I use the following alias in .zshrc on Arch Linux to git pull all repositories in a directory in parallel:

alias multipull="find . -maxdepth 5 -name .git -type d | rev | cut -c 6- | rev | parallel -j64 'echo -n {}... && git -C {} pull'"

This works fine when the gnome-keyring is already unlocked but when it is not, it will prompt for each repository separately.

Ideas

  1. get GNU parallel to execute the first one serially and only then continue
  2. manually trigger the GNOME keyring unlock window (I found several solutions on StackOverflow for Ubunutu but none for Arch Linux) and then && it with the existing code

But other approaches are welcome as well. However I am not looking for a way to execute it serially. While that solves the problem it is much slower.

P.S.: Opened an issue at https://gitlab.gnome.org/GNOME/gnome-keyring/-/issues/102.

1

There are 1 best solutions below

0
On

Idea 2. You probably know of one of the git repositories that is fast to pull. Run that manually first. Maybe you can even create one with that purpose alone.

If you want to pursue idea 1, you can use (untested):

do_pull() {
  seq="$1"
  git="$2"
  if [ 1 = "$seq" ] ; then
    # this is job 1
    touch flag
  else
    while [ -e flag ] ; do
      # Wait for file flag to vanish
      sleep 1
    done
  fi
  echo -n "$git..."
  git -C "$git" pull
  rm -f flag
}
export -f do_pull
alias multipull="touch flag; ... | parallel -j64 do_pull {#} {}"