0.5.0 • Published 8 years ago

gitcapsule v0.5.0

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
8 years ago

GitCapsule

Git client on nodejs

This package is in development and is very unstable as this point.

Status

Latest Version: npm version

BranchBuild status
masterBuild Status
developBuild Status

Requirements

This package uses the git CLI. You must to have it installed on your machine to use this module. Go here to download it.

installation

This package is meant to be used by other nodejs applications and it's published on NPM

    $ npm install gitcapsule

Changes

  • Basic support to the git status command.

Examples

This example shows a basic flow using gitcapsule

const gitCapsule = require("gitcapsule");

var repositoryOptions = {
    "prepareBasePath": true
}

var gitRepository = gitCapsule.createGitRepository("/repo/testAll", repositoryOptions)
gitRepository.on("cloned", function (data) {
    var latestCommit = "";
    gitRepository.fetch(function (error, data) {
        if (error !== null) {
            console.error(error.toString());
            process.abort();
        }

        gitRepository.checkout("develop");
    });
});

gitRepository.on("checkedout", function (data) {
    gitRepository.pull(function (error, data) {
        if (error !== null) {
            console.error(error.toString());
            process.abort();
        }

        gitRepository.getLatestCommit(function (error, data) {
            if (error !== null) {
                console.error(error.toString());
                process.abort();
            }

            latestCommit = data.commit;
            console.log("Latest commit: " + latestCommit);
            process.exit();
        })
    });
});

gitRepository.on("error", function (error) {
    console.error(error.toString());
});

gitRepository.clone("https://github.com/jmtvms/GitCapsule.git");

Available events

Those are the available events on the GitRepository. Those events may be used in place of the callback functions, since those are optional.

  • error - When a error occurs on any command.
  • cloned - When the clone(sting, Function(error, cloneResponse)) function is sucessfuly executed.
  • fetched - When the fetch(Function(error, fetchResponse)) function is sucessfuly executed.
  • pulled - When the pull(Function(error, pullResponse)) function is sucessfuly executed.
  • gotLatestCommit - When the getLatestCommit(Function(error, latestCommitResponse)) function is sucessfuly executed.
  • checkedOut - When the checkout(sting, Function(error, checkoutResponse)) function is sucessfuly executed.
  • gotStatus - When the status(Function(error, statusResponse)) function is sucessfuly executed.

Responses

Those responses are passes on the callback or event functions

  • baseResponse - All responses derive from this response and have this fieds available.
    • The responses cloneResponse, fetchResponse and checkoutResponse are exactly equal to baseResponse.
{
    raw: string; //The raw output from the git CLI
    lines: string[]; //The output from the git CLI splited in lines.
}
  • pullResponse
{
    //...baseResponse fields...
    alreadyUpToDate: boolean; //If the local repository is already up to date with the remote.
}
  • latestCommitResponse
{
    //...baseResponse fields...
    commit: string; //The hash that identify the HEAD commit.
}
  • statusResponse
{
    //...baseResponse fields...
    isRepository: boolean; //If the folder is a git repository.
}
Help us to make this the best GIT package for node.

To contribute to this package, just ask us or create a pull request.

0.5.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago