Ejemplo n.º 1
0
 def test_changelog_parser(self):
     self.client.update_changelog(self.sample['changelog0'])
     versions = Release.objects.filter(product=self.product)
     indexed = {}
     for v in versions:
         indexed[pversion(v.version)] = v
     self.assertEqual(len(versions), 3)
     self.assertEqual(set(indexed.keys()), set(['1.2.2', '1.2.5', '1.2.6']))
     self.assertEqual(indexed['1.2.6'].datev, None)
     self.assertEqual(indexed['1.2.5'].datev, date(2011, 9, 23))
     self.assertEqual(indexed['1.2.2'].changelog, """* Last version where Products.NaayaSurvey and Products.NaayaWidgets were separate packages""")
Ejemplo n.º 2
0
    def test_changelog_incremental_update(self):
        self.client.update_changelog(self.sample['changelog0'])
        # this throws DoesNotExist / MultipleValues exception unless 1 result
        unreleased = Release.objects.get(product=self.product, datev=None)
        unreleased.obs = 'My personal observations aka extended changelog'
        unreleased.save()

        self.client.update_changelog(self.sample['changelog1'])
        versions = Release.objects.filter(product=self.product)
        indexed = {}
        for v in versions:
            indexed[pversion(v.version)] = v
        self.assertEqual(set(indexed.keys()),
                         set(['1.2.2', '1.2.5', '1.3.0', '1.3.1', '1.3.2']))
        self.assertEqual(indexed['1.3.0'].obs,
                         'My personal observations aka extended changelog')
        self.assertEqual(indexed['1.3.0'].datev, date(2011, 9, 30))
        self.assertEqual(indexed['1.3.0'].changelog,
                         """* Another bugfix that now looks ok
* bugfix: Bugfix in RadioWidget.get_value
* feature: Administrators can now edit answers in expired surveys""")
        self.assertEqual(indexed['1.3.2'].datev, None)
Ejemplo n.º 3
0
    def update_changelog(self, changelog):
        """
        Updates changelog in db for wrapped product
        with given `changelog` multiline string

        """
        docsettings = OptionParser(components=(Parser,),
                                   defaults={'report_level': 4}).get_default_values()
        document = new_document(u'Changelog Document Instance', docsettings)
        parser = Parser()
        parser.parse(changelog, document)
        if not len(document.children):
            raise EmptyChangelog()

        releases = {}
        for block in document.children:
            headline = block[0].astext()
            r_date = self._get_date(headline)
            version = self._get_sortable_version(headline)
            text = ''
            if len(block) == 1:
                # must be unreleased
                assert(r_date is None)
            else:
                # TODO: figure out a better way to get rst of doctree
                entries = block[1].astext().split(block.child_text_separator)
                text = '* ' + '\n* '.join([e.replace('\n', ' ') for e in entries])
            releases[version] = {'datev': r_date, 'changelog': text}

        found_versions = releases.keys()
        found_versions.sort()
        last_released = Release.objects.filter(product=self.product, datev__isnull=False)
        last_released = last_released.order_by('-datev')

        try:
            last_released = last_released[0]
            last_released_version = last_released.version
        except:
            last_released_version = ''
        after_last_released = False

        needs_blame = []
        for version in found_versions:
            # walk versions in new changelog, from oldest to newest
            if after_last_released:
                needs_blame.append(pversion(version))
                # this is unreleased in db, probably totally changed in changelog
                # update 1 on 1, regardless of version
                (unreleased, c) = Release.objects.get_or_create(product=self.product, datev__isnull=True)
                unreleased.version = version
                unreleased.datev = releases[version]['datev']
                unreleased.changelog = releases[version]['changelog']
                unreleased.save()
                after_last_released = False
            else:
                # either exists in db, either totally new
                added = Release_update_or_add(self.product, version,
                                              releases[version]['datev'],
                                              releases[version]['changelog'])
                if added:
                    needs_blame.append(pversion(version))
                if version == last_released_version:
                    after_last_released = True

        self.update_commit_info(needs_blame)
Ejemplo n.º 4
0
 def release(self, obj):
     return pversion(obj.version)