Repository: fedora-infra/bodhi

Issue:
Fix bodhi1 for EPEL-7
There are a bunch of places in the master branch that look to see if the `Release.name.startswith('EL')`, and also assumes the tag will be `el%d`.



Discussion:

Resolving patch:
diff --git a/bodhi/jobs.py b/bodhi/jobs.py
--- a/bodhi/jobs.py
+++ b/bodhi/jobs.py
@@ -232,7 +232,7 @@ def clean_pending_tags():
     koji = get_session()
     for release in Release.select():
         log.info("Finding all stray pending-testing builds...")
-        if release.name.startswith('EL'):
+        if release.name.startswith('E'):
             continue
 
         tag = release.pending_testing_tag
diff --git a/bodhi/model.py b/bodhi/model.py
--- a/bodhi/model.py
+++ b/bodhi/model.py
@@ -76,10 +76,14 @@ class Release(SQLObject):
 
     @property
     def branchname(self):
+        version = self.get_version()
         if self.id_prefix == 'FEDORA-EPEL':
-            return 'el%d' % self.get_version()
+            if version >= 7:
+                return 'epel%d' % version
+            else:
+                return 'el%d' % version
         else:
-            return 'f%d' % self.get_version()
+            return 'f%d' % version
 
     def get_version(self):
         regex = re.compile('\D+(\d+)$')
@@ -92,7 +96,7 @@ def collection_name(self):
 
     @property
     def candidate_tag(self):
-        if self.name.startswith('EL'):  # EPEL Hack.
+        if self.name.startswith('E'):  # EPEL Hack.
             return '%s-testing-candidate' % self.dist_tag
         else:
             return '%s-updates-candidate' % self.dist_tag
@@ -107,7 +111,7 @@ def testing_tag(self):
     def stable_tag(self):
         if self.locked:
             return self.dist_tag
-        if self.name.startswith('EL'):  # EPEL Hack.
+        if self.name.startswith('E'):  # EPEL Hack.
             return self.dist_tag
         else:
             return '%s-updates' % self.dist_tag
@@ -129,16 +133,22 @@ def override_tag(self):
     @property
     def stable_repo(self):
         id = self.name.replace('-', '').lower()
-        if self.name.startswith('EL'):  # EPEL Hack.
-            return '%s-epel' % id
+        if self.name.startswith('E'):  # EPEL Hack.
+            if self.get_version() >= 7:
+                return id
+            else:
+                return '%s-epel' % id
         else:
             return '%s-updates' % id
 
     @property
     def testing_repo(self):
         id = self.name.replace('-', '').lower()
-        if self.name.startswith('EL'):
-            return '%s-epel-testing' % id
+        if self.name.startswith('E'):
+            if self.get_version() >= 7:
+                return '%s-testing' % id
+            else:
+                return '%s-epel-testing' % id
         else:
             return '%s-updates-testing' % id
 
@@ -1493,7 +1503,7 @@ def _default_message(self, update):
                 if build.package.suggest_reboot:
                     reboot = ', then reboot'
                     break
-            if update.release.name.startswith('EL'):
+            if update.release.name.startswith('E'):
                 repo = 'epel-testing'
             message = self.testing_msg % (
                 update.get_title(delim=', '),
diff --git a/bodhi/tools/tagcheck.py b/bodhi/tools/tagcheck.py
--- a/bodhi/tools/tagcheck.py
+++ b/bodhi/tools/tagcheck.py
@@ -25,7 +25,7 @@ def main():
     # Clean up any stray pending tags
     for release in Release.select():
         print "Finding all pending-testing builds..."
-        if release.name.startswith('EL'):
+        if release.name.startswith('E'):
             continue
 
         tag = release.pending_testing_tag


Test patch:
diff --git a/bodhi/tests/test_model.py b/bodhi/tests/test_model.py
--- a/bodhi/tests/test_model.py
+++ b/bodhi/tests/test_model.py
@@ -592,6 +592,15 @@ def test_epel_stable_tag_property(self):
         update.release = self._get_epel_release()
         assert update.release.stable_tag == 'dist-5E-epel'
 
+    def test_epel7_tags(self):
+        el7 = Release(name='EPEL-7', long_name='Fedora EPEL 7',
+                      id_prefix='FEDORA-EPEL', dist_tag='epel7')
+        assert el7.get_version() == 7
+        assert el7.candidate_tag == 'epel7-testing-candidate'
+        assert el7.testing_tag == 'epel7-testing'
+        assert el7.stable_tag == 'epel7'
+        assert el7.stable_repo == 'epel7'
+
     def test_bullets_in_notes(self):
         update = self.get_update(name='foo-1.2.3-4')
         update.notes = u'\xb7'