chiark / gitweb /
Infra: dgit-ssh-dispatch: Break out serve_up (nfc)
[dgit.git] / tests / lib
index c91020bc3285a3e5545fe0e5d71b3d0340d42e8f..0b0ae47280f0158efd3471ccf869d25afe6c1414 100644 (file)
--- a/tests/lib
+++ b/tests/lib
@@ -72,6 +72,34 @@ t-expect-fail () {
                fail "error message not found"
 }
 
+t-expect-push-fail () {
+       local mpat="$1"; shift
+
+       local triedpush=`git rev-parse HEAD`
+
+       t-reporefs pre-push
+       t-expect-fail "$mpat"  "$@"
+       t-reporefs post-push
+       diff $tmp/show-refs.{pre,post}-push
+
+       t-git-objects-not-present '' $triedpush
+
+       eval "$t_expect_push_fail_hook"
+}
+
+t-git-objects-not-present () {
+       # t-git-objects-not-present GITDIR|'' OBJID [...]
+       # specifying '' means the repo for package $p
+       local gitdir="${1-$tmp/git/$p.git}"
+       local obj
+       if ! [ -e "$gitdir" ]; then return; fi
+       for obj in "$@"; do
+               GIT_DIR=$gitdir \
+               t-expect-fail 'unable to find' \
+               git cat-file -t $obj
+       done
+}
+
 t-reporefs () {
        local whichoutput=$1; shift
        local outputfile="$tmp/show-refs.$whichoutput"
@@ -274,6 +302,16 @@ t-clean-on-branch () {
        t-output "## $1" git status -b --porcelain
 }
 
+t-git-get-ref-exact () {
+       local ref=$1
+       # does not dereference, unlike t-git-get-ref
+       case "$ref" in
+       refs/*) ;;
+       *) fail "t-git-get-ref-exact bad $ref" ;;
+       esac
+       git for-each-ref --format='%(objectname)' "[r]efs/${ref#refs/}"
+}
+
 t-git-get-ref () {
        local ref=$1
        case "$ref" in
@@ -395,6 +433,15 @@ t-tstunt-parsechangelog () {
        t-tstunt dpkg-parsechangelog Dpkg/Changelog/Parse.pm
 }
 
+t-prep-mergechangelogs () {
+       local b=merge.dpkg-mergechangelogs
+       git config $b.name 'debian/changelog merge driver'
+       git config $b.driver 'dpkg-mergechangelogs -m %O %A %B %A'
+       mkdir -p .git/info
+       echo >>.git/info/attributes \
+               'debian/changelog merge=dpkg-mergechangelogs'
+}
+
 t-ref-dsc-dgit () {
        local dsc=${p}_${v}.dsc
        local val=`t-822-field $tmp/incoming/$dsc Dgit`