summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/git/repo.py27
-rw-r--r--test/git/test_repo.py4
2 files changed, 16 insertions, 15 deletions
diff --git a/lib/git/repo.py b/lib/git/repo.py
index 8cfc2cad..aff595f1 100644
--- a/lib/git/repo.py
+++ b/lib/git/repo.py
@@ -62,20 +62,19 @@ class Repo(object):
self.git = Git(self.wd)
- @property
- def description(self):
- """
- The project's description. Taken verbatim from GIT_REPO/description
-
- Returns
- str
- """
- try:
- f = open(os.path.join(self.path, 'description'))
- result = f.read()
- return result.rstrip()
- finally:
- f.close()
+ # Description property
+ def _get_description(self):
+ filename = os.path.join(self.path, 'description')
+ return file(filename).read().rstrip()
+
+ def _set_description(self, descr):
+ filename = os.path.join(self.path, 'description')
+ file(filename, 'w').write(descr+'\n')
+
+ description = property(_get_description, _set_description,
+ doc="the project's description")
+ del _get_description
+ del _set_description
@property
def heads(self):
diff --git a/test/git/test_repo.py b/test/git/test_repo.py
index 036ae1e9..29ba463b 100644
--- a/test/git/test_repo.py
+++ b/test/git/test_repo.py
@@ -25,7 +25,9 @@ class TestRepo(object):
Repo("repos/foobar")
def test_description(self):
- assert_equal("Unnamed repository; edit this file to name it for gitweb.", self.repo.description)
+ txt = "Test repository"
+ self.repo.description = txt
+ assert_equal(self.repo.description, txt)
def test_heads_should_return_array_of_head_objects(self):
for head in self.repo.heads: