use of com.google.copybara.git.GerritOptions in project copybara by google.
the class ModuleSupplier method newOptions.
/**
* Returns a new list of {@link Option}s.
*/
public ImmutableList<Option> newOptions(Supplier<GeneralOptions> generalOptionsSupplier) {
GitOptions gitOptions = new GitOptions(generalOptionsSupplier);
GitDestinationOptions gitDestinationOptions = new GitDestinationOptions(generalOptionsSupplier, gitOptions);
return ImmutableList.of(new FolderDestinationOptions(), new FolderOriginOptions(), gitOptions, new GitOriginOptions(), new GithubPrOriginOptions(), gitDestinationOptions, new GithubOptions(generalOptionsSupplier, gitOptions), new GithubDestinationOptions(), new GerritOptions(generalOptionsSupplier, gitOptions), new GitMirrorOptions(generalOptionsSupplier, gitOptions), new WorkflowOptions());
}
use of com.google.copybara.git.GerritOptions in project copybara by google.
the class GerritApiTest method setUp.
@Before
public void setUp() throws Exception {
OptionsBuilder options = new OptionsBuilder().setWorkdirToRealTempDir().setEnvironment(GitTestUtil.getGitEnv().getEnvironment()).setOutputRootToTmpDir();
credentialsFile = Files.createTempFile("credentials", "test");
Files.write(credentialsFile, "https://user:SECRET@copybara-not-real.com".getBytes(UTF_8));
GitRepository repo = newBareRepo(Files.createTempDirectory("test_repo"), getGitEnv(), /*verbose=*/
true, DEFAULT_TIMEOUT, /*noVerify=*/
false).init().withCredentialHelper("store --file=" + credentialsFile);
httpTransport = new MockHttpTransport() {
@Override
public LowLevelHttpRequest buildRequest(String method, String url) {
String requestString = method + " " + url;
MockLowLevelHttpRequest request = new MockLowLevelHttpRequest();
MockLowLevelHttpResponse response = new MockLowLevelHttpResponse();
request.setResponse(response);
apiCalled = new AtomicBoolean(false);
for (Entry<Predicate<String>, byte[]> entry : requestToResponse.entrySet()) {
if (entry.getKey().test(requestString)) {
apiCalled.set(true);
byte[] content = entry.getValue();
assertWithMessage("'" + method + " " + url + "'").that(content).isNotNull();
if (content.length == 0) {
// No content
response.setStatusCode(204);
return request;
}
response.setContent(content);
return request;
}
}
response.setStatusCode(404);
response.setContent(("NO BASE_URL MATCHED! (Returning 404) REQUEST: " + requestString));
return request;
}
};
GerritOptions gerritOptions = new GerritOptions(options.general, options.git) {
@Override
protected HttpTransport getHttpTransport() {
return httpTransport;
}
@Override
protected GitRepository getCredentialsRepo() {
return repo;
}
};
gerritApi = gerritOptions.newGerritApi(getHost() + "/foo/bar/baz");
}
use of com.google.copybara.git.GerritOptions in project copybara by google.
the class ModuleSupplier method newOptions.
/**
* Returns a new list of {@link Option}s.
*/
protected Options newOptions() {
GeneralOptions generalOptions = new GeneralOptions(environment, fileSystem, console);
GitOptions gitOptions = new GitOptions(generalOptions);
GitDestinationOptions gitDestinationOptions = new GitDestinationOptions(generalOptions, gitOptions);
BuildifierOptions buildifierOptions = new BuildifierOptions();
WorkflowOptions workflowOptions = new WorkflowOptions();
return new Options(ImmutableList.of(generalOptions, buildifierOptions, new BuildozerOptions(generalOptions, buildifierOptions, workflowOptions), new FolderDestinationOptions(), new FolderOriginOptions(), gitOptions, new GitOriginOptions(), new GitHubPrOriginOptions(), gitDestinationOptions, new GitHubOptions(generalOptions, gitOptions), new GitHubDestinationOptions(), new GerritOptions(generalOptions, gitOptions), new GitMirrorOptions(), new HgOptions(generalOptions), new HgOriginOptions(), new PatchingOptions(generalOptions), workflowOptions, new RemoteFileOptions(), new DebugOptions(generalOptions)));
}
Aggregations