From b01824b1aecf8aadae4501e22feb45c20fb26bce Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Oct 2009 22:22:28 +0200 Subject: Fixed remaining tests to deal with the changes mode is now generally an int compatible to the stat module --- lib/git/base.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/git/base.py') diff --git a/lib/git/base.py b/lib/git/base.py index b7976dab..4e5298e4 100644 --- a/lib/git/base.py +++ b/lib/git/base.py @@ -171,9 +171,27 @@ class IndexObject(Object): file.ext or folder/other.ext """ super(IndexObject, self).__init__(repo, id) + if isinstance(mode, basestring): + mode = self._mode_str_to_int(mode) self.mode = mode self.path = path + @classmethod + def _mode_str_to_int( cls, modestr ): + """ + ``modestr`` + string like 755 or 644 or 100644 - only the last 3 chars will be used + + Returns + String identifying a mode compatible to the mode methods ids of the + stat module regarding the rwx permissions for user, group and other + """ + mode = 0 + for iteration,char in enumerate(reversed(modestr[-3:])): + mode += int(char) << iteration*3 + # END for each char + return mode + @property def basename(self): """ -- cgit v1.2.1