Coder Social home page Coder Social logo

node-git's Introduction

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);
        });
      });
    });
  });
});

More example:

var sys = require('sys');
// Git("/Users/tim/git/howtonode.org.git");
Git("/Users/tim/Code/howtonode.org");
Git.log("articles/what-is-this.markdown", function (err, data) {
  if (err) throw err;
  sys.p(data);
  process.exit();
});

node-git's People

Contributors

avianflu avatar creationix avatar pirxpilot avatar rlidwka avatar sapk avatar tootallnate avatar yashiro1899 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-git's Issues

Update usage examples in README

I'm getting has no method errors on the examples in the README. Assuming I'm not doing something wrong (totally possible) could you update them please?

buggy call of git log

You call git log without deactivating colors.

https://github.com/creationix/node-git/blob/master/lib/git-fs.js#L197

A user who has configures git to always print color will see a weird error message cause the regex-parser won't match. You can fix this by adding the option -c color.ui=never before the log in git log.

Generally you should add this option to all of your git commands and specially you could look into my own thin wrapper around git commands ;-) https://github.com/payload/node-treeeater/

I discovered this error while using https://github.com/mklabs/nabe

Error: ENOENT, No such file or directory 'packed-refs'

When attempting to use this lib on a "bare" git repo with a single commit pushed to it, I get this:

/home/nrajlich/wheat/lib/wheat.js:74
            if (err) { throw err; }
                       ^
Error: ENOENT, No such file or directory '/home/nrajlich/blog.git/packed-refs'
at node.js:221:9

When does the packed-refs file get created in Git? I worked around it by commenting out everything related to packed-refs in the Git.getHead method, and it seems to work fine, but obviously that's not the right way.

Any heads up? Or I guess node-git should be patched to check for the existence of that file before trying to read it, so that this error never happens :)

EDIT: I was further able to fix the error by simply running:

git pack-refs

and then the packed-refs file was created. I'm still in favor of checking for the existence of the file first. I'll try and get a patch ready if I have time.

node-git module === 1GB?

I previously installed node-git, noticed that the installed module was about one gigabyte in size (Babel) and then I deleted the module. I am disappointed because the premise of this API is awesome. Is there some other alternative for having a smaller installation?

Thanks,
Philip

Minimum version of git

Might be nice to put some minimal version checks of git in, I had to update to 1.8 to get this to work, and of course I didn't check my version I had before, but it didn't work (also I am on a windows install if that helps)

support for corporate proxy

It would be great to support a corporate proxy with the http_proxy and https_proxy environment variables.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.