Clear the git repo cache on update.

The GitPython Repo object caches whether a given sha is held in an packed
or loose database.  If the remote repository is repacked, that information
could be invalid.  Therefore, each time the local repo is updated from the
remote, clear the object database cache.

See this file for the cache in action:
  https://github.com/gitpython-developers/gitdb/blob/master/gitdb/db/base.py#L227

Change-Id: I547ba01d8cdc20f431e93e02736b498f744992c0
Reviewed-on: https://review.openstack.org/12597
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py
index d32f49d..568c85d 100644
--- a/tests/test_scheduler.py
+++ b/tests/test_scheduler.py
@@ -1493,3 +1493,40 @@
         assert self.countJobResults(finished_jobs, 'ABORTED') == 15
         assert len(finished_jobs) == 44
         self.assertEmptyQueues()
+
+    def test_merger_repack(self):
+        "Test that the merger works after a repack"
+        A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
+        A.addApproval('CRVW', 2)
+        self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
+        self.waitUntilSettled()
+        jobs = self.fake_jenkins.job_history
+        job_names = [x['name'] for x in jobs]
+        assert 'project-merge' in job_names
+        assert 'project-test1' in job_names
+        assert 'project-test2' in job_names
+        assert jobs[0]['result'] == 'SUCCESS'
+        assert jobs[1]['result'] == 'SUCCESS'
+        assert jobs[2]['result'] == 'SUCCESS'
+        assert A.data['status'] == 'MERGED'
+        assert A.reported == 2
+        self.assertEmptyQueues()
+
+        path = os.path.join(GIT_ROOT, "org/project")
+        os.system('git --git-dir=%s/.git repack -afd' % path)
+
+        A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
+        A.addApproval('CRVW', 2)
+        self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
+        self.waitUntilSettled()
+        jobs = self.fake_jenkins.job_history
+        job_names = [x['name'] for x in jobs]
+        assert 'project-merge' in job_names
+        assert 'project-test1' in job_names
+        assert 'project-test2' in job_names
+        assert jobs[0]['result'] == 'SUCCESS'
+        assert jobs[1]['result'] == 'SUCCESS'
+        assert jobs[2]['result'] == 'SUCCESS'
+        assert A.data['status'] == 'MERGED'
+        assert A.reported == 2
+        self.assertEmptyQueues()