lib/gitoe/httpserver/public/gitoe-repo.js in gitoe-0.1.0 vs lib/gitoe/httpserver/public/gitoe-repo.js in gitoe-0.1.1
- old
+ new
@@ -1,13 +1,18 @@
(function() {
var $, DAGtopo, GitoeChange, GitoeHistorian, GitoeRepo, OrderedSet, clone, exec_callback, local, strcmp, uniq, url_root, _ref,
+ __slice = [].slice,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
$ = jQuery || (function() {
throw "demand jQuery";
})();
+ moment || (function() {
+ throw "demand moment";
+ })();
+
url_root = "/repo";
exec_callback = function(context, fun, args) {
return fun.apply(context, args);
};
@@ -302,10 +307,29 @@
sha1_commit: function(sha1) {
return this.span(sha1, "sha1_commit");
},
br: function() {
return $('<br>');
+ },
+ pretty_abs_time: function(change) {
+ return this.span(moment.unix(change.committer.time).format("YYYY-MM-DD HH:mm:ss"), "git_abs_time");
+ },
+ pretty_relative_time: function(change) {
+ return this.span(moment.unix(change.committer.time).fromNow(), "git_rel_time");
+ },
+ p_with_time: function(change, elems) {
+ return this.p([this.pretty_abs_time(change), this.span(" / "), this.pretty_relative_time(change), this.span(" : ")].concat(__slice.call(elems)));
+ },
+ p: function(elements) {
+ var e, ret, _i, _len;
+
+ ret = $('<p>');
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
+ e = elements[_i];
+ ret.append(e);
+ }
+ return ret;
}
};
GitoeChange.message_rules = {
patterns: {
@@ -326,62 +350,62 @@
rebase_finish3: /^rebase (-[^ ]+ )?finished: ([^ ]+) onto/,
rebase_abort: /^rebase: aborting/
},
actions: {
clone: function(matched, change) {
- return this.li([this.git_command("git clone"), this.span(": create "), this.ref(this.ref_fullname(change)), this.span(" at "), this.sha1_commit(change.oid_new)]);
+ return this.li([this.p_with_time(change, [this.git_command("git clone")]), this.p([this.span("create "), this.ref(this.ref_fullname(change)), this.span(" at "), this.sha1_commit(change.oid_new)])]);
},
branch: function(matched, change) {
- return this.li([this.git_command("git branch"), this.span(": branch out "), this.ref(this.ref_fullname(change)), this.span(" at "), this.sha1_commit(change.oid_new), /^refs/.test(matched[1]) ? this.span(" (was ") : void 0, /^refs/.test(matched[1]) ? this.ref(this.ref_realname(matched[1])) : void 0, /^refs/.test(matched[1]) ? this.span(" )") : void 0]);
+ return this.li([this.p_with_time(change, [this.git_command("git branch")]), this.p([this.span("create branch "), this.ref(this.ref_fullname(change)), this.span(" at "), this.sha1_commit(change.oid_new), /^refs/.test(matched[1]) ? this.span(" (was ") : void 0, /^refs/.test(matched[1]) ? this.ref(this.ref_realname(matched[1])) : void 0, /^refs/.test(matched[1]) ? this.span(" )") : void 0])]);
},
commit: function(matched, change) {
- return this.li([this.git_command("git commit"), this.span(": move "), this.ref(this.ref_fullname(change)), this.span(" from "), this.sha1_commit(change.oid_old), this.span(" to "), this.sha1_commit(change.oid_new)]);
+ return this.li([this.p_with_time(change, [this.git_command("git commit")]), this.p([this.span("move "), this.ref(this.ref_fullname(change)), this.span(" from "), this.sha1_commit(change.oid_old), this.span(" to "), this.sha1_commit(change.oid_new)])]);
},
merge_commit: function(matched, change) {
- return this.li([this.git_command("git merge"), this.span(": move "), this.span(matched[2], "ref_name"), this.span(' to '), this.sha1_commit(change.oid_new), this.span(' by merging '), this.span(matched[1], "ref_name")]);
+ return this.li([this.p_with_time(change, [this.git_command("git merge")]), this.p([this.span("move "), this.span(matched[2], "ref_name"), this.span(' to '), this.sha1_commit(change.oid_new), this.span(' by merging '), this.span(matched[1], "ref_name")])]);
},
commit_amend: function(matched, change) {
- return this.li([this.git_command("git commit --amend"), this.span(": move "), this.ref(this.ref_fullname(change)), this.span(" from "), this.sha1_commit(change.oid_old), this.span(" to "), this.sha1_commit(change.oid_new)]);
+ return this.li([this.p_with_time(change, [this.git_command("git commit --amend")]), this.p([this.span("move "), this.ref(this.ref_fullname(change)), this.span(" from "), this.sha1_commit(change.oid_old), this.span(" to "), this.sha1_commit(change.oid_new)])]);
},
merge_ff: function(matched, change) {
- return this.li([this.git_command("git merge"), this.span(": move "), this.ref(this.ref_fullname(change)), this.span(' to '), this.sha1_commit(change.oid_new), this.span(' by merging '), this.span(matched[1], "ref_name")]);
+ return this.li([this.p_with_time(change, [this.git_command("git merge"), this.span(" (fast-forward)", "comment")]), this.p([this.span("move "), this.ref(this.ref_fullname(change)), this.span(' to '), this.sha1_commit(change.oid_new), this.span(' by merging '), this.span(matched[1], "ref_name")])]);
},
reset: function(matched, change) {
- return this.li([this.git_command("git reset"), this.span(": point "), this.ref(this.ref_fullname(change)), this.span(" to "), this.sha1_commit(change.oid_new), this.span(" ( was "), this.sha1_commit(change.oid_old), this.span(" )")]);
+ return this.li([this.p_with_time(change, [this.git_command("git reset")]), this.p([this.span("point "), this.ref(this.ref_fullname(change)), this.span(" to "), this.sha1_commit(change.oid_new), this.span("(was "), this.sha1_commit(change.oid_old), this.span(")")])]);
},
push: function(matched, change) {
- return this.li([this.git_command("git push"), this.span(": update "), this.ref(this.ref_fullname(change)), this.span(" to "), this.sha1_commit(change.oid_new), change.oid_old !== "0000000000000000000000000000000000000000" ? this.span(" ( was ") : void 0, change.oid_old !== "0000000000000000000000000000000000000000" ? this.sha1_commit(change.oid_old) : void 0, change.oid_old !== "0000000000000000000000000000000000000000" ? this.span(" )") : void 0]);
+ return this.li([this.p_with_time(change, [this.git_command("git push")]), this.p([this.span("update "), this.ref(this.ref_fullname(change)), change.oid_old !== "0000000000000000000000000000000000000000" ? this.span(" from ") : void 0, change.oid_old !== "0000000000000000000000000000000000000000" ? this.sha1_commit(change.oid_old) : void 0, this.span(" to "), this.sha1_commit(change.oid_new)])]);
},
fetch: function(matched, change) {
- return this.li([this.git_command("git fetch"), this.span(": update "), this.ref(this.ref_fullname(change)), this.span(" to "), this.sha1_commit(change.oid_new), change.oid_old !== "0000000000000000000000000000000000000000" ? this.span(" ( was ") : void 0, change.oid_old !== "0000000000000000000000000000000000000000" ? this.sha1_commit(change.oid_old) : void 0, change.oid_old !== "0000000000000000000000000000000000000000" ? this.span(" )") : void 0]);
+ return this.li([this.p_with_time(change, [this.git_command("git fetch")]), this.p([this.span("update "), this.ref(this.ref_fullname(change)), change.oid_old !== "0000000000000000000000000000000000000000" ? this.span(" from ") : void 0, change.oid_old !== "0000000000000000000000000000000000000000" ? this.sha1_commit(change.oid_old) : void 0, this.span(" to "), this.sha1_commit(change.oid_new)])]);
},
pull: function(matched, change) {
- return this.li([this.git_command("git pull"), this.span(": update "), this.ref(this.ref_fullname(change)), this.span(" from "), this.sha1_commit(change.oid_old), this.span(" to "), this.sha1_commit(change.oid_new)]);
+ return this.li([this.p_with_time(change, [this.git_command("git pull")]), this.p([this.span("update "), this.ref(this.ref_fullname(change)), this.span(" from "), this.sha1_commit(change.oid_old), this.span(" to "), this.sha1_commit(change.oid_new)])]);
},
checkout: function(matched, change, rest) {
- return this.li([this.git_command("git checkout"), this.span(": checkout "), this.ref(matched[2]), this.span(" at "), this.sha1_commit(change.oid_new)]);
+ return this.li([this.p_with_time(change, [this.git_command("git checkout")]), this.p([this.span("checkout "), this.ref(matched[2]), this.span(" at "), this.sha1_commit(change.oid_new)])]);
},
rename_remote: function(matched, change) {
- return this.li([this.git_command("git remote rename"), this.span(": rename "), this.ref(this.ref_realname(matched[1])), this.span(" to "), this.ref(this.ref_realname(matched[2]))]);
+ return this.li([this.p_with_time(change, [this.git_command("git remote rename")]), this.p([this.span("rename "), this.ref(this.ref_realname(matched[1])), this.span(" to "), this.ref(this.ref_realname(matched[2]))])]);
},
rebase_finish: function(matched, change) {
- return this.li([matched[1] ? this.git_command("git rebase " + matched[1]) : this.git_command("git rebase"), this.span(": rebase "), this.ref(this.ref_realname(matched[2])), this.span(" to "), this.sha1_commit(change.oid_new)]);
+ return this.li([this.p_with_time(change, [matched[1] ? this.git_command("git rebase " + matched[1]) : this.git_command("git rebase")]), this.p([this.span("rebase "), this.ref(this.ref_realname(matched[2])), this.span(" to "), this.sha1_commit(change.oid_new)])]);
},
rebase_finish2: function(matched, change) {
- return this.li([matched[1] ? this.git_command("git rebase " + matched[1]) : this.git_command("git rebase"), this.span(": rebase "), this.ref(this.ref_fullname(change)), this.span(" to "), this.sha1_commit(change.oid_new)]);
+ return this.li([this.p_with_time(change, [matched[1] ? this.git_command("git rebase " + matched[1]) : this.git_command("git rebase")]), this.p([this.span("rebase "), this.ref(this.ref_fullname(change)), this.span(" to "), this.sha1_commit(change.oid_new)])]);
},
rebase_finish3: function(matched, change) {
- return this.li([matched[1] ? this.git_command("git rebase " + matched[1]) : this.git_command("git rebase"), this.span(": rebase "), this.ref(this.ref_fullname(change)), this.span(" to "), this.sha1_commit(change.oid_new)]);
+ return this.li([this.p_with_time(change, [matched[1] ? this.git_command("git rebase " + matched[1]) : this.git_command("git rebase")]), this.p([this.span(": rebase "), this.ref(this.ref_fullname(change)), this.span(" to "), this.sha1_commit(change.oid_new)])]);
},
rebase_abort: function(matched, change, rest) {
var matched_head, real_ref;
if (rest.length > 0) {
if (matched_head = rest[0].message.match(/^checkout: moving from ([^ ]+)/)) {
real_ref = matched_head[1];
}
}
- return this.li([this.git_command("git rebase --abort"), this.span(": didn't rebase "), real_ref ? this.ref(real_ref) : void 0]);
+ return this.li([this.p_with_time(change, [this.git_command("git rebase --abort")]), this.p([this.span("didn't rebase "), real_ref ? this.ref(real_ref) : void 0])]);
}
}
};
return GitoeChange;