kiss: Add update-resolve hook

Hooks can now resolve paths if needed and tell the package manager
about the result. ie, a hook performing git retrieval can tell the
package manager the resolved path to the repository.

The package manager will then filter duplicates /correctly/ and
hooks can be sure they'll run once per *Git repository*.

  #!/bin/sh -e
  #
  # Generic Git repository updater.

  git remote >/dev/null 2>&1 || exit 0

  case $1 in
      update-resolve)
          subm=$(git rev-parse --show-superproject-working-tree)
          git -C "${subm:-"$PWD"}" rev-parse --show-toplevel
      ;;

      pre-update)
          case $(git config --get merge.verifySignatures) in true)
              printf 'Signature verification enabled.\n'
          esac

          git pull
          git submodule update --remote --init -f
      ;;
  esac

NOTE: This may be reverted. Just merging to allow users to play
around with it. It's one possible solution to removing hook
boilerplate for updates.
This commit is contained in:
Dylan Araps 2021-07-26 07:59:32 +03:00
parent f122076086
commit 569554d315
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C
1 changed files with 7 additions and 0 deletions

7
kiss
View File

@ -1562,6 +1562,13 @@ pkg_update() {
pkg_update_repo() {
cd "$repo" || die "Repository '$repo' inaccessible"
# Hook can tell the package manager to use a different path.
# arg1: update-resolve
# arg2: path to repository
_pwd_res=$(run_hook update-resolve "$repo") repo=${_pwd_res:-"$repo"}
cd "$repo" || die "Repository '$repo' inaccessible"
contains "$repos" "$PWD" || {
repos="$repos $PWD"