import com.gitblit.Constants.FederationStrategy;\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
+import com.gitblit.models.RepositoryModel;\r
import com.gitblit.models.UserModel;\r
import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.WicketUtils;\r
HttpServletRequest req = servletWebRequest.getHttpServletRequest();\r
return req.getServerName();\r
}\r
+ \r
+ protected String getRepositoryUrl(RepositoryModel repository) {\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append(WicketUtils.getGitblitURL(getRequestCycle().getRequest()));\r
+ sb.append(Constants.GIT_PATH);\r
+ sb.append(repository.name);\r
+ \r
+ // inject username into repository url if authentication is required\r
+ if (repository.accessRestriction.exceeds(AccessRestrictionType.NONE)\r
+ && GitBlitWebSession.get().isLoggedIn()) {\r
+ String username = GitBlitWebSession.get().getUser().username;\r
+ sb.insert(sb.indexOf("://") + 3, username + "@");\r
+ }\r
+ return sb.toString();\r
+ }\r
\r
public void warn(String message, Throwable t) {\r
logger.warn(message, t);\r
import org.apache.wicket.PageParameters;\r
import org.apache.wicket.markup.html.basic.Label;\r
\r
-import com.gitblit.Constants;\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
+import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.utils.ArrayUtils;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.panels.RepositoryUrlPanel;\r
\r
super(params);\r
\r
String repositoryName = WicketUtils.getRepositoryName(params);\r
+ RepositoryModel repository = GitBlit.self().getRepositoryModel(repositoryName);\r
setupPage(repositoryName, getString("gb.emptyRepository"));\r
\r
List<String> repositoryUrls = new ArrayList<String>();\r
\r
if (GitBlit.getBoolean(Keys.git.enableGitServlet, true)) {\r
- StringBuilder sb = new StringBuilder();\r
- sb.append(WicketUtils.getGitblitURL(getRequestCycle().getRequest()));\r
- sb.append(Constants.GIT_PATH);\r
- sb.append(repositoryName);\r
- repositoryUrls.add(sb.toString());\r
+ // add the Gitblit repository url\r
+ repositoryUrls.add(getRepositoryUrl(repository));\r
}\r
repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(repositoryName));\r
\r
+ String primaryUrl = ArrayUtils.isEmpty(repositoryUrls) ? "" : repositoryUrls.get(0);\r
add(new Label("repository", repositoryName));\r
- add(new RepositoryUrlPanel("pushurl", repositoryUrls.get(0)));\r
+ add(new RepositoryUrlPanel("pushurl", primaryUrl));\r
add(new Label("cloneSyntax", MessageFormat.format("git clone {0}", repositoryUrls.get(0))));\r
- add(new Label("remoteSyntax", MessageFormat.format("git remote add gitblit {0}\ngit push gitblit master", repositoryUrls.get(0))));\r
+ add(new Label("remoteSyntax", MessageFormat.format("git remote add gitblit {0}\ngit push gitblit master", primaryUrl)));\r
}\r
}\r
import org.wicketstuff.googlecharts.MarkerType;\r
import org.wicketstuff.googlecharts.ShapeMarker;\r
\r
-import com.gitblit.Constants;\r
-import com.gitblit.Constants.AccessRestrictionType;\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
+import com.gitblit.Constants.AccessRestrictionType;\r
import com.gitblit.models.Metric;\r
import com.gitblit.models.PathModel;\r
import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.utils.ArrayUtils;\r
import com.gitblit.utils.JGitUtils;\r
import com.gitblit.utils.MarkdownUtils;\r
import com.gitblit.utils.StringUtils;\r
default:\r
add(WicketUtils.newClearPixel("accessRestrictionIcon").setVisible(false));\r
}\r
- StringBuilder sb = new StringBuilder();\r
- sb.append(WicketUtils.getGitblitURL(getRequestCycle().getRequest()));\r
- sb.append(Constants.GIT_PATH);\r
- sb.append(repositoryName);\r
- repositoryUrls.add(sb.toString());\r
+ // add the Gitblit repository url\r
+ repositoryUrls.add(getRepositoryUrl(getRepositoryModel()));\r
} else {\r
add(WicketUtils.newClearPixel("accessRestrictionIcon").setVisible(false));\r
}\r
repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(repositoryName));\r
\r
- String primaryUrl = repositoryUrls.remove(0);\r
+ String primaryUrl = ArrayUtils.isEmpty(repositoryUrls) ? "" : repositoryUrls.remove(0);\r
add(new RepositoryUrlPanel("repositoryCloneUrl", primaryUrl));\r
\r
add(new Label("otherUrls", StringUtils.flattenStrings(repositoryUrls, "<br/>"))\r