Search in sources :

Example 1 with FileUtils

use of com.google.startupos.common.FileUtils in project startup-os by google.

the class HttpArchiveDepsTool method main.

public static void main(String[] args) throws IOException {
    Flags.parseCurrentPackage(args);
    HttpArchiveDepsTool.HttpArchiveDepsToolComponent component = DaggerHttpArchiveDepsTool_HttpArchiveDepsToolComponent.create();
    FileUtils fileUtils = component.getFileUtils();
    WorkspaceFile workspaceFile = component.getWorkspaceParser().getWorkspaceFile();
    HttpArchiveDepsList httpArchiveDepsList = component.getHttpArchiveDepsGenerator().getHttpArchiveDeps(workspaceFile, httpArchiveNames.get());
    if (!httpArchiveDepsList.getHttpArchiveDepsList().isEmpty()) {
        new HttpArchiveDepsTool().write(fileUtils, httpArchiveDepsList, fileUtils.joinPaths(fileUtils.getCurrentWorkingDirectory(), HttpArchiveDepsGenerator.HTTP_ARCHIVE_DEPS_FILENAME));
    }
}
Also used : FileUtils(com.google.startupos.common.FileUtils) WorkspaceFile(com.google.startupos.tools.build_file_generator.Protos.WorkspaceFile) HttpArchiveDepsList(com.google.startupos.tools.build_file_generator.Protos.HttpArchiveDepsList)

Example 2 with FileUtils

use of com.google.startupos.common.FileUtils in project startup-os by google.

the class AaModule method diffNumber.

