Module: GitApi

GitApi

Source:

Members

<static> AJAX_ERROR

Indicates an unexpected ajax error when trying to make a request
Source:

<static> BRANCH_NAME_NOT_VALID

The branch doesn't follow valid git branch naming rules.
Source:

<static> CLONE_DIR_NOT_EMPTY

trying to clone into a non-empty directory
Source:

<static> CLONE_GIT_DIR_IN_USE

Trying to clone into directory that contains a .git directory that already contains objects
Source:

<static> COMMIT_NO_CHANGES

A commit was attempted but the local git repo has no new changes to commit
Source:

<static> FILE_IO_ERROR

Indicates an unexpected error in the HTML5 file system.
Source:

<static> HTTP_AUTH_ERROR

401 when attempting to make a request.
Source:

<static> OBJECT_STORE_CORRUPTED

Indicates an unexpected problem retrieving objects
Source:

<static> PULL_NON_FAST_FORWARD

A pull was attempted that would require a non-fast-forward. The API only supports fast forward merging at the moment.
Source:

<static> PULL_UP_TO_DATE

A pull was attempted but the local git repo is up to date
Source:

<static> PUSH_NO_CHANGES

A push was attempted but the remote repo is up to date.
Source:

<static> PUSH_NO_REMOTE

Trying to push a repo without a valid remote. This can happen if it's a first push to blank repo and a url wasn't specified as one of the options.
Source:

<static> PUSH_NON_FAST_FORWARD

A push was attempted but the remote has new commits that the local repo doesn't know about. You would normally do a pull and merge remote changes first. Unfortunately, this isn't possible with this API. As a workaround, you could create and checkout a new branch and then do a push.
Source:

<static> REMOTE_BRANCH_NOT_FOUND

No branch found with the name given.
Source:

<static> UNCOMMITTED_CHANGES

A pull was attempted with uncommitted changed in the working copy
Source:

Methods

<static> branch(options, success, error)

Creates a local branch. You will need to call the checkout api command to check it out.
Parameters:
Name Type Argument Description
options Object
Properties
Name Type Description
dir DirectoryEntry an HTML5 DirectoryEntry that contains a local git repo
branch String Name of the branch to create
success successCallback callback that gets notified after the push is completed successfully.
error errorCallback <optional>
callback that gets notified if there is an error
Source:

<static> checkForUncommittedChanges(options, success, error)

Looks in the working directory for uncommitted changes. This is faster than attempting a commit and having it fail.
Parameters:
Name Type Argument Description
options Object
Properties
Name Type Description
dir DirectoryEntry an HTML5 DirectoryEntry that contains a local git repo
success successCallback callback that gets notified after the push is completed successfully.
error errorCallback <optional>
callback that gets notified if there is an error
Source:

<static> checkout(options, success, error)

Checks out a local branch.
Parameters:
Name Type Argument Description
options Object
Properties
Name Type Description
dir DirectoryEntry an HTML5 DirectoryEntry that contains a local git repo
branch String Name of the branch to checkout
success successCallback callback that gets notified after the push is completed successfully.
error errorCallback <optional>
callback that gets notified if there is an error
Source:

<static> clone(options, success, error)

Clones a remote git repo into a local HTML5 DirectoryEntry. It only requests a single branch. This will either be the branch specified or the HEAD at specified url. You can also specify the depth of the clone. It's recommended that a depth of 1 always be given since the api does not currently give a way to access the commit history of a repo.
Parameters:
Name Type Argument Description
options Object
Properties
Name Type Argument Default Description
dir DirectoryEntry an HTML5 DirectoryEntry to clone the repo into
branch String <optional>
HEAD the name of the remote branch to clone.
url String the url of the repo to clone from
depth Number <optional>
the depth of the clone. Equivalent to the --depth option from git-clone
username String <optional>
User name to authenticate with if the repo supports basic auth
password String <optional>
password to authenticate with if the repo supports basic auth
progress progressCallback <optional>
callback that gets notified of progress events.
success successCallback callback that gets notified after the clone is completed successfully
error errorCallback <optional>
callback that gets notified if there is an error
Source:

<static> commit(options, success, error)

Looks for changes in the working directory since the last commit and adds them to the local git repo history. Some caveats
  • This is does an implicit "git add" of all changes including previously untracked files.
  • A Tree created by this command will only have two file modes: 40000 for folders (subtrees) and 100644 for files (blobs).
  • Ignores any rules in .gitignore
Parameters:
Name Type Argument Description
options Object
Properties
Name Type Description
dir DirectoryEntry an HTML5 DirectoryEntry to look for changes and commit them to the .git subdirectory in the same driectory
name String The name that will appear in the commit log as the name of the author and committer.
email String The email that will appear in the commit log as the email of the author and committer.
commitMsg String The message that will appear in the commit log
success successCallback callback that gets notified after the commit is completed successfully.
error errorCallback <optional>
callback that gets notified if there is an error
Source:

<static> getCurrentBranch(options, success, error)

Retrieves the name of the currently checked out local branch .
Parameters:
Name Type Argument Description
options Object
Properties
Name Type Description
dir DirectoryEntry an HTML5 DirectoryEntry that contains a local git repo
success successCallback callback that gets notified after the push is completed successfully.
error errorCallback <optional>
callback that gets notified if there is an error
Source:

<static> getLocalBranches(options, success, error)

Gets a list of all local branches.
Parameters:
Name Type Argument Description
options Object
Properties
Name Type Description
dir DirectoryEntry an HTML5 DirectoryEntry that contains a local git repo
success successCallback callback that gets notified after the push is completed successfully.
error errorCallback <optional>
callback that gets notified if there is an error
Source:

<static> getRemoteBranches(options, success, error)

Gets a list of all remote branches.
Parameters:
Name Type Argument Description
options Object
Properties
Name Type Argument Description
url String url of a remote git repo
username String <optional>
User name to authenticate with if the repo supports basic auth
password String <optional>
password to authenticate with if the repo supports basic auth
success successCallback callback that gets notified after the push is completed successfully.
error errorCallback <optional>
callback that gets notified if there is an error
Source:

<static> pull(options, success, error)

Does a pull from the url the local repo was cloned from. Will only succeed for fast-forward pulls. If a merge is required, it calls the error callback
Parameters:
Name Type Argument Description
options Object
Properties
Name Type Argument Description
dir DirectoryEntry an HTML5 DirectoryEntry that contains a local git repo to pull updates into
username String <optional>
User name to authenticate with if the repo supports basic auth
password String <optional>
password to authenticate with if the repo supports basic auth
progress progressCallback <optional>
callback that gets notified of progress events.
success successCallback callback that gets notified after the pull is completed successfully.
error errorCallback <optional>
callback that gets notified if there is an error
Source:

<static> push(options, success, error)

Pushes local commits to a remote repo. This is usually the remote repo the local repo was cloned from. It can also be the initial push to a blank repo.
Parameters:
Name Type Argument Description
options Object
Properties
Name Type Argument Description
dir DirectoryEntry an HTML5 DirectoryEntry to push changes from
url String <optional>
the remote url to push changes to. This defaults to the url the repo was cloned from.
username String <optional>
User name to authenticate with if the repo supports basic auth
password String <optional>
password to authenticate with if the repo supports basic auth
progress progressCallback <optional>
callback that gets notified of progress events.
success successCallback callback that gets notified after the push is completed successfully.
error errorCallback <optional>
callback that gets notified if there is an error
Source: