Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add license and readme to the git wrapper library.

  • Loading branch information...
commit d459edd6d71acadfc9a21178a506247e9112b5d9 1 parent c569433
Tim Caswell authored
Showing with 58 additions and 24 deletions.
  1. +33 −0 README.markdown
  2. +25 −24 lib/git.js
33 README.markdown
View
@@ -0,0 +1,33 @@
+# node-git
+
+This is a thin wrapper around the command-line `git` command for use inside node applications. It's used primarily by the [wheat][] blogging system to enable a running node.JS server to read files out of a git repository as if they were local files.
+
+## Example usage
+
+ var sys = require('sys'),
+ Git = require('git');
+
+
+ // Test it!
+ Git("/Users/tim/code/howtonode.org");
+ Git.exists("articles/control-flow-part-ii.markdown", function (err, tags) {
+ if (err) { throw(err); }
+ sys.p(tags);
+ });
+ Git.getTags(function (err, tags) {
+ if (err) { throw(err); }
+ Object.keys(tags).forEach(function (tag) {
+ Git.readDir("articles", tags[tag], function (err, contents) {
+ if (err) { throw(err); }
+ contents.files.forEach(function (file) {
+ file = Path.join("articles", file);
+ Git.readFile(file, tags[tag], function (err, text) {
+ if (err) { throw(err); }
+ sys.error("tag: " + tag + " sha1: " + tags[tag] + " file: " + file + " length: " + text.length);
+ });
+ });
+ });
+ });
+ });
+
+[wheat]: http://github.com/creationix/wheat
49 lib/git.js
View
@@ -1,6 +1,30 @@
+/*
+Copyright (c) 2010 Tim Caswell <tim@creationix.com>
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
var ChildProcess = require('child_process'),
Path = require('path'),
- sys = require('sys'),
fs = require('fs');
var fileCache;
@@ -170,26 +194,3 @@ Git.clearCache = function () {
tagsCache = undefined;
};
-
-// Test it!
-// Git("/Users/tim/code/node");
-// Git("/Users/tim/git/howtonode.org.git");
-// Git.exists("articles/control-flow-part-ii.markdown", function (err, tags) {
-// if (err) { throw(err); }
-// sys.p(tags);
-// });
-// Git.getTags(function (err, tags) {
-// if (err) { throw(err); }
-// Object.keys(tags).forEach(function (tag) {
-// Git.readDir("articles", tags[tag], function (err, contents) {
-// if (err) { throw(err); }
-// contents.files.forEach(function (file) {
-// file = Path.join("articles", file);
-// Git.readFile(file, tags[tag], function (err, text) {
-// if (err) { throw(err); }
-// sys.error("tag: " + tag + " sha1: " + tags[tag] + " file: " + file + " length: " + text.length);
-// });
-// });
-// });
-// });
-// });
Please sign in to comment.
Something went wrong with that request. Please try again.