[damned-lies] Fixed branch exist test when module is created



commit 137744539cdf9e7dc0000f6f2e846e9d40d9b7e8
Author: Claude Paroz <claude 2xlibre net>
Date:   Sat Oct 25 21:58:49 2014 +0200

    Fixed branch exist test when module is created
    
    Fixes bug #739173.

 stats/models.py      |    2 ++
 stats/tests/tests.py |    6 ++++++
 2 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index f66ce4d..a5efcd2 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -527,6 +527,8 @@ class Branch(models.Model):
     def _exists(self):
         """ Determine if branch (self) already exists (i.e. already checked out) on local FS """
         if self.module.vcs_type == 'git':
+            if not os.path.exists(self.co_path()):
+                return False
             command = "git branch | grep %s" % self.name
             status, output, errs = utils.run_shell_command(command, cwd=self.co_path())
             return output != ""
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index 50cf385..d25d724 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -126,6 +126,12 @@ class ModuleTestCase(TestCase):
             self.assertEqual(fr_po_stat.po_url(reduced=True), 
u"/POT/gnome-hello.master/gnome-hello.master.fr.reduced.po")
             self.assertEqual(fr_po_stat.translated(scope='part'), 44)
 
+    def test_branch_exists(self):
+        branch = Branch.objects.get(name='master', module__name='zenity')
+        self.assertFalse(branch._exists())
+        branch = Branch.objects.get(name='master', module__name='gnome-hello')
+        self.assertTrue(branch._exists())
+
     @test_scratchdir
     def test_delete_branch(self):
         """ Deleting the master branch of a git module deletes the checkout dir """


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]