Merge "Move SubmoduleSectionParser into util/git/ , a separate java_library."

This commit is contained in:
Han-Wen Nienhuys
2018-07-12 13:31:42 +00:00
committed by Gerrit Code Review
6 changed files with 65 additions and 25 deletions

View File

@@ -41,6 +41,7 @@ java_library(
"//java/com/google/gerrit/prettify:server",
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server/ioutil",
"//java/com/google/gerrit/server/util/git",
"//java/com/google/gerrit/util/cli",
"//java/com/google/gerrit/util/ssl",
"//java/org/apache/commons/net",

View File

@@ -23,7 +23,7 @@ import com.google.gerrit.server.config.CanonicalWebUrl;
import com.google.gerrit.server.project.NoSuchProjectException;
import com.google.gerrit.server.submit.MergeOpRepoManager.OpenRepo;
import com.google.gerrit.server.util.RequestId;
import com.google.gerrit.server.util.SubmoduleSectionParser;
import com.google.gerrit.server.util.git.SubmoduleSectionParser;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import java.io.IOException;

View File

@@ -0,0 +1,9 @@
java_library(
name = "git",
srcs = glob(["**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//java/com/google/gerrit/reviewdb:server",
"//lib/jgit/org.eclipse.jgit:jgit",
],
)

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2011 The Android Open Source Project
// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.util;
package com.google.gerrit.server.util.git;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Project;

View File

@@ -0,0 +1,32 @@
load("//tools/bzl:junit.bzl", "junit_tests")
junit_tests(
name = "git_tests",
size = "small",
srcs = glob(
["**/*.java"],
),
visibility = ["//visibility:public"],
deps = [
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server/util/git",
"//java/com/google/gerrit/truth",
"//java/org/eclipse/jgit:server",
"//lib:grappa",
"//lib:gson",
"//lib:guava",
"//lib:guava-retrying",
"//lib:gwtorm",
"//lib:protobuf",
"//lib/auto:auto-value",
"//lib/auto:auto-value-annotations",
"//lib/commons:codec",
"//lib/guice",
"//lib/jgit/org.eclipse.jgit:jgit",
"//lib/jgit/org.eclipse.jgit.junit:junit",
"//lib/truth",
"//lib/truth:truth-java8-extension",
"//lib/truth:truth-proto-extension",
"//proto:cache_java_proto",
],
)

View File

@@ -12,26 +12,24 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.acceptance.git;
package com.google.gerrit.server.util.git;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.Sets;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.SubmoduleSubscription;
import com.google.gerrit.server.util.SubmoduleSectionParser;
import java.util.Set;
import org.eclipse.jgit.lib.Config;
import org.junit.Test;
public class SubmoduleSectionParserIT extends AbstractDaemonTest {
public class SubmoduleSectionParserTest {
private static final String THIS_SERVER = "http://localhost/";
@Test
public void followMasterBranch() throws Exception {
Project.NameKey p = createProject("a");
Project.NameKey p = new Project.NameKey("proj");
Config cfg = new Config();
cfg.fromText(
""
@@ -56,7 +54,7 @@ public class SubmoduleSectionParserIT extends AbstractDaemonTest {
@Test
public void followMatchingBranch() throws Exception {
Project.NameKey p = createProject("a");
Project.NameKey p = new Project.NameKey("a");
Config cfg = new Config();
cfg.fromText(
""
@@ -92,7 +90,7 @@ public class SubmoduleSectionParserIT extends AbstractDaemonTest {
@Test
public void followAnotherBranch() throws Exception {
Project.NameKey p = createProject("a");
Project.NameKey p = new Project.NameKey("a");
Config cfg = new Config();
cfg.fromText(
""
@@ -117,7 +115,7 @@ public class SubmoduleSectionParserIT extends AbstractDaemonTest {
@Test
public void withAnotherURI() throws Exception {
Project.NameKey p = createProject("a");
Project.NameKey p = new Project.NameKey("a");
Config cfg = new Config();
cfg.fromText(
""
@@ -142,7 +140,7 @@ public class SubmoduleSectionParserIT extends AbstractDaemonTest {
@Test
public void withSlashesInProjectName() throws Exception {
Project.NameKey p = createProject("project/with/slashes/a");
Project.NameKey p = new Project.NameKey("project/with/slashes/a");
Config cfg = new Config();
cfg.fromText(
""
@@ -167,7 +165,7 @@ public class SubmoduleSectionParserIT extends AbstractDaemonTest {
@Test
public void withSlashesInPath() throws Exception {
Project.NameKey p = createProject("a");
Project.NameKey p = new Project.NameKey("a");
Config cfg = new Config();
cfg.fromText(
""
@@ -192,8 +190,8 @@ public class SubmoduleSectionParserIT extends AbstractDaemonTest {
@Test
public void withMoreSections() throws Exception {
Project.NameKey p1 = createProject("a");
Project.NameKey p2 = createProject("b");
Project.NameKey p1 = new Project.NameKey("a");
Project.NameKey p2 = new Project.NameKey("b");
Config cfg = new Config();
cfg.fromText(
""
@@ -225,8 +223,8 @@ public class SubmoduleSectionParserIT extends AbstractDaemonTest {
@Test
public void withSubProjectFound() throws Exception {
Project.NameKey p1 = createProject("a/b");
Project.NameKey p2 = createProject("b");
Project.NameKey p1 = new Project.NameKey("a/b");
Project.NameKey p2 = new Project.NameKey("b");
Config cfg = new Config();
cfg.fromText(
"\n"
@@ -258,10 +256,10 @@ public class SubmoduleSectionParserIT extends AbstractDaemonTest {
@Test
public void withAnInvalidSection() throws Exception {
Project.NameKey p1 = createProject("a");
Project.NameKey p2 = createProject("b");
Project.NameKey p3 = createProject("d");
Project.NameKey p4 = createProject("e");
Project.NameKey p1 = new Project.NameKey("a");
Project.NameKey p2 = new Project.NameKey("b");
Project.NameKey p3 = new Project.NameKey("d");
Project.NameKey p4 = new Project.NameKey("e");
Config cfg = new Config();
cfg.fromText(
"\n"
@@ -328,7 +326,7 @@ public class SubmoduleSectionParserIT extends AbstractDaemonTest {
@Test
public void withSectionToOtherServer() throws Exception {
Project.NameKey p1 = createProject("a");
Project.NameKey p1 = new Project.NameKey("a");
Config cfg = new Config();
cfg.fromText(
""
@@ -349,7 +347,7 @@ public class SubmoduleSectionParserIT extends AbstractDaemonTest {
@Test
public void withRelativeURI() throws Exception {
Project.NameKey p1 = createProject("a");
Project.NameKey p1 = new Project.NameKey("a");
Config cfg = new Config();
cfg.fromText(
""
@@ -374,7 +372,7 @@ public class SubmoduleSectionParserIT extends AbstractDaemonTest {
@Test
public void withDeepRelativeURI() throws Exception {
Project.NameKey p1 = createProject("a");
Project.NameKey p1 = new Project.NameKey("a");
Config cfg = new Config();
cfg.fromText(
""
@@ -400,7 +398,7 @@ public class SubmoduleSectionParserIT extends AbstractDaemonTest {
@Test
public void withOverlyDeepRelativeURI() throws Exception {
Project.NameKey p1 = createProject("nested/a");
Project.NameKey p1 = new Project.NameKey("nested/a");
Config cfg = new Config();
cfg.fromText(
""