From 96403639160cb1e3dde7adb15a9aaee1cef0e9d2 Mon Sep 17 00:00:00 2001 From: Darragh Bailey Date: Wed, 27 Jan 2016 14:38:54 +0000 Subject: [PATCH] Keep modifications to GitPython objects in single module Ensure all modifications to objects imported from GitPython are placed in the same module within git-upstream, from which all instances are then imported. This ensures that for all test contexts, the modified objects are the ones used instead of accidentally using the objects without modifications. Specifically this allows direct execution of the strategies unit tests using testtools to behave as expected, as otherwise the note module is not correctly pulled in when processing the filters. Change-Id: I0725429d8247e657681ee1dda25cb26e3688c0d9 --- git_upstream/lib/note.py | 5 ----- git_upstream/lib/pygitcompat.py | 8 ++++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/git_upstream/lib/note.py b/git_upstream/lib/note.py index 0b4fbea..92fdb1b 100644 --- a/git_upstream/lib/note.py +++ b/git_upstream/lib/note.py @@ -15,7 +15,6 @@ # limitations under the License. # -from git import base from git import GitCommandError from git_upstream.errors import GitUpstreamError @@ -68,7 +67,3 @@ def note_message(self, note_ref='refs/notes/commits'): return None else: raise e - -base.Object.add_note = add_note -base.Object.append_note = append_note -base.Object.note = note_message diff --git a/git_upstream/lib/pygitcompat.py b/git_upstream/lib/pygitcompat.py index fb1ebc5..8aeb127 100644 --- a/git_upstream/lib/pygitcompat.py +++ b/git_upstream/lib/pygitcompat.py @@ -16,6 +16,9 @@ # import git +from git import base + +from git_upstream.lib import note try: from git.objects.commit import Commit @@ -119,3 +122,8 @@ if not hasattr(Commit, 'iter_items'): git.commit.Commit = GitUpstreamCompatCommit else: Commit.short = GitUpstreamCompatCommit.short + + +base.Object.add_note = note.add_note +base.Object.append_note = note.append_note +base.Object.note = note.note_message