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();
}
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);
}
}
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);
}
Aggregations