From 9cde57fa58b70cf5d9233531edc08de5c93308fb Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 23 Dec 2022 15:49:23 -0700 Subject: add git_repack myrepos action --- lib-src/mr/config | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib-src') diff --git a/lib-src/mr/config b/lib-src/mr/config index aea3bd03..6a8a8743 100644 --- a/lib-src/mr/config +++ b/lib-src/mr/config @@ -35,6 +35,22 @@ unstow = hstow unstow "$MR_REPO" restow = hstow restow "$MR_REPO" adopt = hstow adopt "$MR_REPO" +# Repack git-remote-gcrypt origin remotes. +# Useful to avoid surprise repacks; see git-remote-gcrypt README.rst. +git_repack = + git config --get remote.origin.gcrypt-id >/dev/null || exit 0 + if ! git is-clean; then + echo >&2 must commit first; exit 1 + elif [ -n "$(git for-each-ref \ + --no-contains=origin/master refs/heads/master)" ]; then + git pull origin master + fi + # Ensure that there is something to push, else no repack will occur. + [ -n "$(git for-each-ref \ + --contains=master refs/remotes/origin/master)" ] \ + && git push -f origin origin/master~1:master + GCRYPT_FULL_REPACK=yes git push origin master + lib = if [ -n "$USER" ]; then whoami="$USER" -- cgit v1.2.3