Search in sources :

Example 1 with ReviewerRegistryConfig

use of com.google.startupos.tools.reviewer.RegistryProtos.ReviewerRegistryConfig in project startup-os by google.

the class InitCommand method run.

public boolean run(String basePath, String startuposRepo) {
    if (basePath.isEmpty()) {
        throw new IllegalArgumentException("--base_path must be set");
    }
    try {
        if (!fileUtils.folderEmptyOrNotExists(basePath)) {
            System.out.println("Base folder exists and is not empty");
            return false;
        }
        baseFolderExistedBefore = fileUtils.folderExists(basePath);
        // Create folders
        fileUtils.mkdirs(fileUtils.joinToAbsolutePath(basePath, "head"));
        fileUtils.mkdirs(fileUtils.joinToAbsolutePath(basePath, "ws"));
        fileUtils.mkdirs(fileUtils.joinToAbsolutePath(basePath, "local"));
        fileUtils.mkdirs(fileUtils.joinToAbsolutePath(basePath, "logs"));
        // Write BASE file
        fileUtils.writeString("", fileUtils.joinToAbsolutePath(basePath, BASE_FILENAME));
        if (!startuposRepo.isEmpty()) {
            // Clone StartupOS repo into head:
            cloneRepoIntoHead("startup-os", startuposRepo);
            try {
                ReviewerRegistry registry = (ReviewerRegistry) fileUtils.readPrototxt(fileUtils.joinToAbsolutePath(getRepoPath("startup-os"), GLOBAL_REGISTRY_CONFIG), ReviewerRegistry.newBuilder());
                for (ReviewerRegistryConfig config : registry.getReviewerConfigList()) {
                    // should not clone StartupOS twice
                    if (!config.getConfigRepo().equals(startuposRepo)) {
                        cloneRepoIntoHead(config.getId(), config.getConfigRepo());
                    }
                }
            } catch (IOException e) {
                System.err.println("Error: Did not find global registry config");
            }
        } else {
            System.out.println("Warning: StartupOS repo url is empty. Cloning skipped.");
        }
    } catch (IllegalArgumentException e) {
        System.out.println(e.getMessage());
        System.out.println("Input flags:");
        Flags.printUsage();
        revertChanges();
        return false;
    } catch (Exception e) {
        revertChanges();
        e.printStackTrace();
    }
    return true;
}
Also used : ReviewerRegistry(com.google.startupos.tools.reviewer.RegistryProtos.ReviewerRegistry) ReviewerRegistryConfig(com.google.startupos.tools.reviewer.RegistryProtos.ReviewerRegistryConfig) IOException(java.io.IOException) IOException(java.io.IOException)

Aggregations

ReviewerRegistry (com.google.startupos.tools.reviewer.RegistryProtos.ReviewerRegistry)1 ReviewerRegistryConfig (com.google.startupos.tools.reviewer.RegistryProtos.ReviewerRegistryConfig)1 IOException (java.io.IOException)1