Esempio n. 1
0
def init_git_dependent_config(config: Config, github: GitHub, git_repo: GitRepo):

    while(True):
        config.branch_to_be_released = prompt_enter_value("the name of the branch to be released")
        if(is_valid_branch(config)):
            break

    config.release_version = ""
    version_pattern = re.compile(r'[0-9]\.[0-9]\.[0-9]')
    while(not version_pattern.match(config.release_version)):
        config.release_version = prompt_enter_value("release version number without 'v' in front")

    config.next_version = ""
    while(not version_pattern.match(config.next_version)):
        config.next_version = prompt_enter_value("next version number (after releasing) without 'v' in front")

    config.build_folder = __get_build_folder(config)
    config.build_folder_abs = os.path.join(config.root_path, config.build_folder)
    config.build_artifacts_root_search_path = __get_build_artifacts_root_search_path(config)
    config.cobigenwiki_title_name = __get_cobigenwiki_title_name(config)
    config.tag_name = __get_tag_name(config) + config.release_version
    config.tag_core_name = __get_tag_name_specific_branch(config, config.branch_core)

    if git_repo.exists_tag(config.tag_name):
        log_error("Git tag " + config.tag_name + " already exists. Maybe you entered the wrong release version? Please fix the problem and try again.")
        sys.exit()

    config.issue_label_name = config.tag_name[:-7]

    config.expected_milestone_name = config.tag_name[:-7] + "-v" + config.release_version
    config.expected_core_milestone_name = config.tag_core_name[:-2] + "-v"
    milestone = github.find_release_milestone()
    if milestone:
        log_info("Milestone '"+milestone.title+"' found!")
    else:
        log_error("Milestone not found! Searched for milestone with name '" + config.expected_milestone_name+"'. Aborting...")
        sys.exit()

    while(True):
        github_issue_no: str = prompt_enter_value(
            "release issue number without # prefix in case you already created one or type 'new' to create an issue automatically")
        if github_issue_no == 'new':
            issue_text = "This issue has been automatically created. It serves as a container for all release related commits"
            config.github_issue_no = github.create_issue("Release " + config.expected_milestone_name, body=issue_text, milestone=milestone)
            if not config.github_issue_no:
                log_error("Could not create issue! Aborting...")
                sys.exit()
            else:
                log_info('Successfully created issue #' + str(github_issue_no))
            break
        else:
            try:
                if github.find_issue(int(github_issue_no)):
                    config.github_issue_no = int(github_issue_no)
                    log_info("Issue #" + str(config.github_issue_no) + " found remotely!")
                    break
                else:
                    log_error("Issue with number #" + str(config.github_issue_no) + " not found! Typo?")
            except ValueError:
                log_error("Please enter a number.")
            sys.exit()


#####################################################################

#############################
log_step("Initialization...")
#############################

check_running_in_bash()
exit_if_not_executed_in_ide_environment()

config = Config()
init_non_git_config(config)

git_repo = GitRepo(config)
git_repo.assure_clean_working_copy()

github = GitHub(config)
init_git_dependent_config(config, github, git_repo)

exit_if_origin_is_not_correct(config)

if (config.debug):
    log_debug("Current config:")
    pprint(vars(config))
    if not prompt_yesno_question("[DEBUG] Continue?"):
        sys.exit()

maven = Maven(config, github)
Esempio n. 3
0
def create_git_repo(config: Config):
    git_repo = GitRepo(config)
    try:
        yield git_repo
    finally:
        git_repo.close()