From b48e6284291b62745af8b2c9660c42ea38df6e14 Mon Sep 17 00:00:00 2001
From: Robin Roth <robin.roth@kit.edu>
Date: Fri, 15 Apr 2016 08:34:49 +0200
Subject: [PATCH] test git version before running test on depth

---
 test/integration/roles/test_git/tasks/main.yml | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/test/integration/roles/test_git/tasks/main.yml b/test/integration/roles/test_git/tasks/main.yml
index f895be638bf..792dd0dc3bb 100644
--- a/test/integration/roles/test_git/tasks/main.yml
+++ b/test/integration/roles/test_git/tasks/main.yml
@@ -40,6 +40,11 @@
 - name: verify that git is installed so this test can continue
   shell: which git
 
+- name: get git version, only newer than 1.8.2 has fixed git depth
+  shell: git --version | grep 'git version' | sed 's/git version //'
+  register: git_version
+
+
 #
 # Test repo=https://github.com/...
 #
@@ -254,6 +259,7 @@
     that: 
       - checkout_shallow.rc == 1
       - checkout_shallow|failed
+  when: git_version.stdout | version_compare("1.8.2", '>=')
 
 - name: clear checkout_dir
   file: state=absent path={{ checkout_dir }}
@@ -450,7 +456,7 @@
 
 
 # Test the depth option and fetching revisions that were ignored first
-
+  
 - name: clear checkout_dir
   file: state=absent path={{ checkout_dir }}
 
@@ -470,6 +476,7 @@
 - name: make sure the old commit was not fetched
   assert:
     that: checkout_early.rc == 1
+  when: git_version.stdout | version_compare("1.8.2", '>=')
 
 # tests https://github.com/ansible/ansible/issues/14954
 - name: fetch repo again with depth=1
@@ -481,6 +488,7 @@
 
 - assert:
     that: "not checkout2|changed"
+  when: git_version.stdout | version_compare("1.8.2", '>=')
 
 - name: again try to access earlier commit
   shell: git checkout 79624b4
@@ -492,6 +500,7 @@
 - name: again make sure the old commit was not fetched
   assert:
     that: checkout_early.rc == 1
+  when: git_version.stdout | version_compare("1.8.2", '>=')
     
 # make sure we are still able to fetch other versions
 - name: Clone same repo with older version