Search in sources :

Example 1 with GerritOptions

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());
}
Also used : FolderDestinationOptions(com.google.copybara.folder.FolderDestinationOptions) GerritOptions(com.google.copybara.git.GerritOptions) GithubOptions(com.google.copybara.git.GithubOptions) GithubDestinationOptions(com.google.copybara.git.GithubDestinationOptions) GitMirrorOptions(com.google.copybara.git.GitMirrorOptions) GithubPrOriginOptions(com.google.copybara.git.GithubPrOriginOptions) GitOptions(com.google.copybara.git.GitOptions) GitDestinationOptions(com.google.copybara.git.GitDestinationOptions) FolderOriginOptions(com.google.copybara.folder.FolderOriginOptions) GitOriginOptions(com.google.copybara.git.GitOriginOptions)

Example 2 with GerritOptions

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");
}
Also used : GitRepository(com.google.copybara.git.GitRepository) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Entry(java.util.Map.Entry) MockHttpTransport(com.google.api.client.testing.http.MockHttpTransport) MockLowLevelHttpResponse(com.google.api.client.testing.http.MockLowLevelHttpResponse) LowLevelHttpRequest(com.google.api.client.http.LowLevelHttpRequest) MockLowLevelHttpRequest(com.google.api.client.testing.http.MockLowLevelHttpRequest) GerritOptions(com.google.copybara.git.GerritOptions) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) MockLowLevelHttpRequest(com.google.api.client.testing.http.MockLowLevelHttpRequest) Before(org.junit.Before)

Example 3 with GerritOptions

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)));
}
Also used : GitMirrorOptions(com.google.copybara.git.GitMirrorOptions) HgOriginOptions(com.google.copybara.hg.HgOriginOptions) HgOptions(com.google.copybara.hg.HgOptions) GitHubOptions(com.google.copybara.git.GitHubOptions) GitHubPrOriginOptions(com.google.copybara.git.GitHubPrOriginOptions) GitHubDestinationOptions(com.google.copybara.git.GitHubDestinationOptions) PatchingOptions(com.google.copybara.transform.patch.PatchingOptions) FolderOriginOptions(com.google.copybara.folder.FolderOriginOptions) DebugOptions(com.google.copybara.transform.debug.DebugOptions) BuildozerOptions(com.google.copybara.buildozer.BuildozerOptions) BuildifierOptions(com.google.copybara.format.BuildifierOptions) GitOptions(com.google.copybara.git.GitOptions) FolderDestinationOptions(com.google.copybara.folder.FolderDestinationOptions) GitDestinationOptions(com.google.copybara.git.GitDestinationOptions) GitOriginOptions(com.google.copybara.git.GitOriginOptions) RemoteFileOptions(com.google.copybara.remotefile.RemoteFileOptions) GerritOptions(com.google.copybara.git.GerritOptions) RemoteFileOptions(com.google.copybara.remotefile.RemoteFileOptions) BuildifierOptions(com.google.copybara.format.BuildifierOptions) GerritOptions(com.google.copybara.git.GerritOptions) HgOptions(com.google.copybara.hg.HgOptions) BuildozerOptions(com.google.copybara.buildozer.BuildozerOptions) FolderOriginOptions(com.google.copybara.folder.FolderOriginOptions) DebugOptions(com.google.copybara.transform.debug.DebugOptions) GitOriginOptions(com.google.copybara.git.GitOriginOptions) GitHubOptions(com.google.copybara.git.GitHubOptions) PatchingOptions(com.google.copybara.transform.patch.PatchingOptions) HgOriginOptions(com.google.copybara.hg.HgOriginOptions) FolderDestinationOptions(com.google.copybara.folder.FolderDestinationOptions) GitMirrorOptions(com.google.copybara.git.GitMirrorOptions) GitOptions(com.google.copybara.git.GitOptions) GitDestinationOptions(com.google.copybara.git.GitDestinationOptions) GitHubPrOriginOptions(com.google.copybara.git.GitHubPrOriginOptions) GitHubDestinationOptions(com.google.copybara.git.GitHubDestinationOptions)

Aggregations

GerritOptions (com.google.copybara.git.GerritOptions)3 FolderDestinationOptions (com.google.copybara.folder.FolderDestinationOptions)2 FolderOriginOptions (com.google.copybara.folder.FolderOriginOptions)2 GitDestinationOptions (com.google.copybara.git.GitDestinationOptions)2 GitMirrorOptions (com.google.copybara.git.GitMirrorOptions)2 GitOptions (com.google.copybara.git.GitOptions)2 GitOriginOptions (com.google.copybara.git.GitOriginOptions)2 LowLevelHttpRequest (com.google.api.client.http.LowLevelHttpRequest)1 MockHttpTransport (com.google.api.client.testing.http.MockHttpTransport)1 MockLowLevelHttpRequest (com.google.api.client.testing.http.MockLowLevelHttpRequest)1 MockLowLevelHttpResponse (com.google.api.client.testing.http.MockLowLevelHttpResponse)1 BuildozerOptions (com.google.copybara.buildozer.BuildozerOptions)1 BuildifierOptions (com.google.copybara.format.BuildifierOptions)1 GitHubDestinationOptions (com.google.copybara.git.GitHubDestinationOptions)1 GitHubOptions (com.google.copybara.git.GitHubOptions)1 GitHubPrOriginOptions (com.google.copybara.git.GitHubPrOriginOptions)1 GitRepository (com.google.copybara.git.GitRepository)1 GithubDestinationOptions (com.google.copybara.git.GithubDestinationOptions)1 GithubOptions (com.google.copybara.git.GithubOptions)1 GithubPrOriginOptions (com.google.copybara.git.GithubPrOriginOptions)1