wilton.js  v202103141
 All Namespaces Functions
Functions
git Namespace Reference

wilton/git
Work with Git repositories More...

Functions

Undefined clone (String url, String repo, Object|Undefined options, Function|Undefined callback)
 Clone remote Git repository.
Undefined pull (String repo, Object|Undefined options, Function|Undefined callback)
 Pulls a branch from a remote Git repository.
String revparseHead (String repo, Function|Undefined callback)
 Read the revision ID of the repo HEAD.

Detailed Description

This module allows to work with remote and local Git repositories.

Usage example:

// clone local repo
git.clone("file://path/to/my/repo", "path/to/dest");
// clone over SSH using password auth
git.clone("git+ssh://androiddev@127.0.0.1/home/androiddev/app", repo, {
password: "mypwd"
});
// clone over SSH using key auth
git.clone("git+ssh://androiddev@127.0.0.1/home/androiddev/app", repo, {
sshPublicKeyPath: "/home/alex/.ssh/id_rsa.pub",
sshPrivateKeyPath: "/home/alex/.ssh/id_rsa"
});
// clone over HTTPS using passord auth
git.clone("https://bitbucket.org/orgid/repo.git", "path/to/dest", {
username: "myuser",
password: "mypwd"
});
// pull remote branch
git.pull("path/to/dest", {
username: "myuser",
password: "mypwd",
branch: "master"
});
// get current HEAD revision
var sha1 = git.revparseHead("path/to/repo");

Function Documentation

Undefined git::clone ( String  url,
String  repo,
Object|Undefined  options,
Function|Undefined  callback 
)

Clones repote Git repository to the specified path, supports Local, SSH and HTTPS(S) transport protocols.

For SSH authentication username must be specified as a part of the URL, example: git+ssh://myuser@127.0.0.1/path/to/my/app

Username may be specified either in URL or as a username option; if both variants are used at the same time - URL takes preference.

Parameters
urlString URL of the remote Git repository, must have one of the supported protocol prfixes: file://, git+ssh://, http://, https://
repoString path to the destination local repository
optionsObject|Undefined configuration object, can be omitted, see possible options below
callbackFunction|Undefined callback to receive result or error
Returns
Undefined

Options

  • branch String|Undefined Git branch to checkout after the clone, default value: master
  • username String|Undefined user name that should be used for Git authentication over SSH or HTTPS
  • password String|Undefined password that should be used for Git authentication over SSH or HTTPS
  • sshPublicKeyPath String|Undefined path to the public SSH key file that should be used for authentication with the SSH server
  • sshPrivateKeyPath String|Undefined path to the private SSH key file that should be used for authentication with the SSH server
  • httpsCheckCertificate Boolean|Undefined whether HTTPS certificate of the Git server should be checked for validness, default value: true
Undefined git::pull ( String  repo,
Object|Undefined  options,
Function|Undefined  callback 
)

Fetches changes from the origin remote repository and checkouts the specified remote branch.

Uses origin remote record from the specified git repo.

See clone() for the details about the protocols and authentication.

Parameters
repoString path to the local repository
optionsObject|Undefined configuration object, can be omitted, see possible options below
callbackFunction|Undefined callback to receive result or error
Returns
Undefined

Options

  • branch String|Undefined Git branch to checkout after the fetch, default value: master
  • username String|Undefined user name that should be used for Git authentication over SSH or HTTPS
  • password String|Undefined password that should be used for Git authentication over SSH or HTTPS
  • sshPublicKeyPath String|Undefined path to the public SSH key file that should be used for authentication with the SSH server
  • sshPrivateKeyPath String|Undefined path to the private SSH key file that should be used for authentication with the SSH server
  • httpsCheckCertificate Boolean|Undefined whether HTTPS certificate of the Git server should be checked for validness, default value: true
String git::revparseHead ( String  repo,
Function|Undefined  callback 
)

Reads the revision ID of the repo HEAD

Parameters
repoString path to the local repository
callbackFunction|Undefined callback to receive result or error
Returns
String 40 symbols revision ID SHA1