Esempio n. 1
0
    def test_mergeNewFile(self):
        package = testhelper.build_and_import_simple_package(
            'foo', '1.0-1', self.source1_repo)

        forked = copy(package)
        forked.changelog_entry(version='1.0-1mom1')
        open(forked.pkg_path + '/debian/new.file', 'w').write('hello')
        forked.build()
        self.target_repo.importPackage(forked)

        package.changelog_entry(version='1.2-1')
        package.create_orig()
        package.build()
        self.source2_repo.importPackage(package)

        target = config.targets()[0]
        testhelper.update_all_distro_sources()
        testhelper.update_all_distro_source_pools()

        our_version = target.distro.findPackage(package.name,
                                                version='1.0-1mom1')[0]
        upstream = target.findSourcePackage(package.name, version='1.2-1')[0]
        base = target.findSourcePackage(package.name, version='1.0-1')[0]

        output_dir = result_dir(target.name, package.name)
        report = produce_merges.produce_merge(target, base, our_version,
                                              upstream, output_dir)
        self.assertEqual(report.result, MergeResult.MERGED)
        self.assertTrue(report.merged_version > upstream.version)
Esempio n. 2
0
    def test_onlyDiffIsChangelog(self):
        package = testhelper.build_and_import_simple_package(
            'foo', '1.0-1', self.source1_repo)

        forked = copy(package)
        forked.changelog_entry(version='1.0-1mom1')
        forked.build()
        self.target_repo.importPackage(forked)

        package.changelog_entry(version='1.2-1')
        package.create_orig()
        package.build()
        self.source2_repo.importPackage(package)

        target = config.targets()[0]
        testhelper.update_all_distro_sources()
        testhelper.update_all_distro_source_pools()

        our_version = target.distro.findPackage(package.name,
                                                version='1.0-1mom1')[0]
        upstream = target.findSourcePackage(package.name, version='1.2-1')[0]
        base = target.findSourcePackage(package.name, version='1.0-1')[0]

        output_dir = result_dir(target.name, package.name)
        report = produce_merges.produce_merge(target, base, our_version,
                                              upstream, output_dir)
        self.assertEqual(report.result, MergeResult.SYNC_THEIRS)
        self.assertEqual(report.merged_version, upstream.version)
Esempio n. 3
0
    def test_multipleOrig(self):
        package = testhelper.TestPackage('foo', '2.0-1')
        os.makedirs(package.pkg_path + '/mydir')
        open(package.pkg_path + '/mydir/mainfile', 'w').write('hello')
        package.create_orig()
        package.create_orig(subdir='mydir')
        package.build()
        self.source1_repo.importPackage(package)

        forked = copy(package)
        forked.changelog_entry(version='2.0-1mom1')
        open(forked.pkg_path + '/debian/new.file', 'w').write('hello')
        forked.build()
        self.target_repo.importPackage(forked)

        package.changelog_entry(version='3.0-1')
        open(package.pkg_path + '/debian/new.file2', 'w').write('another')
        package.create_orig()
        package.create_orig(subdir='mydir')
        package.build()
        self.source2_repo.importPackage(package)

        target = config.targets()[0]
        testhelper.update_all_distro_sources()
        testhelper.update_all_distro_source_pools()

        our_version = target.distro.findPackage(package.name,
                                                version='2.0-1mom1')[0]
        upstream = target.findSourcePackage(package.name, version='3.0-1')[0]
        base = target.findSourcePackage(package.name, version='2.0-1')[0]

        output_dir = result_dir(target.name, package.name)
        report = produce_merges.produce_merge(target, base, our_version,
                                              upstream, output_dir)
        self.assertEqual(report.result, MergeResult.MERGED)
    def test_simpleSync(self):
        foo = th.build_and_import_simple_package('foo', '1.0',
                                                 self.target_repo)

        foo.changelog_entry('2.0')
        foo.build()
        self.source1_repo.importPackage(foo)

        target = config.targets()[0]
        th.update_all_distro_sources()
        th.update_all_distro_source_pools()

        our_version = target.distro.findPackage(foo.name, version='1.0')[0]
        upstream = target.findSourcePackage(foo.name, '2.0')[0]

        output_dir = result_dir(target.name, foo.name)
        report = produce_merge(target, our_version, our_version, upstream,
                               output_dir)
        self.assertEqual(report.result, MergeResult.SYNC_THEIRS)
        self.assertEqual(report.merged_version, upstream.version)

        self.assertEqual(len(report.merged_files), 2)
        tarfiles = [
            x for x in report.merged_files if x.startswith('foo_2.0.tar.')
        ]
        self.assertEqual(len(tarfiles), 1)
        self.assertIn('foo_2.0.dsc', report.merged_files)
def main(options, args):
    logger.debug('Sending email if actions are needed...')

    for target in config.targets(args):
        logger.debug('%r', target)
        d = target.distro

        if not isinstance(d, OBSDistro):
            logger.debug('Skipping %r distro %r: not an OBSDistro', target, d)
            continue

        for pkg in d.packages(target.dist, target.component):
            if options.package and pkg.name not in options.package:
                logger.debug('Skipping package %s: not selected', pkg.name)
                continue

            if pkg.name in target.blacklist:
                logger.debug('Skipping package %s: blacklisted', pkg.name)
                continue

            try:
                output_dir = result_dir(target.name, pkg.name)
                report = read_report(output_dir)
            except ValueError:
                logger.debug('Skipping package %s: unable to read report',
                             pkg.name)
                continue

            if report.result == MergeResult.KEEP_OURS:
                logger.debug('Skipping package %s: result=%s',
                             pkg.name, report.result)
                continue

            if (target.committable
                    and report.result in (MergeResult.MERGED,
                                          MergeResult.SYNC_THEIRS)):
                logger.debug('Skipping package %s: result=%s, would already '
                             'have been committed', pkg.name, report.result)
                continue

            try:
                notify_action_needed(target, output_dir, report)
            except Exception:
                logger.exception('Error processing %s:', pkg.name)
Esempio n. 6
0
    def test_simpleSync(self):
        foo = testhelper.build_and_import_simple_package(
            'foo', '1.0', self.target_repo)

        foo.changelog_entry('2.0')
        foo.build()
        self.source1_repo.importPackage(foo)

        target = config.targets()[0]
        testhelper.update_all_distro_sources()
        testhelper.update_all_distro_source_pools()

        our_version = target.distro.findPackage(foo.name, version='1.0')[0]
        upstream = target.findSourcePackage(foo.name, '2.0')[0]

        output_dir = result_dir(target.name, foo.name)
        report = produce_merges.produce_merge(target, our_version, our_version,
                                              upstream, output_dir)
        self.assertEqual(report.result, MergeResult.SYNC_THEIRS)
        self.assertEqual(report.merged_version, upstream.version)