Skip to content

Commit accb9ce

Browse files
committed
Add a git log view.
1 parent 352f361 commit accb9ce

File tree

3 files changed

+62
-10
lines changed

3 files changed

+62
-10
lines changed

coder-apps/common/vcs/app/gitapp.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var Git = require("./git");
55
var App = coderlib.App;
66
var LocalApp = coderlib.LocalApp;
77

8-
var GitApp = exports = function(name, rev) {
8+
var GitApp = module.exports = function(name, rev) {
99
GitApp.super_.call(this, name);
1010

1111
this.revision = rev;
@@ -97,19 +97,26 @@ GitApp.history = function(name, callback) {
9797

9898
(function loadRev(rev) {
9999
repo.parseCommit(rev, function(err, commit) {
100-
if (err)
100+
if (err) {
101101
callback(err);
102-
else {
103-
commits.push(commit);
104-
if (commit.parents.length == 0)
105-
callback(null, commits);
106-
else
107-
loadRev(commit.parents[0]);
102+
return;
108103
}
104+
repo.rev_parse(["--short", rev], function(err, short_rev) {
105+
commit.revision = rev;
106+
commit.short = short_rev;
107+
if (err)
108+
callback(err);
109+
else {
110+
commits.push(commit);
111+
if (commit.parents.length == 0)
112+
callback(null, commits);
113+
else
114+
loadRev(commit.parents[0]);
115+
}
116+
});
109117
});
110118
})(revision);
111119
}
112120
], callback);
113121
};
114122

115-

coder-apps/common/vcs/app/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ var isVersionned = function(app, callback) {
1212

1313
exports.get_routes = [
1414
{ path:'/', handler:'index_handler' },
15-
{ path:/^\/view\/(\w+)\/([0-9a-f]+)\/static\/(.+)$/, handler: 'static_handler' }
15+
{ path:/^\/view\/(\w+)\/([0-9a-f]+)\/static\/(.+)$/, handler: 'static_handler' },
16+
{ path:/^\/log\/(\w+)\/?$/, handler:'log_handler' }
1617
];
1718

1819
exports.post_routes = [
@@ -55,6 +56,16 @@ exports.static_handler = function( app, req, res, match ) {
5556
});
5657
};
5758

59+
exports.log_handler = function( app, req, res, match ) {
60+
var appname = match[1];
61+
62+
GitApp.history(appname, function(err, results) {
63+
console.log(err);
64+
res.render( app.view("log"), {commits: results} );
65+
});
66+
};
67+
68+
5869
exports.on_destroy = function() {
5970
};
6071

coder-apps/common/vcs/views/log.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Coder</title>
5+
<meta charset="utf-8">
6+
<!-- Standard Coder Includes -->
7+
<script>
8+
var appname = "{{app_name}}"; //app name (id) of this app
9+
var appurl = "{{&app_url}}";
10+
var staticurl = "{{&static_url}}"; //base path to your static files /static/apps/yourapp
11+
</script>
12+
<link href="/static/apps/coderlib/css/index.css" media="screen" rel="stylesheet" type="text/css"/>
13+
<script src="/static/common/js/jquery.min.js"></script>
14+
<script src="/static/common/ace-min/ace.js" type="text/javascript" charset="utf-8"></script>
15+
<script src="/static/apps/coderlib/js/index.js"></script>
16+
<!-- End Coder Includes -->
17+
18+
<!-- This app's includes -->
19+
<link href="{{&static_url}}/css/index.css" media="screen" rel="stylesheet" type="text/css"/>
20+
<script src="{{&static_url}}/js/index.js"></script>
21+
<!-- End apps includes -->
22+
</head>
23+
<body class="">
24+
<div class="pagecontent">
25+
<h1>Log</h1>
26+
<ul>
27+
{{#commits}}
28+
<li>{{message}} - {{short}}</li>
29+
{{/commits}}
30+
</ul>
31+
</div>
32+
</body>
33+
</html>
34+

0 commit comments

Comments
 (0)