}\r
\r
public static String getJGitVersion() {\r
- return "JGit 0.11.3";\r
+ return "JGit 0.12-stable";\r
}\r
\r
public static String getRunningVersion() {\r
r = repositoryResolver.open(null, repositoryName);\r
} catch (RepositoryNotFoundException e) {\r
r = null;\r
- logger.error("Failed to find repository " + repositoryName);\r
- e.printStackTrace();\r
+ logger.error("GitBlit.getRepository(String) failed to find repository " + repositoryName);\r
} catch (ServiceNotEnabledException e) {\r
r = null;\r
e.printStackTrace();\r
Repository r = getRepository(repositoryName);\r
RepositoryModel model = new RepositoryModel();\r
model.name = repositoryName;\r
+ model.hasCommits = JGitUtils.hasCommits(r);\r
model.lastChange = JGitUtils.getLastChange(r);\r
StoredConfig config = JGitUtils.readConfig(r);\r
if (config != null) {\r
public static final String R_NOTES_COMMITS = R_NOTES + "commits";\r
\r
private final static Logger LOGGER = LoggerFactory.getLogger(JGitUtils.class);\r
- \r
+\r
public static Repository createRepository(File repositoriesFolder, String name, boolean bare) {\r
Git git = Git.init().setDirectory(new File(repositoriesFolder, name)).setBare(bare).call();\r
return git.getRepository();\r
// first look for standard folder/.git structure\r
File gitFolder = new File(file, Constants.DOT_GIT);\r
boolean isGitRepository = gitFolder.exists() && gitFolder.isDirectory();\r
- \r
- // then look for folder.git/HEAD or folder/HEAD and folder/config\r
+\r
+ // then look for folder.git/HEAD or folder/HEAD and\r
+ // folder/config\r
if (!isGitRepository) {\r
- if ((file.getName().endsWith(Constants.DOT_GIT_EXT) && new File(file, Constants.HEAD).exists())\r
- || (new File(file, "config").exists() && new File(file, Constants.HEAD).exists())) {\r
+ if ((file.getName().endsWith(Constants.DOT_GIT_EXT) && new File(file, Constants.HEAD).exists()) || (new File(file, "config").exists() && new File(file, Constants.HEAD).exists())) {\r
gitFolder = file;\r
isGitRepository = true;\r
}\r
}\r
\r
public static RevCommit getFirstCommit(Repository r, String branch) {\r
+ if (!hasCommits(r)) {\r
+ return null;\r
+ }\r
if (StringUtils.isEmpty(branch)) {\r
branch = Constants.HEAD;\r
}\r
RevCommit commit = getFirstCommit(r, branch);\r
if (commit == null) {\r
// fresh repository\r
- return new Date(r.getDirectory().lastModified()); \r
+ return new Date(r.getDirectory().lastModified());\r
}\r
return getCommitDate(commit);\r
} catch (Throwable t) {\r
return null;\r
}\r
\r
- public static Date getLastChange(Repository r) { \r
- RevCommit commit = getCommit(r, Constants.HEAD);\r
- if (commit == null) {\r
+ public static boolean hasCommits(Repository r) {\r
+ return new File(r.getDirectory(), Constants.R_HEADS).list().length > 0;\r
+ }\r
+\r
+ public static Date getLastChange(Repository r) {\r
+ if (!hasCommits(r)) {\r
// fresh repository\r
- return new Date(r.getDirectory().lastModified()); \r
+ return new Date(r.getDirectory().lastModified());\r
}\r
+ RevCommit commit = getCommit(r, Constants.HEAD);\r
return getCommitDate(commit);\r
}\r
\r
public static RevCommit getCommit(Repository r, String objectId) {\r
RevCommit commit = null;\r
+ if (!hasCommits(r)) {\r
+ return null;\r
+ }\r
try {\r
if (objectId == null || objectId.trim().length() == 0) {\r
objectId = Constants.HEAD;\r
commit = rev;\r
walk.dispose();\r
} catch (Throwable t) {\r
- LOGGER.error("Failed to determine last change", t);\r
+ LOGGER.error("Failed to get commit " + objectId, t);\r
}\r
return commit;\r
}\r
}\r
\r
public static String getRawContentAsString(Repository r, RevBlob blob) {\r
- byte [] content = getRawContent(r, blob);\r
+ byte[] content = getRawContent(r, blob);\r
return new String(content, Charset.forName(Constants.CHARACTER_ENCODING));\r
}\r
\r
public static String getRawContentAsString(Repository r, RevCommit commit, String blobPath) {\r
RevObject obj = getRevObject(r, commit.getTree(), blobPath);\r
- byte [] content = getRawContent(r, (RevBlob) obj);\r
+ byte[] content = getRawContent(r, (RevBlob) obj);\r
return new String(content, Charset.forName(Constants.CHARACTER_ENCODING));\r
}\r
\r
\r
public static List<PathChangeModel> getFilesInCommit(Repository r, RevCommit commit) {\r
List<PathChangeModel> list = new ArrayList<PathChangeModel>();\r
+ if (commit == null) {\r
+ LOGGER.warn("getFilesInCommit for NULL commit");\r
+ return list;\r
+ }\r
try {\r
final RevWalk rw = new RevWalk(r);\r
RevCommit parent = rw.parseCommit(commit.getParent(0).getId());\r
}\r
return list;\r
}\r
- \r
+\r
public static List<PathModel> getDocuments(Repository r, List<String> extensions) {\r
List<PathModel> list = new ArrayList<PathModel>();\r
- RevCommit commit = getCommit(r, Constants.HEAD); \r
+ RevCommit commit = getCommit(r, Constants.HEAD);\r
final TreeWalk walk = new TreeWalk(r);\r
try {\r
walk.addTree(commit.getTree());\r
if (extensions != null && extensions.size() > 0) {\r
Collection<TreeFilter> suffixFilters = new ArrayList<TreeFilter>();\r
- for (String extension:extensions) {\r
+ for (String extension : extensions) {\r
if (extension.charAt(0) == '.') {\r
suffixFilters.add(PathSuffixFilter.create(extension));\r
} else {\r
\r
public static List<RevCommit> getRevLog(Repository r, String objectId, String path, int offset, int maxCount) {\r
List<RevCommit> list = new ArrayList<RevCommit>();\r
+ if (!hasCommits(r)) {\r
+ return list;\r
+ }\r
try {\r
if (objectId == null || objectId.trim().length() == 0) {\r
objectId = Constants.HEAD;\r
public static List<RevCommit> searchRevlogs(Repository r, String objectId, String value, final SearchType type, int offset, int maxCount) {\r
final String lcValue = value.toLowerCase();\r
List<RevCommit> list = new ArrayList<RevCommit>();\r
+ if (!hasCommits(r)) {\r
+ return list;\r
+ }\r
try {\r
if (objectId == null || objectId.trim().length() == 0) {\r
objectId = Constants.HEAD;\r
}\r
\r
public static List<Metric> getDateMetrics(Repository r) {\r
- final List<RefModel> tags = getTags(r, -1);\r
- final Map<ObjectId, RefModel> tagMap = new HashMap<ObjectId, RefModel>();\r
- for (RefModel tag : tags) {\r
- tagMap.put(tag.getCommitId(), tag);\r
- }\r
Metric total = new Metric("TOTAL");\r
final Map<String, Metric> metricMap = new HashMap<String, Metric>();\r
- try {\r
- RevWalk walk = new RevWalk(r);\r
- ObjectId object = r.resolve(Constants.HEAD);\r
-\r
- RevCommit firstCommit = getFirstCommit(r, Constants.HEAD);\r
- RevCommit lastCommit = walk.parseCommit(object);\r
- int diffDays = (lastCommit.getCommitTime() - firstCommit.getCommitTime()) / (60 * 60 * 24);\r
- total.duration = diffDays;\r
- DateFormat df;\r
- if (diffDays <= 90) {\r
- // Days\r
- df = new SimpleDateFormat("yyyy-MM-dd");\r
- } else if (diffDays > 90 && diffDays < 365) {\r
- // Weeks\r
- df = new SimpleDateFormat("yyyy-MM (w)");\r
- } else {\r
- // Months\r
- df = new SimpleDateFormat("yyyy-MM");\r
+ \r
+ if (hasCommits(r)) {\r
+ final List<RefModel> tags = getTags(r, -1);\r
+ final Map<ObjectId, RefModel> tagMap = new HashMap<ObjectId, RefModel>();\r
+ for (RefModel tag : tags) {\r
+ tagMap.put(tag.getCommitId(), tag);\r
}\r
- walk.markStart(lastCommit);\r
+ try {\r
+ RevWalk walk = new RevWalk(r);\r
+ ObjectId object = r.resolve(Constants.HEAD);\r
+\r
+ RevCommit firstCommit = getFirstCommit(r, Constants.HEAD);\r
+ RevCommit lastCommit = walk.parseCommit(object);\r
+ int diffDays = (lastCommit.getCommitTime() - firstCommit.getCommitTime()) / (60 * 60 * 24);\r
+ total.duration = diffDays;\r
+ DateFormat df;\r
+ if (diffDays <= 90) {\r
+ // Days\r
+ df = new SimpleDateFormat("yyyy-MM-dd");\r
+ } else if (diffDays > 90 && diffDays < 365) {\r
+ // Weeks\r
+ df = new SimpleDateFormat("yyyy-MM (w)");\r
+ } else {\r
+ // Months\r
+ df = new SimpleDateFormat("yyyy-MM");\r
+ }\r
+ walk.markStart(lastCommit);\r
\r
- Iterable<RevCommit> revlog = walk;\r
- for (RevCommit rev : revlog) {\r
- Date d = getCommitDate(rev);\r
- String p = df.format(d);\r
- if (!metricMap.containsKey(p))\r
- metricMap.put(p, new Metric(p));\r
- Metric m = metricMap.get(p);\r
- m.count++;\r
- total.count++;\r
- if (tagMap.containsKey(rev.getId())) {\r
- m.tag++;\r
- total.tag++;\r
+ Iterable<RevCommit> revlog = walk;\r
+ for (RevCommit rev : revlog) {\r
+ Date d = getCommitDate(rev);\r
+ String p = df.format(d);\r
+ if (!metricMap.containsKey(p))\r
+ metricMap.put(p, new Metric(p));\r
+ Metric m = metricMap.get(p);\r
+ m.count++;\r
+ total.count++;\r
+ if (tagMap.containsKey(rev.getId())) {\r
+ m.tag++;\r
+ total.tag++;\r
+ }\r
}\r
+ } catch (Throwable t) {\r
+ LOGGER.error("Failed to mine log history for metrics", t);\r
}\r
- } catch (Throwable t) {\r
- LOGGER.error("Failed to mine log history for metrics", t);\r
}\r
List<String> keys = new ArrayList<String>(metricMap.keySet());\r
Collections.sort(keys);\r
metrics.add(0, total);\r
return metrics;\r
}\r
- \r
+\r
public static RefModel getTicketsBranch(Repository r) {\r
RefModel ticgitBranch = null;\r
try {\r
<span>\r
<a href="/"><span wicket:id="siteName">[site name]</span></a> / <span wicket:id="repositoryName">[repository name]</span> <span wicket:id="pageName">[page name]</span>\r
</span> \r
- <span wicket:id="feedback">[Feedback Panel]</span>\r
</div>\r
\r
<!-- page content -->\r
import javax.servlet.http.HttpServletRequest;\r
\r
import org.apache.wicket.PageParameters;\r
+import org.apache.wicket.RestartResponseAtInterceptPageException;\r
import org.apache.wicket.markup.html.WebPage;\r
import org.apache.wicket.markup.html.basic.Label;\r
import org.apache.wicket.markup.html.panel.FeedbackPanel;\r
add(new FeedbackPanel("feedback"));\r
\r
// footer\r
- if (GitBlit.self().settings().getBoolean(Keys.web.authenticateViewPages, true)\r
- || GitBlit.self().settings().getBoolean(Keys.web.authenticateAdminPages, true)) {\r
+ if (GitBlit.self().settings().getBoolean(Keys.web.authenticateViewPages, true) || GitBlit.self().settings().getBoolean(Keys.web.authenticateAdminPages, true)) {\r
if (GitBlitWebSession.get().isLoggedIn()) {\r
// logout\r
add(new LinkPanel("userPanel", null, getString("gb.logout") + " " + GitBlitWebSession.get().getUser().toString(), LogoutPage.class));\r
} else {\r
// login\r
- add(new LinkPanel("userPanel", null, getString("gb.login"), LoginPage.class)); \r
+ add(new LinkPanel("userPanel", null, getString("gb.login"), LoginPage.class));\r
}\r
} else {\r
add(new Label("userPanel", ""));\r
return req.getServerName();\r
}\r
\r
- public void error(String message, Throwable t) {\r
- super.error(message);\r
+ public void error(String message, boolean redirect) {\r
+ logger.error(message);\r
+ if (redirect) {\r
+ GitBlitWebSession.get().cacheErrorMessage(message);\r
+ throw new RestartResponseAtInterceptPageException(getApplication().getHomePage());\r
+ } else {\r
+ super.error(message);\r
+ }\r
+ }\r
+\r
+ public void error(String message, Throwable t, boolean redirect) {\r
logger.error(message, t);\r
+ if (redirect) {\r
+ GitBlitWebSession.get().cacheErrorMessage(message);\r
+ throw new RestartResponseAtInterceptPageException(getApplication().getHomePage());\r
+ } else {\r
+ super.error(message);\r
+ }\r
}\r
}\r
mount(new MixedParamUrlCodingStrategy("/commitdiff", CommitDiffPage.class, new String[] { "r", "h" }));\r
mount(new MixedParamUrlCodingStrategy("/patch", PatchPage.class, new String[] { "r", "h", "f" }));\r
mount(new MixedParamUrlCodingStrategy("/history", HistoryPage.class, new String[] { "r", "h", "f" }));\r
- mount(new MixedParamUrlCodingStrategy("/search", SearchPage.class, new String[] { "r", "h", "a", "c" }));\r
+ mount(new MixedParamUrlCodingStrategy("/search", SearchPage.class, new String[] { }));\r
\r
// setup ticket urls\r
mount(new MixedParamUrlCodingStrategy("/tickets", TicketsPage.class, new String[] { "r" }));\r
gb.group = group\r
gb.description = description\r
gb.enableTickets = enable tickets\r
-gb.enableDocs = enable docs
\ No newline at end of file
+gb.enableDocs = enable docs\r
+gb.save = save
\ No newline at end of file
protected TimeZone timezone = null;\r
\r
private User user = null;\r
+ \r
+ private String errorMessage = null;\r
\r
public GitBlitWebSession(Request request) {\r
super(request);\r
}\r
return timezone;\r
}\r
+ \r
+ public void cacheErrorMessage(String message) {\r
+ this.errorMessage = message;\r
+ }\r
+ \r
+ public String clearErrorMessage() {\r
+ String msg = errorMessage;\r
+ errorMessage = null;\r
+ return msg;\r
+ }\r
\r
public static GitBlitWebSession get() {\r
return (GitBlitWebSession) Session.get();\r
<input type="password" wicket:id="password" value=""/>\r
<p/>\r
<input type="submit" value="Login" wicket:message="value:gb.login" />\r
- <div style="background-color:#c7c7c7" wicket:id="feedback"></div>\r
+ <div style="padding-top:10px;" wicket:id="feedback"></div>\r
</div>\r
- </form>\r
+ </form> \r
</div>\r
</body>\r
</html>
\ No newline at end of file
<a wicket:id="summary"><wicket:message key="gb.summary"></wicket:message></a> | <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="branches"><wicket:message key="gb.branches"></wicket:message></a> | <a wicket:id="tags"><wicket:message key="gb.tags"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a> <span wicket:id="extra"><span wicket:id="extraSeparator"></span><span wicket:id="extraLink"></span></span>\r
</div>\r
</div>\r
+ \r
+ <div style="text-align:center;" wicket:id="feedback">[Feedback Panel]</div>\r
\r
<!-- page content -->\r
<wicket:child />\r
package com.gitblit.wicket;\r
\r
+import java.text.MessageFormat;\r
import java.util.ArrayList;\r
import java.util.Arrays;\r
import java.util.HashMap;\r
public abstract class RepositoryPage extends BasePage {\r
\r
protected final String repositoryName;\r
- protected final String objectId; \r
+ protected final String objectId;\r
\r
private transient Repository r = null;\r
- \r
+\r
private RepositoryModel m = null;\r
\r
private final Logger logger = LoggerFactory.getLogger(RepositoryPage.class);\r
\r
public RepositoryPage(PageParameters params) {\r
super(params);\r
- if (!params.containsKey("r")) {\r
- error("Repository not specified!");\r
- redirectToInterceptPage(new RepositoriesPage());\r
- }\r
repositoryName = WicketUtils.getRepositoryName(params);\r
objectId = WicketUtils.getObject(params);\r
\r
+ if (StringUtils.isEmpty(repositoryName)) {\r
+ error(MessageFormat.format("Repository not specified for {0}!", getPageName()), true);\r
+ }\r
+\r
Repository r = getRepository();\r
+ if (r == null) {\r
+ error(MessageFormat.format("Failed to open repository {0} for {1}!", repositoryName, getPageName()), true);\r
+ }\r
\r
// standard page links\r
add(new BookmarkablePageLink<Void>("summary", SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
add(new BookmarkablePageLink<Void>("tags", TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
\r
- // per-repository extra page links \r
+ // per-repository extra page links\r
List<String> extraPageLinks = new ArrayList<String>();\r
\r
// Conditionally add tickets page\r
}\r
};\r
add(extrasView);\r
- \r
+\r
// disable current page\r
disablePageLink(getPageName());\r
\r
SearchForm searchForm = new SearchForm("searchForm", repositoryName);\r
add(searchForm);\r
searchForm.setTranslatedAttributes();\r
- \r
+\r
// set stateless page preference\r
setStatelessHint(true);\r
}\r
}\r
return r;\r
}\r
- \r
+\r
protected RepositoryModel getRepositoryModel() {\r
if (m == null) {\r
m = GitBlit.self().getRepositoryModel(repositoryName);\r
}\r
return m;\r
}\r
+ \r
+ protected RevCommit getCommit() {\r
+ RevCommit commit = JGitUtils.getCommit(r, objectId);\r
+ if (commit == null) {\r
+ error(MessageFormat.format("Failed to find commit \"{0}\" in {1} for {2} page!", objectId, repositoryName, getPageName()), true);\r
+ }\r
+ return commit;\r
+ }\r
\r
protected void addRefs(Repository r, RevCommit c) {\r
add(new RefsPanel("refsPanel", repositoryName, c, JGitUtils.getAllRefs(r)));\r
TextField<String> searchBox = new TextField<String>("searchBox", searchBoxModel);\r
add(searchBox);\r
}\r
- \r
- void setTranslatedAttributes() { \r
+\r
+ void setTranslatedAttributes() {\r
WicketUtils.setHtmlTooltip(get("searchType"), getString("gb.searchTypeTooltip"));\r
WicketUtils.setHtmlTooltip(get("searchBox"), getString("gb.searchTooltip"));\r
- WicketUtils.setInputPlaceholder(get("searchBox"), getString("gb.search")); \r
+ WicketUtils.setInputPlaceholder(get("searchBox"), getString("gb.search"));\r
}\r
\r
@Override\r
public String owner;\r
public String group;\r
public Date lastChange;\r
+ public boolean hasCommits;\r
public boolean useTickets;\r
public boolean useDocs;\r
public boolean useRestrictedAccess;\r
final String baseObjectId = WicketUtils.getBaseObjectId(params);\r
\r
Repository r = getRepository();\r
- RevCommit commit = JGitUtils.getCommit(r, objectId);\r
- \r
+ RevCommit commit = getCommit();\r
+ \r
DiffOutputType diffType = DiffOutputType.forName(GitBlit.self().settings().getString(Keys.web.diffStyle, DiffOutputType.GITBLIT.name()));\r
\r
String diff;\r
\r
// standard blob view\r
Repository r = getRepository();\r
- RevCommit commit = JGitUtils.getCommit(r, objectId);\r
+ RevCommit commit = getCommit();\r
\r
// blob page links\r
add(new Label("blameLink", getString("gb.blame")));\r
super(params);\r
\r
Repository r = getRepository();\r
- RevCommit commit = JGitUtils.getCommit(r, objectId);\r
+ RevCommit commit = getCommit();\r
DiffOutputType diffType = DiffOutputType.forName(GitBlit.self().settings().getString(Keys.web.diffStyle, DiffOutputType.GITBLIT.name()));\r
String diff = JGitUtils.getCommitDiff(r, commit, diffType);\r
\r
super(params);\r
\r
Repository r = getRepository();\r
- RevCommit c = JGitUtils.getCommit(r, objectId);\r
+ RevCommit c = getCommit();\r
\r
List<String> parents = new ArrayList<String>();\r
if (c.getParentCount() > 0) {\r
<wicket:extend>\r
<!-- Push content down to preserve header image -->\r
<div style="padding-top:20px"></div>\r
- \r
+\r
+ <div style="text-align:center;" wicket:id="feedback">[Feedback Panel]</div> \r
+\r
<!-- Repository Table -->\r
<form wicket:id="editForm">\r
<table class="plain">\r
<tr><th><wicket:message key="gb.group"></wicket:message></th><td class="edit"><input type="text" wicket:id="group" size="30" tabindex="4" /></td></tr>\r
<tr><th><wicket:message key="gb.enableTickets"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="useTickets" tabindex="5" /> <i>distributed Ticgit issues</i></td></tr>\r
<tr><th><wicket:message key="gb.enableDocs"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="useDocs" tabindex="6" /> <i>enumerates repository Markdown documentation</i></td></tr>\r
- <tr><td class="edit" colspan="2"><input type="submit" value="Submit" tabindex="7" /></td></tr>\r
+ <tr><td class="edit" colspan="2"><input type="submit" value="Save" wicket:message="value:gb.save" tabindex="7" /></td></tr>\r
</tbody>\r
</table>\r
</form> \r
+\r
</wicket:extend>\r
</body>\r
</html>
\ No newline at end of file
import com.gitblit.GitBlit;\r
import com.gitblit.utils.JGitUtils;\r
import com.gitblit.utils.StringUtils;\r
+import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.WicketUtils;\r
\r
public class PatchPage extends WebPage {\r
super(params);\r
\r
if (!params.containsKey("r")) {\r
- error("Repository not specified!");\r
+ GitBlitWebSession.get().cacheErrorMessage("Repository not specified!");\r
redirectToInterceptPage(new RepositoriesPage());\r
+ return;\r
}\r
+ \r
final String repositoryName = WicketUtils.getRepositoryName(params);\r
final String baseObjectId = WicketUtils.getBaseObjectId(params);\r
final String objectId = WicketUtils.getObject(params);\r
\r
Repository r = GitBlit.self().getRepository(repositoryName);\r
if (r == null) {\r
- error("Can not load repository " + repositoryName);\r
+ GitBlitWebSession.get().cacheErrorMessage("Can not load repository " + repositoryName);\r
redirectToInterceptPage(new RepositoriesPage());\r
return;\r
}\r
\r
RevCommit commit = JGitUtils.getCommit(r, objectId);\r
+ if (commit == null) {\r
+ GitBlitWebSession.get().cacheErrorMessage("Commit is null");\r
+ redirectToInterceptPage(new RepositoriesPage());\r
+ return;\r
+ }\r
+ \r
String patch;\r
if (StringUtils.isEmpty(baseObjectId)) {\r
patch = JGitUtils.getCommitPatch(r, commit, blobPath);\r
<wicket:extend>\r
<div wicket:id="adminPanel">[admin links]</div>\r
\r
+ <div style="text-align:center;padding-top:20px;" wicket:id="feedback">[Feedback Panel]</div>\r
+ \r
<div class="markdown" wicket:id="repositoriesMessage">[repositories message]</div>\r
\r
<table class="repositories">\r
<wicket:fragment wicket:id="repositoryAdminLinks">\r
<span class="link"><a wicket:id="editRepository"><wicket:message key="gb.edit">[edit]</wicket:message></a> | <a wicket:id="renameRepository"><wicket:message key="gb.rename">[rename]</wicket:message></a> | <a wicket:id="deleteRepository"><wicket:message key="gb.delete">[delete]</wicket:message></a></span>\r
</wicket:fragment>\r
+ \r
</wicket:extend>\r
</body>\r
</html>
\ No newline at end of file
adminLinks.add(new BookmarkablePageLink<Void>("newUser", RepositoriesPage.class));\r
add(adminLinks.setVisible(showAdmin));\r
\r
+ // display an error message cached from a redirect\r
+ String cachedMessage = GitBlitWebSession.get().clearErrorMessage();\r
+ if (!StringUtils.isEmpty(cachedMessage)) {\r
+ error(cachedMessage);\r
+ System.out.println("displayed message");\r
+ }\r
+ \r
// Load the markdown welcome message\r
String messageSource = GitBlit.self().settings().getString(Keys.web.repositoriesMessage, "gitblit");\r
String message = "";\r
message = StringUtils.transformMarkdown(reader);\r
} catch (Throwable t) {\r
message = "Failed to read default welcome message!";\r
- error(message, t);\r
+ error(message, t, false);\r
}\r
} else {\r
// Read user-supplied welcome message\r
message = StringUtils.transformMarkdown(reader);\r
} catch (Throwable t) {\r
message = "Failed to read " + file;\r
- error(message, t);\r
+ error(message, t, false);\r
}\r
} else {\r
message = messageSource + " is not a valid file.";\r
\r
public void populateItem(final Item<RepositoryModel> item) {\r
final RepositoryModel entry = item.getModelObject();\r
- PageParameters pp = WicketUtils.newRepositoryParameter(entry.name);\r
- item.add(new LinkPanel("repositoryName", "list", entry.name, SummaryPage.class, pp));\r
- item.add(new LinkPanel("repositoryDescription", "list", entry.description, SummaryPage.class, pp));\r
-\r
+ if (entry.hasCommits) {\r
+ // Existing repository\r
+ PageParameters pp = WicketUtils.newRepositoryParameter(entry.name);\r
+ item.add(new LinkPanel("repositoryName", "list", entry.name, SummaryPage.class, pp));\r
+ item.add(new LinkPanel("repositoryDescription", "list", entry.description, SummaryPage.class, pp));\r
+ } else {\r
+ // New repository\r
+ item.add(new Label("repositoryName", entry.name + "<span class='empty'>(empty)</span>").setEscapeModelStrings(false));\r
+ item.add(new Label("repositoryDescription", entry.description)); \r
+ }\r
+ \r
if (entry.useTickets) {\r
item.add(WicketUtils.newImage("ticketsIcon", "bug_16x16.png", getString("gb.tickets")));\r
} else {\r
super(params);\r
\r
Repository r = getRepository();\r
+ RevCommit c = getCommit();\r
List<RefModel> tags = JGitUtils.getTags(r, -1);\r
- RevCommit c = JGitUtils.getCommit(r, objectId);\r
\r
RefModel tagRef = null;\r
// determine tag\r
final String path = WicketUtils.getPath(params);\r
\r
Repository r = getRepository();\r
- RevCommit commit = JGitUtils.getCommit(r, objectId);\r
+ RevCommit commit = getCommit();\r
List<PathModel> paths = JGitUtils.getFilesInPath(r, path, commit);\r
\r
// tree page links\r
package com.gitblit.wicket.panels;\r
\r
-import java.util.Date;\r
-\r
import org.apache.wicket.markup.html.basic.Label;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
\r
\r
public CommitHeaderPanel(String id, String repositoryName, RevCommit c) {\r
super(id);\r
- add(new LinkPanel("shortmessage", "title", c == null ? "" : c.getShortMessage(), CommitPage.class, WicketUtils.newObjectParameter(repositoryName, c == null ? "" : c.getName())));\r
+ add(new LinkPanel("shortmessage", "title", c.getShortMessage(), CommitPage.class, WicketUtils.newObjectParameter(repositoryName, c.getName())));\r
add(new Label("commitid", "(" + c.getName().substring(0, 8) + ")")); \r
- add(new Label("author", c == null ? "" : c.getAuthorIdent().getName()));\r
- add(WicketUtils.createDateLabel("date", c == null ? new Date(0) : c.getAuthorIdent().getWhen(), getTimeZone()));\r
+ add(new Label("author", c.getAuthorIdent().getName()));\r
+ add(WicketUtils.createDateLabel("date", c.getAuthorIdent().getWhen(), getTimeZone()));\r
}\r
}
\ No newline at end of file
hasMore = commits.size() >= itemsPerPage;\r
\r
// header\r
- add(new LinkPanel("header", "title", commit.getShortMessage(), CommitPage.class, WicketUtils.newObjectParameter(repositoryName, commit.getName())));\r
+ add(new LinkPanel("header", "title", commit == null ? "":commit.getShortMessage(), CommitPage.class, WicketUtils.newObjectParameter(repositoryName, commit == null ? "":commit.getName())));\r
\r
ListDataProvider<RevCommit> dp = new ListDataProvider<RevCommit>(commits);\r
DataView<RevCommit> searchView = new DataView<RevCommit>("commit", dp) {\r
padding: 0px 0px 15px 5px;\r
}\r
\r
+span.empty {\r
+ font-size: 0.9em;\r
+ font-style: italic;\r
+ padding-left:10px;\r
+ color: #008000;\r
+}\r
+\r
span.link, span.link a {\r
font-family: sans-serif;\r
font-size: 11px;\r
.feedbackPanelERROR { \r
color: red;\r
list-style-image: url(bullet_error.png);\r
- font-weight: bold;\r
- text-align:left;\r
+ font-weight: bold; \r
vertical-align: top;\r
padding:0; \r
margin:0; \r
.feedbackPanelINFO {\r
color: green;\r
list-style: none;\r
- font-weight: bold;\r
- text-align:center;\r
+ font-weight: bold; \r
padding:0;\r
margin:0;\r
}
\ No newline at end of file