Implement a redirector for gitweb-style URLs.

Add a filter to the host index chain to redirect in the presence of
gitweb-style query parameters. Only handles gitweb URLs using the query
parameter flavor; see gitweb(1) for details.

The intent of this filter is to provide compatibility for preexisting
links to old gitweb URLs to be migrated to Gitiles; of course Gitiles
itself does not create such URLs. For this reason, use HTTP 301 (Moved
Permanently) for the redirect rather than 302 Found.

Include simple but not exhaustive tests; the code block in question is
far more concise than exhaustive tests would be.

Change-Id: Ief7022b7cd419fc0380992071ad6e4a4428a6169
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/TestGitilesAccess.java b/gitiles-servlet/src/test/java/com/google/gitiles/TestGitilesAccess.java
index 0b31e24..b9607ae 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/TestGitilesAccess.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/TestGitilesAccess.java
@@ -16,6 +16,8 @@
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import com.google.common.collect.ImmutableMap;
+
 import org.eclipse.jgit.storage.dfs.DfsRepository;
 
 import java.util.Map;
@@ -36,9 +38,13 @@
     return new GitilesAccess() {
       @Override
       public Map<String, RepositoryDescription> listRepositories(Set<String> branches) {
-        // TODO(dborowitz): Implement this, using the DfsRepositoryDescriptions to
-        // get the repository names.
-        throw new UnsupportedOperationException();
+        if (branches != null && !branches.isEmpty()) {
+          throw new UnsupportedOperationException("branches set not yet supported");
+        }
+        RepositoryDescription desc = new RepositoryDescription();
+        desc.name = repo.getDescription().getRepositoryName();
+        desc.cloneUrl = TestGitilesUrls.URLS.getBaseGitUrl(req) + "/" + desc.name;
+        return ImmutableMap.of(desc.name, desc);
       }
 
       @Override