import javax.servlet.http.HttpServletRequest;\r
import javax.servlet.http.HttpServletResponse;\r
\r
+import org.eclipse.jgit.lib.FileMode;\r
import org.eclipse.jgit.lib.Repository;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
import org.eclipse.jgit.revwalk.RevTree;\r
response.getWriter().append("<thead><tr><th>path</th><th>mode</th><th>size</th></tr>");\r
response.getWriter().append("</thead>");\r
response.getWriter().append("<tbody>");\r
- String pattern = "<tr><td><a href=\"{0}\">{0}</a></td><td>{1}</td><td>{2}</td></tr>";\r
+ String pattern = "<tr><td><a href=\"{0}\">{1}</a></td><td>{2}</td><td>{3}</td></tr>";\r
final ByteFormat byteFormat = new ByteFormat();\r
List<PathModel> entries = JGitUtils.getFilesInPath(r, resource, commit);\r
+ if (!entries.isEmpty()) {\r
+ if (entries.get(0).path.indexOf('/') > -1) {\r
+ // we are in a subdirectory, add parent directory link\r
+ entries.add(0, new PathModel("..", resource + "/..", 0, FileMode.TREE.getBits(), null, null));\r
+ }\r
+ }\r
for (PathModel entry : entries) {\r
- response.getWriter().append(MessageFormat.format(pattern, entry.name, JGitUtils.getPermissionsFromMode(entry.mode), byteFormat.format(entry.size)));\r
+ response.getWriter().append(MessageFormat.format(pattern, entry.path, entry.name, JGitUtils.getPermissionsFromMode(entry.mode), byteFormat.format(entry.size)));\r
}\r
response.getWriter().append("</tbody>");\r
response.getWriter().append("</table>");\r