paulwalko.github.io/_site/node_modules/gulp-gh-pages/node_modules/gift/lib/tag.js

88 lines
2.5 KiB
JavaScript

// Generated by CoffeeScript 1.9.1
(function() {
var Actor, Commit, Ref, Tag, _,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
_ = require('underscore');
Commit = require('./commit');
Actor = require('./actor');
Ref = require('./ref').Ref;
module.exports = Tag = (function(superClass) {
extend(Tag, superClass);
function Tag() {
return Tag.__super__.constructor.apply(this, arguments);
}
Tag.find_all = function(repo, callback) {
return Ref.find_all(repo, "tag", Tag, callback);
};
Tag.prototype.message = function(callback) {
return this.lazy(function(err, data) {
if (err) {
return callback(err);
}
return callback(null, data.message);
});
};
Tag.prototype.tagger = function(callback) {
return this.lazy(function(err, data) {
if (err) {
return callback(err);
}
return callback(null, data.tagger);
});
};
Tag.prototype.tag_date = function(callback) {
return this.lazy(function(err, data) {
if (err) {
return callback(err);
}
return callback(null, data.tag_date);
});
};
Tag.prototype.lazy = function(callback) {
if (this._lazy_data) {
return callback(null, this._lazy_data);
}
return this.repo.git("cat-file", {}, ["tag", this.name], (function(_this) {
return function(err, stdout, stderr) {
var author, author_line, data, epoch, line, lines, m, message, ref;
if (err) {
return callback(err);
}
lines = stdout.split("\n");
data = {};
lines.shift();
lines.shift();
lines.shift();
author_line = lines.shift();
ref = /^.+? (.*) (\d+) .*$/.exec(author_line), m = ref[0], author = ref[1], epoch = ref[2];
data.tagger = Actor.from_string(author);
data.tag_date = new Date(epoch);
lines.shift();
message = [];
while (line = lines.shift()) {
message.push(line);
}
data.message = message.join("\n");
return callback(null, (_this._lazy_data = data));
};
})(this));
};
return Tag;
})(Ref);
}).call(this);