0

Hi recently I have to implement a git API for a node module, so we can have version control through programmatic interface. I came upon this post to find some good modules that I can use.

However, after playing around with some of them, I realized that none of them provide the feature of querying the commit history of a single file (like calling 'git log --follow '). I would like to extend that feature into my module but since I have no experience before, does anyone know where I should start?

1 Answer 1

1

The libraries you mentioned should be a good starting point. Take node-git's lib/git.js file for example. There you can find the following lines:

// Call the native git binary
Git.prototype.call_git = function(prefix, command, postfix, options, args, callback) {
    // ...

This is a good starting point to understand how the author maps Node functions on system calls and and allows the callback to work with the output.

I would start a fork of the project. Look for the log function in the same file, which starts like

Git.prototype.log = function(commit, path, options, callback) {

Copy the function, give it a proper name and try to adopt it to meet your needs.

If you succeed and like to help, you could start a pull request on GitHub to help the author and add the functionallity to the official project.

I would do it this way. I hope this helps.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @Seb, actually I decided to just dive into the source code and found that to be pretty clearly documented. I should be able to extend the module smoothly :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.