Commits

Sebastian Sdorra committed f9ef508

fix a bug with gitconfig reference, see #29

  • Participants
  • Parent commits 5c56a1a

Comments (0)

Files changed (2)

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

 import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
 import org.eclipse.jgit.util.FS;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import sonia.scm.repository.GitConfig;
+import sonia.scm.repository.GitRepositoryHandler;
 
 //~--- JDK imports ------------------------------------------------------------
 
         implements RepositoryResolver<HttpServletRequest>
 {
 
+  /** the logger for GitRepositoryResolver */
+  private static final Logger logger =
+    LoggerFactory.getLogger(GitRepositoryResolver.class);
+
+  //~--- constructors ---------------------------------------------------------
+
   /**
    * Constructs ...
    *
    *
-   * @param config
+   *
+   * @param handler
    */
-  public GitRepositoryResolver(GitConfig config)
+  public GitRepositoryResolver(GitRepositoryHandler handler)
   {
-    this.config = config;
+    this.handler = handler;
   }
 
   //~--- get methods ----------------------------------------------------------
 
     try
     {
-      File gitdir = new File(config.getRepositoryDirectory(), repositoryName);
+      GitConfig config = handler.getConfig();
 
-      if (!gitdir.exists())
+      if (config.isValid())
       {
-        throw new RepositoryNotFoundException(repositoryName);
+        File gitdir = new File(config.getRepositoryDirectory(), repositoryName);
+
+        if (logger.isDebugEnabled())
+        {
+          logger.debug("try to open git repository at {}", gitdir);
+        }
+
+        if (!gitdir.exists())
+        {
+          throw new RepositoryNotFoundException(repositoryName);
+        }
+
+        repository = RepositoryCache.open(FileKey.lenient(gitdir, FS.DETECTED),
+                                          true);
       }
-
-      repository = RepositoryCache.open(FileKey.lenient(gitdir, FS.DETECTED),
-                                        true);
     }
     catch (RuntimeException e)
     {
   //~--- fields ---------------------------------------------------------------
 
   /** Field description */
-  private GitConfig config;
+  private GitRepositoryHandler handler;
 }

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

   @Inject
   public ScmGitServlet(GitRepositoryHandler handler)
   {
-    resolver = new GitRepositoryResolver(handler.getConfig());
+    resolver = new GitRepositoryResolver(handler);
     setRepositoryResolver(resolver);
   }