@@ -0,0 +1,2179 @@
+// Copyright (C) 2018 The Android Open Source Project%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A// http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A%0Apackage com.google.gerrit.acceptance.git;%0A%0Aimport com.google.gerrit.acceptance.AbstractDaemonTest;%0Aimport org.eclipse.jgit.api.errors.TransportException;%0Aimport org.eclipse.jgit.junit.TestRepository;%0Aimport org.eclipse.jgit.lib.Config;%0Aimport org.eclipse.jgit.transport.RefSpec;%0Aimport org.junit.Test;%0A%0Apublic class GitmodulesIT extends AbstractDaemonTest %7B%0A  @Test%0A  public void invalidSubmoduleURLIsRejected() throws Exception %7B%0A    pushGitmodules(%22name%22, %22-invalid-url%22, %22path%22, %22Invalid submodule URL%22);%0A  %7D%0A%0A  @Test%0A  public void invalidSubmodulePathIsRejected() throws Exception %7B%0A    pushGitmodules(%22name%22, %22http://somewhere%22, %22-invalid-path%22, %22Invalid submodule path%22);%0A  %7D%0A%0A  @Test%0A  public void invalidSubmoduleNameIsRejected() throws Exception %7B%0A    pushGitmodules(%22-invalid-name%22, %22http://somewhere%22, %22path%22, %22Invalid submodule name%22);%0A  %7D%0A%0A  private void pushGitmodules(String name, String url, String path, String expectedErrorMessage)%0A      throws Exception %7B%0A    Config config = new Config();%0A    config.setString(%22submodule%22, name, %22url%22, url);%0A    config.setString(%22submodule%22, name, %22path%22, path);%0A    TestRepository%3C?%3E repo = cloneProject(project);%0A    repo.branch(%22HEAD%22)%0A        .commit()%0A        .insertChangeId()%0A        .message(%22subject: adding new subscription%22)%0A        .add(%22.gitmodules%22, config.toText().toString())%0A        .create();%0A%0A    exception.expectMessage(expectedErrorMessage);%0A    exception.expect(TransportException.class);%0A    repo.git().push().setRemote(%22origin%22).setRefSpecs(new RefSpec(%22HEAD:refs/for/master%22)).call();%0A  %7D%0A%7D%0A

Add tests for .gitmodules validation