f6796e3d34334bed853f6a901712b1ac64185c7c
   1#!/bin/sh
   2#
   3# Copyright (c) 2010 Sverre Rabbelier
   4#
   5
   6test_description='Test remote-helper import and export commands'
   7
   8. ./test-lib.sh
   9
  10if ! test_have_prereq PYTHON ; then
  11        skip_all='skipping git-remote-hg tests, python not available'
  12        test_done
  13fi
  14
  15"$PYTHON_PATH" -c '
  16import sys
  17if sys.hexversion < 0x02040000:
  18    sys.exit(1)
  19' || {
  20        skip_all='skipping git-remote-hg tests, python version < 2.4'
  21        test_done
  22}
  23
  24compare_refs() {
  25        git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
  26        git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
  27        test_cmp expect actual
  28}
  29
  30test_expect_success 'setup repository' '
  31        git init --bare server/.git &&
  32        git clone server public &&
  33        (cd public &&
  34         echo content >file &&
  35         git add file &&
  36         git commit -m one &&
  37         git push origin master)
  38'
  39
  40test_expect_success 'cloning from local repo' '
  41        git clone "testgit::${PWD}/server" localclone &&
  42        test_cmp public/file localclone/file
  43'
  44
  45test_expect_success 'cloning from remote repo' '
  46        git clone "testgit::file://${PWD}/server" clone &&
  47        test_cmp public/file clone/file
  48'
  49
  50test_expect_success 'create new commit on remote' '
  51        (cd public &&
  52         echo content >>file &&
  53         git commit -a -m two &&
  54         git push)
  55'
  56
  57test_expect_success 'pulling from local repo' '
  58        (cd localclone && git pull) &&
  59        test_cmp public/file localclone/file
  60'
  61
  62test_expect_success 'pulling from remote remote' '
  63        (cd clone && git pull) &&
  64        test_cmp public/file clone/file
  65'
  66
  67test_expect_success 'pushing to local repo' '
  68        (cd localclone &&
  69        echo content >>file &&
  70        git commit -a -m three &&
  71        git push) &&
  72        compare_refs localclone HEAD server HEAD
  73'
  74
  75test_expect_success 'synch with changes from localclone' '
  76        (cd clone &&
  77         git pull)
  78'
  79
  80test_expect_success 'pushing remote local repo' '
  81        (cd clone &&
  82        echo content >>file &&
  83        git commit -a -m four &&
  84        git push) &&
  85        compare_refs clone HEAD server HEAD
  86'
  87
  88test_done