chiark / gitweb /
Test suite: Provide t-sametree-parent
[dgit.git] / tests / lib
index 81accebf0f6f11d53639af725298416606102e33..36237a7485ed008f136ff4afd1c03dd2f3f3a6e5 100644 (file)
--- a/tests/lib
+++ b/tests/lib
@@ -335,7 +335,7 @@ t-dgit () {
 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
        $dgit --dgit=$dgit --dget:-u --dput:--config=$tmp/dput.cf \
                -dtest-dummy $DGIT_TEST_OPTS $DGIT_TEST_DEBUG \
-               -k39B13D8A "$@"
+               -k39B13D8A $t_dgit_xopts "$@"
        : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
 '
 }
@@ -398,18 +398,22 @@ t-setup-done () {
 t-setup-import () {
        local setupname=$1
 
+       local setupsrc
+       local lock
        if [ "x$tmpbase" = x ]; then
                # ADTTMP was set on entry to tests/lib, so we
                # are not sharing tmp area between tests
                setupsrc="$tmp"
+               lock="$tmp/.dummy.lock"
        else
                setupsrc="$tmpbase/$setupname"
+               lock="$setupsrc.lock"
        fi
 
        local simport="$setupsrc/IMPORT"
 
        if ! [ -e "$simport" ]; then
-               with-lock-ex -w "$simport.lock" \
+               with-lock-ex -w "$lock" \
                xargs -0 -a $tmp/.save-env \
                bash -xec '
                        cd "$1"; shift
@@ -504,6 +508,28 @@ t-v-tag () {
        echo refs/tags/$tagpfx/${v//\~/_}
 }
 
+t-format-ref () {
+       git log -n1 --pretty=format:"$1" "$2"
+}
+
+t-sametree-parent () {
+       local ref=$1
+       local parent
+       local ctree=$(t-format-ref '%T' "$ref")
+       while :; do
+               local psame=''
+               for parent in $(t-format-ref '%P' "$ref"); do
+                       local ptree=$(t-format-ref '%T' "$parent")
+                       if [ "x$ptree" = "x$ctree" ]; then
+                               psame+=" $parent"
+                       fi
+               done
+               case "$psame" in ""|" * *") break ;; esac
+               ref="${psame# }"
+       done
+       echo "$ref"
+}
+
 t-check-pushed-master () {
        local master=`t-git-get-ref refs/heads/master`
        if [ x$master = x$t_ref_val ]; then return; fi
@@ -650,7 +676,7 @@ t-gbp-example-prep () {
 
 t-commit () {
        local msg=$1
-       v=${2:-1.$revision}
+       v=${2:-${majorv:-1}.$revision}
        dch -v$v --distribution ${3:-unstable} "$1"
        git add debian/changelog
        debcommit