Commits

Sebastian Sdorra committed 7781717

fix wrong commit and source url on git repositories with reverse proxy, see issue #483

Comments (0)

Files changed (1)

scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitRepositoryViewer.java

 import com.google.common.collect.Iterables;
 import com.google.common.io.Closeables;
 import com.google.inject.Inject;
-import com.google.inject.name.Named;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import sonia.scm.config.ScmConfiguration;
 import sonia.scm.repository.Branch;
 import sonia.scm.repository.Branches;
 import sonia.scm.repository.Changeset;
 import sonia.scm.url.RepositoryUrlProvider;
 import sonia.scm.url.UrlProvider;
 import sonia.scm.url.UrlProviderFactory;
-import sonia.scm.util.HttpUtil;
 import sonia.scm.util.Util;
 
 //~--- JDK imports ------------------------------------------------------------
    *
    * @param templateEngineFactory
    * @param repositoryServiceFactory
+   * @param configuration
    */
   @Inject
   public GitRepositoryViewer(TemplateEngineFactory templateEngineFactory,
-    RepositoryServiceFactory repositoryServiceFactory)
+    RepositoryServiceFactory repositoryServiceFactory,
+    ScmConfiguration configuration)
   {
     this.templateEngineFactory = templateEngineFactory;
     this.repositoryServiceFactory = repositoryServiceFactory;
+    this.configuration = configuration;
   }
 
   //~--- methods --------------------------------------------------------------
     throws RepositoryException, IOException
   {
 
-    String baseUrl = HttpUtil.getCompleteUrl(request);
+    String baseUrl = configuration.getBaseUrl();
 
     UrlProvider urlProvider = UrlProviderFactory.createUrlProvider(baseUrl,
                                 UrlProviderFactory.TYPE_WUI);
     //~--- fields -------------------------------------------------------------
 
     /** Field description */
-    private Iterable<ChangesetModel> changesets;
+    private final Iterable<ChangesetModel> changesets;
 
     /** Field description */
-    private String name;
+    private final String name;
   }
 
 
     //~--- fields -------------------------------------------------------------
 
     /** Field description */
-    private RepositoryService service;
+    private final RepositoryService service;
   }
 
 
     //~--- fields -------------------------------------------------------------
 
     /** Field description */
-    private Iterable<BranchModel> branches;
+    private final Iterable<BranchModel> branches;
   }
 
 
     //~--- fields -------------------------------------------------------------
 
     /** Field description */
-    private Changeset changeset;
+    private final Changeset changeset;
   }
 
 
   //~--- fields ---------------------------------------------------------------
 
   /** Field description */
-  private RepositoryServiceFactory repositoryServiceFactory;
+  private final ScmConfiguration configuration;
 
   /** Field description */
-  private TemplateEngineFactory templateEngineFactory;
+  private final RepositoryServiceFactory repositoryServiceFactory;
+
+  /** Field description */
+  private final TemplateEngineFactory templateEngineFactory;
 }