Ejemplo n.º 1
0
    def check_changes_to_be_released(self):
        """Check which distributions have changes that could need a release"""
        logger.info('')
        msg = 'Check changes to be released'
        logger.info(msg)
        logger.info('-' * len(msg))
        need_a_release = []
        for distribution_path in self.distributions:
            dist_name = distribution_path.split('/')[-1]
            logger.debug(DISTRIBUTION.format(distribution_path))
            repo = Repo(distribution_path)
            remote = repo.remote()

            latest_tag = get_latest_tag(repo, self.branch)
            if latest_tag not in repo.tags:
                # if there is no tag it definitely needs a release
                need_a_release.append(distribution_path)
                self.last_tags[dist_name] = latest_tag
                continue

            self.last_tags[dist_name] = latest_tag
            # get the commit where the latest tag is on
            tag = repo.tags[latest_tag]
            tag_sha = tag.commit.hexsha

            branch_sha = remote.refs[self.branch].commit.hexsha
            if tag_sha != branch_sha:
                # self.branch is ahead of the last tag: needs a release
                need_a_release.append(distribution_path)

        # if nothing is about to be released, do not filter the distributions
        if not self.test:
            self.distributions = need_a_release