Exemple #1
0
    def branch(self):
        """Create a branch for all products from a bundle tag."""
        release_tag = self.release_tag
        hash_tag = getHashTag(release_tag)
        bundle_tag_url = computeTagUrl(self.bundle_url, release_tag)
        if not bundle_tag_url:
            logger.error('Invalid source url: %s' % self.bundle_url)
            return -1
        bundle_branch_url = bundle_tag_url.replace('/tags/', '/branches/')
        logger.info('Branching %s -> %s hash_tag: %s.' %
                    (bundle_tag_url, bundle_branch_url, hash_tag))
        ret, output = command('svn ls %s' % bundle_tag_url, do_raise=False)
        if ret:
            logger.error('Tag not found. You need to release %s first.' %
                         release_tag)
            return -1
        ret, output = command('svn ls %s' % bundle_branch_url, do_raise=False)
        if not ret:
            logger.error('Branch %s already exists.' % bundle_branch_url)
            return -1
        products = self.listProducts(bundle_tag_url)
        branch_products = []

        # create a branch for each product
        for product in products:
            product_url = product['url']
            parent = os.path.dirname(product_url)
            ret = -1
            if os.path.basename(parent) == 'tags':
                ret, output = command('svn ls %s/CHANGES' % product_url,
                                      do_raise=False)
            if ret:
                # not a versionned product keep it asis
                branch_products.append(product)
                continue

            branch_url = os.path.dirname(parent) + '/branches/' + hash_tag
            ret, output = command('svn ls %s' % branch_url, do_raise=False)
            if not ret:
                logger.warning('Branch %s already exists.' % branch_url)
            else:
                command('svn copy -m"bundleman branch product %s release %s"'
                        '-r%s %s %s' %
                        (product['path'], hash_tag, product['revision'],
                         product_url, branch_url))
            branch_products.append({'path': product['path'],
                                    'url': branch_url})

        # create a bundle branch
        logger.info('Creating bundle %s' % bundle_branch_url)
        createBundle(bundle_branch_url, branch_products, release_tag)
        return bundle_branch_url
Exemple #2
0
    def tag(self):
        """Create a bundle tags/release_tag."""
        release_tag = self.release_tag
        logger.info('Create a bundle tag %s' % release_tag)

        # check bundle url
        bundle_url = self.bundle_url

        tag_url = computeTagUrl(bundle_url, release_tag)
        if tag_url is None:
            logger.error('Invalid bundle url: %s' % bundle_url)
            return -1
        ret, output = command('svn ls %s' % tag_url, do_raise=False)
        if not ret:
            logger.error('Bundle tag %s already exists.' % tag_url)
            return -1

        # analyze products
        self.analyze(force=True)
        bad_products = []
        products = []
        for product in self.products:
            if product.status != 'use_tag':
                bad_products.append(product)
            products.append({'path': product.rpath,
                             'revision': product.revision,
                             'url': product.tag_url})
        if bad_products:
            logger.warning('Sorry found product(s) not ready:')
            for product in bad_products:
                print str(product)
            return -1

        # create bundle
        logger.info('Creating bundle %s' % tag_url)
        createBundle(tag_url, products, release_tag, bundle_url)
        return 0