Exemplo n.º 1
0
    def _print_line(self, time_diff, sk_issue=None, pub_collection=None):
        """
        Print time differences information.
        """
        pub_issue = pub_collection.first() if pub_collection else None

        pub_link = io.highlight_key(
            issue=pub_issue) if pub_issue else 'Not found'
        sk_link = io.highlight_key(issue=sk_issue) if sk_issue else 'Not found'

        summary = sk_issue.summary if sk_issue else pub_collection.first(
        ).summary

        hours = io.highlight_time(time_diff, prefix='[ ', suffix=' ]', ljust=5)

        click.echo('%s -> %s\t%s %s' % (pub_link.rjust(54), sk_link.ljust(41),
                                        hours, io.truncate_summary(summary)))

        if pub_collection:
            for issue in pub_collection.items[1:]:
                click.echo('%s' % io.highlight_key(issue=issue))
    def do(self, sk_key):
        """
        Doing issue migration from SK jira to PUB by SK key

        :param sk_key:
        :return:
        """
        try:
            sk_issue = self._sk_jira.issue(sk_key)
        except Exception:
            raise Exception('Can\'t find the issue by key: %s' % sk_key)

        pub_issues = self._pub_jira.search_issues(
            "'External issue ID' ~ '%s'" % sk_issue.permalink())

        if pub_issues:
            click.echo('\nThis task has been already migrated to PUB: ')

            for issue in pub_issues:
                click.echo(
                    io.highlight_key(issue=issue) + '\t' +
                    issue.fields.summary)

            if not click.confirm('\nContinue?', default=False):
                return

        click.echo('Beginning of migration %s' %
                   io.highlight_key(issue=sk_issue))

        pub_issue = self.create_pub_issue(sk_issue)
        if pub_issue is None:
            return

        click.echo('Issue was migrated: %s' %
                   io.highlight_key(issue=pub_issue))
        click.echo('Beginning of migration attachments')

        self.migrate_attachments(sk_issue, pub_issue)

        return pub_issue
Exemplo n.º 3
0
    def migrate(self, sk_key):
        """
        Migrates issue from SK to PUB.
        """
        try:
            sk_issue = self._sk_jira.issue(sk_key)
        except Exception:
            io.error('Can\'t find the issue by key: %s' % sk_key)

            return

        pub_issues = self._pub_jira.search_issues(
            "'External issue ID' ~ '%s'" % sk_issue.permalink())

        if pub_issues:
            click.echo('\nThis task has been already migrated to PUB: ')

            for issue in pub_issues:
                click.echo(
                    io.highlight_key(issue=issue) + '\t' +
                    io.truncate_summary(issue.fields.summary))

            if not click.confirm('\nContinue?', default=False):
                return

        click.echo('Beginning of migration %s' %
                   io.highlight_key(issue=sk_issue))

        pub_issue = self.create_pub_issue(sk_issue)
        if pub_issue is None:
            click.echo('Error has occurred')
            return

        click.echo('Issue was migrated: %s' %
                   io.highlight_key(issue=pub_issue))

        self.migrate_attachments(sk_issue, pub_issue)

        return pub_issue
Exemplo n.º 4
0
    def _sync_time(self, items):
        """
        :type issue: IssuesCollection
        """
        for issue, pub_collection, date in items:
            self._sk_helper.remove_worklogs(
                issue.data, issue.worklogs.filter_by_date(date))

            if pub_collection is None:
                continue

            for pub_issue in pub_collection:
                [
                    self._sk_helper.add_worklog(issue.data, worklog)
                    for worklog in pub_issue.worklogs.filter_by_date(date)
                ]

            click.echo('Synchronized %s' % io.highlight_key(issue=issue))