def main(args: argparse.Namespace) -> int:
    """Main entry point."""
    set_log_level(args.verbose)
    pr_info = PullRequestInfo(
        repo="ARMMbed/mbed-targets",
        head_branch=args.head_branch,
        base_branch=args.base_branch,
        subject=args.pr_subject,
        body=args.pr_description,
    )
    try:
        online_boards = Boards.from_online_database()
        if BOARD_DATABASE_PATH.exists():
            offline_boards = Boards.from_offline_database()
            added, removed = get_boards_added_or_removed(
                offline_boards, online_boards)
            if not (added or removed):
                logger.info("No changes to commit. Exiting.")
                return 0

            news_file_path = write_news_file_from_boards(added, removed)
        else:
            news_file_path = create_news_file(
                "Offline board database updated.", NewsType.feature)

        save_board_database(online_boards.json_dump(), BOARD_DATABASE_PATH)
        git_commit_and_push([BOARD_DATABASE_PATH, news_file_path],
                            pr_info.head_branch, pr_info.subject)
        raise_github_pr(pr_info)
        return 0
    except ToolsError as tools_error:
        log_exception(logger, tools_error)
        return 1
Beispiel #2
0
    def test_log_error_with_traceback(self):
        mock_logger = mock.Mock(spec_set=logging.Logger)
        mock_exception = mock.Mock(spec_set=Exception)

        log_exception(mock_logger, mock_exception, True)

        mock_logger.error.assert_called_once_with(mock_exception, exc_info=True)
Beispiel #3
0
def main(args: argparse.Namespace) -> int:
    """Main entry point."""
    set_log_level(args.verbose)
    try:
        online_boards = Boards.from_online_database()
        offline_boards = Boards.from_offline_database()
        result = compare_databases(offline_boards, online_boards)
        if not (result.boards_added or result.boards_removed or result.boards_modified):
            logger.info("No changes to commit. Exiting.")
            return 0

        news_file_text = create_news_file_text_from_result(result)
        create_news_file(news_file_text, NewsType.feature)
        save_board_database(online_boards.json_dump(), BOARD_DATABASE_PATH)
        return 0
    except ToolsError as tools_error:
        log_exception(logger, tools_error)
        return 1