Search in sources :

Example 1 with GitRepoFactory

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

the class GitRepoTest method setup.

@Before
public void setup() throws IOException {
    TestComponent component = DaggerGitRepoTest_TestComponent.create();
    GitRepoFactory gitRepoFactory = component.getFactory();
    fileUtils = component.getFileUtils();
    repoFolder = Files.createTempDirectory("temp").toAbsolutePath().toString();
    gitRepo = gitRepoFactory.create(repoFolder);
    gitRepo.init();
    repo = gitRepo;
    gitRepo.setUserDataForTesting();
    // We need one commit to make the repo have a master branch.
    fileUtils.writeStringUnchecked("initial commit", fileUtils.joinToAbsolutePath(repoFolder, "initial_commit.txt"));
    initialCommit = repo.commit(repo.getUncommittedFiles(), "Initial commit").getId();
}
Also used : GitRepoFactory(com.google.startupos.common.repo.GitRepoFactory) Before(org.junit.Before)

Example 2 with GitRepoFactory

use of com.google.startupos.common.repo.GitRepoFactory 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 GitRepoFactory

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

the class GithubSyncTool method main.

public static void main(String[] args) throws IOException {
    Flags.parseCurrentPackage(args);
    GitRepoFactory gitRepoFactory = DaggerGithubSyncTool_GitubSyncToolComponent.builder().build().getGitRepoFactory();
    ImmutableMap<String, GitRepo> repoNameToGitRepos = getGitReposMap(repoPaths.get(), gitRepoFactory);
    GithubClient githubClient = new GithubClient(login.get(), password.get());
    GithubSync githubSync = new GithubSync(githubClient, reviewerDiffLink.get());
    githubSync.syncWithGithub(diffNumber.get(), repoNameToGitRepos);
}
Also used : GitRepo(com.google.startupos.common.repo.GitRepo) GitRepoFactory(com.google.startupos.common.repo.GitRepoFactory)

Aggregations

GitRepoFactory (com.google.startupos.common.repo.GitRepoFactory)3 GitRepo (com.google.startupos.common.repo.GitRepo)2 CommonModule (com.google.startupos.common.CommonModule)1 FileUtils (com.google.startupos.common.FileUtils)1 Config (com.google.startupos.tools.reviewer.aa.Protos.Config)1 InitCommand (com.google.startupos.tools.reviewer.aa.commands.InitCommand)1 Module (dagger.Module)1 Provides (dagger.Provides)1 File (java.io.File)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 Named (javax.inject.Named)1 Before (org.junit.Before)1