<commit_before>package org.shipkit.internal.gradle;

import org.gradle.api.DefaultTask;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
import org.gradle.api.tasks.TaskAction;
import org.shipkit.internal.notes.vcs.GitOriginRepoProvider;
import org.shipkit.internal.exec.DefaultProcessRunner;
import org.shipkit.internal.exec.ProcessRunner;
import org.shipkit.internal.notes.util.IOUtil;
import org.shipkit.internal.util.ExposedForTesting;

import java.io.File;

public class InitConfigFileTask extends DefaultTask{

    private static final Logger LOG = Logging.getLogger(InitConfigFileTask.class);

    private File configFile;
    private GitOriginRepoProvider gitOriginRepoProvider;
    public static final String FALLBACK_GITHUB_REPO = "mockito/mockito-release-tools-example";

    public InitConfigFileTask(){
        ProcessRunner runner = new DefaultProcessRunner(getProject().getProjectDir());
        gitOriginRepoProvider = new GitOriginRepoProvider(runner);
    }

    @TaskAction public void initShipkitConfigFile(){
        if(configFile.exists()){
            LOG.lifecycle("  Shipkit configuration already exists, nothing to do. Configuration file: {}", configFile.getPath());
        } else{
            createShipKitConfigFile();
            LOG.lifecycle("  Shipkit configuration created! Please review before committing: ", configFile.getPath());
        }
    }

    private void createShipKitConfigFile() {
        String defaultGitRepo = getOriginGitRepo();
        String content =
                new TemplateResolver(DEFAULT_SHIPKIT_CONFIG_FILE_CONTENT)
                        .withProperty("gitHub.repository", defaultGitRepo)
                        .withProperty("gitHub.writeAuthUser", "shipkit")
                        .withProperty("gitHub.readOnlyAuthToken", "e7fe8fcfd6ffedac384c8c4c71b2a48e646ed1ab")

                        .withProperty("bintray.pkg.repo", "examples")
                        .withProperty("bintray.pkg.user", "szczepiq")
                        .withProperty("bintray.pkg.userOrg", "shipkit")
                        .withProperty("bintray.pkg.name", "basic")
                        .withProperty("bintray.pkg.licenses", "['MIT']")
                        .withProperty("bintray.pkg.labels", "['continuous delivery', 'release automation', 'mockito']")

                        .resolve();

        IOUtil.writeFile(configFile, content);
    }

    private String getOriginGitRepo() {<commit_msg>InitConfig task logging improved<commit_after>package org.shipkit.internal.gradle;

import org.gradle.api.DefaultTask;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
import org.gradle.api.tasks.TaskAction;
import org.shipkit.internal.notes.vcs.GitOriginRepoProvider;
import org.shipkit.internal.exec.DefaultProcessRunner;
import org.shipkit.internal.exec.ProcessRunner;
import org.shipkit.internal.notes.util.IOUtil;
import org.shipkit.internal.util.ExposedForTesting;

import java.io.File;

public class InitConfigFileTask extends DefaultTask{

    private static final Logger LOG = Logging.getLogger(InitConfigFileTask.class);

    private File configFile;
    private GitOriginRepoProvider gitOriginRepoProvider;
    public static final String FALLBACK_GITHUB_REPO = "mockito/mockito-release-tools-example";

    public InitConfigFileTask(){
        ProcessRunner runner = new DefaultProcessRunner(getProject().getProjectDir());
        gitOriginRepoProvider = new GitOriginRepoProvider(runner);
    }

    @TaskAction public void initShipkitConfigFile(){
        if(configFile.exists()){
            LOG.lifecycle("  Shipkit configuration already exists, nothing to do. Configuration file: {}", configFile.getPath());
        } else{
            createShipKitConfigFile();
            LOG.lifecycle("  Shipkit configuration created at {}! You can modify it manually. Remember to check it into VCS!", configFile.getPath());
        }
    }

    private void createShipKitConfigFile() {
        String defaultGitRepo = getOriginGitRepo();
        String content =
                new TemplateResolver(DEFAULT_SHIPKIT_CONFIG_FILE_CONTENT)
                        .withProperty("gitHub.repository", defaultGitRepo)
                        .withProperty("gitHub.writeAuthUser", "shipkit")
                        .withProperty("gitHub.readOnlyAuthToken", "<PASSWORD>8c4c71b2a48e646ed1ab")

                        .withProperty("bintray.pkg.repo", "examples")
                        .withProperty("bintray.pkg.user", "szczepiq")
                        .withProperty("bintray.pkg.userOrg", "shipkit")
                        .withProperty("bintray.pkg.name", "basic")
                        .withProperty("bintray.pkg.licenses", "['MIT']")
                        .withProperty("bintray.pkg.labels", "['continuous delivery', 'release automation', 'mockito']")

                        .resolve();

        IOUtil.writeFile(configFile, content);
    }

    private String getOriginGitRepo() {
{'fraction_non_alphanumeric': 0.10331734612310152, 'fraction_numerical': 0.005595523581135092, 'mean_word_length': 2.9440504334121353, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6440494', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1343, 'n_words': 249}