@Provides
@Named("Diff number")
public static Integer diffNumber(FileUtils fileUtils, @Named("Workspace path") String workspacePath, GitRepoFactory gitRepoFactory) {
    try {
        String firstWorkspacePath = fileUtils.listContents(workspacePath).stream().map(path -> fileUtils.joinToAbsolutePath(workspacePath, path)).filter(fileUtils::folderExists).findFirst().orElse(null);
        if (firstWorkspacePath == null) {
            throw new RuntimeException(String.format("There are no repositories in workspace %s", workspacePath));
        }
        GitRepo repo = gitRepoFactory.create(firstWorkspacePath);
        return repo.listBranches().stream().filter(branchName -> branchName.startsWith("D")).mapToInt(branchName -> safeParsePositiveInt(branchName.replace("D", ""))).filter(number -> number > 0).findFirst().orElse(-1);
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
Also used : FileUtils(com.google.startupos.common.FileUtils) IOException(java.io.IOException) File(java.io.File) CommonModule(com.google.startupos.common.CommonModule) GitRepoFactory(com.google.startupos.common.repo.GitRepoFactory) Module(dagger.Module) Paths(java.nio.file.Paths) Config(com.google.startupos.tools.reviewer.aa.Protos.Config) GitRepo(com.google.startupos.common.repo.GitRepo) InitCommand(com.google.startupos.tools.reviewer.aa.commands.InitCommand) Named(javax.inject.Named) Path(java.nio.file.Path) Provides(dagger.Provides) GitRepo(com.google.startupos.common.repo.GitRepo) IOException(java.io.IOException) Named(javax.inject.Named) Provides(dagger.Provides)

Example 3 with FileUtils

use of com.google.startupos.common.FileUtils in project startup-os by google.

the class ThirdPartyDepsTool method main.

public static void main(String[] args) throws IOException {
    Flags.parseCurrentPackage(args);
    ThirdPartyDepsToolComponent component = DaggerThirdPartyDepsTool_ThirdPartyDepsToolComponent.create();
    FileUtils fileUtils = component.getFileUtils();
    fileUtils.writePrototxtToZip(component.getThirdPartyDepsAnalyzer().getThirdPartyDeps(buildFilePath.get()), fileUtils.joinPaths(fileUtils.getCurrentWorkingDirectory(), PATH_TO_ZIP), PROTOTXT_FILENAME_INSIDE_ZIP);
}
Also used : FileUtils(com.google.startupos.common.FileUtils)

Example 4 with FileUtils

use of com.google.startupos.common.FileUtils in project startup-os by google.

the class CodeReviewServiceTextDiffTest method setup.

@Before
public void setup() throws IOException {
    Flags.parse(new String[0], AuthService.class.getPackage(), CodeReviewService.class.getPackage());
    String testFolder = Files.createTempDirectory("temp").toAbsolutePath().toString();
    final String initialRepoFolder = joinToAbsolutePath(testFolder, "initial_repo");
    aaBaseFolder = joinToAbsolutePath(testFolder, "base_folder");
    component = DaggerCodeReviewServiceTextDiffTest_TestComponent.builder().aaModule(new AaModule() {

        @Provides
        @Singleton
        @Override
        @Named("Base path")
        public String provideBasePath(FileUtils fileUtils) {
            return aaBaseFolder;
        }
    }).build();
    gitRepoFactory = component.getGitRepoFactory();
    fileUtils = component.getFileUtils();
    codeReviewService = new CodeReviewService(component.getAuthService(), fileUtils, aaBaseFolder, gitRepoFactory, component.getTextDifferencer());
    createInitialRepo(initialRepoFolder);
    initAaBase(initialRepoFolder, aaBaseFolder);
    createAaWorkspace(TEST_WORKSPACE);
    createBlockingStub();
    writeFile(TEST_FILE_CONTENTS);
    testFileCommitId = repo.commit(repo.getUncommittedFiles(), COMMIT_MESSAGE).getId();
}
Also used : Named(javax.inject.Named) AaModule(com.google.startupos.tools.reviewer.aa.AaModule) FileUtils(com.google.startupos.common.FileUtils) Singleton(javax.inject.Singleton) AuthService(com.google.startupos.tools.reviewer.local_server.service.AuthService) CodeReviewService(com.google.startupos.tools.reviewer.local_server.service.CodeReviewService) Provides(dagger.Provides) Before(org.junit.Before)

Example 5 with FileUtils

use of com.google.startupos.common.FileUtils in project startup-os by google.

the class CodeReviewServiceGetDiffFilesTest method setup.

@Before
public void setup() throws IOException {
    Flags.parse(new String[0], AuthService.class.getPackage(), CodeReviewService.class.getPackage());
    component = DaggerCodeReviewServiceGetDiffFilesTest_TestComponent.builder().aaModule(new AaModule() {

        @Provides
        @Singleton
        @Override
        @Named("Base path")
        public String provideBasePath(FileUtils fileUtils) {
            return aaBaseFolder;
        }
    }).build();
    gitRepoFactory = component.getGitRepoFactory();
    fileUtils = component.getFileUtils();
    String testFolder = Files.createTempDirectory("temp").toAbsolutePath().toString();
    String initialRepoFolder = fileUtils.joinToAbsolutePath(testFolder, "initial_repo");
    aaBaseFolder = fileUtils.joinToAbsolutePath(testFolder, "base_folder");
    codeReviewService = new CodeReviewService(component.getAuthService(), fileUtils, aaBaseFolder, gitRepoFactory, component.getTextDifferencer());
    createInitialRepo(initialRepoFolder);
    initAaBase(initialRepoFolder, aaBaseFolder);
    createAaWorkspace(TEST_WORKSPACE);
    createBlockingStub();
    writeFile(TEST_FILE_CONTENTS);
    testFileCommitId = repo.commit(repo.getUncommittedFiles(), COMMIT_MESSAGE).getId();
    mockFirestoreClientMethods();
}
Also used : Named(javax.inject.Named) AaModule(com.google.startupos.tools.reviewer.aa.AaModule) FileUtils(com.google.startupos.common.FileUtils) Singleton(javax.inject.Singleton) AuthService(com.google.startupos.tools.reviewer.local_server.service.AuthService) CodeReviewService(com.google.startupos.tools.reviewer.local_server.service.CodeReviewService) Provides(dagger.Provides) Before(org.junit.Before)

Aggregations

FileUtils (com.google.startupos.common.FileUtils)8 Provides (dagger.Provides)4 Named (javax.inject.Named)4 AaModule (com.google.startupos.tools.reviewer.aa.AaModule)3 Singleton (javax.inject.Singleton)3 Before (org.junit.Before)3 CommonModule (com.google.startupos.common.CommonModule)2 GitRepo (com.google.startupos.common.repo.GitRepo)2 GitRepoFactory (com.google.startupos.common.repo.GitRepoFactory)2 AuthService (com.google.startupos.tools.reviewer.local_server.service.AuthService)2 CodeReviewService (com.google.startupos.tools.reviewer.local_server.service.CodeReviewService)2 Paths (java.nio.file.Paths)2 ImmutableList (com.google.common.collect.ImmutableList)1 Flag (com.google.startupos.common.flags.Flag)1 FlagDesc (com.google.startupos.common.flags.FlagDesc)1 Flags (com.google.startupos.common.flags.Flags)1 HttpArchiveDepsList (com.google.startupos.tools.build_file_generator.Protos.HttpArchiveDepsList)1 WorkspaceFile (com.google.startupos.tools.build_file_generator.Protos.WorkspaceFile)1 ReviewerProtos (com.google.startupos.tools.reviewer.ReviewerProtos)1 ReviewerConfig (com.google.startupos.tools.reviewer.ReviewerProtos.ReviewerConfig)1