def _genmsg_release_repo():
    return ReleaseRepositorySpecification(
        'genmsg', {
            'url': 'https://github.com/ros-gbp/genmsg-release.git',
            'tags': {
                'release': 'release/melodic/{package}/{version}'
            },
            'version': '0.5.11-0'
        })
def _rospeex_release_repo():
    return ReleaseRepositorySpecification(
        'rospeex', {
            'packages': ['rospeex', 'rospeex_msgs'],
            'tags': {
                'release': 'release/indigo/{package}/{version}'
            },
            'url': 'https://bitbucket.org/rospeex/rospeex-release.git',
            'version': '2.14.7-0'
        })
def _genmsg_release_tarball():
    return ReleaseRepositorySpecification(
        'genmsg', {
            'url':
            'https://github.com/ros-gbp/genmsg-release/archive/release/melodic/genmsg/0.5.16-1.tar.gz',
            'tags': {
                'release':
                '{package}-release-release-melodic-{package}-{version}'
            },
            'version': '0.5.16-1',
            'type': 'tar'
        })
    def _update_rosdistro_entry(self, name, latest_tag, release_branch_name):
        click.echo(click.style(
            f"Updating rosdistro with release of '{name}' as version {latest_tag}",
            fg='yellow'),
                   err=True)
        data = self.internal_distro.repositories[name]
        data.source_repository.version = release_branch_name
        if data.release_repository is None:
            data.release_repository = ReleaseRepositorySpecification(
                name, {
                    'version': latest_tag,
                    'url': data.source_repository.url,
                    'tags': {
                        'release': '{{ version }}'
                    }
                })
        else:
            data.release_repository.version = latest_tag

        self.write_internal_distro()
Exemple #5
0
    def execute(self, rosdistro_repo, repositories):
        super().execute(rosdistro_repo)

        github_client = get_github_client()

        actions = []

        for repo in repositories:
            click.echo(f'Pinning repo {repo} ...', err=True)
            data = self.rosdistro_repo[repo]

            try:
                if data.release_repository.url != data.source_repository.url:
                    click.echo(click.style(
                        "This package relies on a different release repository, needs to be bumped "
                        "manually",
                        fg='yellow'),
                               err=True)
                    continue

            except (KeyError, AttributeError):
                pass

            try:
                source_url = data.source_repository.url
                source_branch = data.source_repository.version
            except (KeyError, AttributeError):
                click.echo(click.style("No source entry found", fg='yellow'),
                           err=True)
                continue

            # TODO(pbovbel) Abstract interface away for github/bitbucket/gitlab
            try:
                repo_name = urlsplit(source_url).path[len('/'):-len('.git')]
                gh_repo = github_client.get_repo(repo_name, lazy=False)
                gh_branch = gh_repo.get_branch(source_branch)

                # Find latest tag on source_branch
                head = gh_branch.commit
                queued = deque([(head, 0)])
                tags = {tag.commit.sha: tag.name for tag in gh_repo.get_tags()}

                # Breadth first search from branch head until we find a tagged commit
                while queued:
                    commit, age = queued.popleft()
                    try:
                        latest_tag = tags[commit.sha]
                        break
                    except KeyError:
                        queued.extend(
                            zip(commit.parents,
                                [age + 1] * len(commit.parents)))
            except github.GithubException as e:
                click.echo(click.style(
                    f'Error processing branch {source_branch}: {e}', fg='red'),
                           err=True)
                continue

            try:
                click.echo(
                    f'Found tag {latest_tag} for on branch {source_branch}, {age} commit(s) behind'
                )
            except NameError:
                click.echo(click.style(
                    f'Unable to find the latest tag on branch {source_branch}',
                    fg='yellow'),
                           err=True)
                continue

            if data.release_repository is None:
                actions.append(f'{repo} ({latest_tag})')
                data.release_repository = ReleaseRepositorySpecification(
                    repo_name, {
                        'version': latest_tag,
                        'url': source_url,
                        'tags': {
                            'release': '{{ version }}'
                        }
                    })
            else:
                actions.append(
                    f'{repo} ({data.release_repository.version} -> {latest_tag})'
                )
                data.release_repository.version = latest_tag

            # TODO(pbovbel) store name of pinner?
            data.status_description = f"Pinned {age} commits behind {source_branch} on {datetime.datetime.now()}"

        self.rosdistro_repo.write_internal_distro('Pinning {}'.format(
            ', '.join(actions)))