Class Repository
- Defined in: bindings.js
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Represents an open Git repository.
|
Method Summary
| Method Attributes | Method Name and Description |
|---|---|
|
createBlob(data, callback)
Creates a new Blob in the Repository.
|
|
|
createCommit(data, callback)
Creates a new Commit and immediately stores it in the Repository.
|
|
|
createOidReference(name, oid, callback)
Creates a new OID (direct) Reference in the Repository.
|
|
|
createSymbolicReference(name, target, callback)
Creates a new symbolic (indirect) Reference in the Repository.
|
|
|
createTag(data, callback)
Creates a new Tag with the provided data.
|
|
|
createTree(data, callback)
Creates a new Tree in the Repository with the given data.
|
|
|
createWalker(callback)
Creates a new RevisionWalker.
|
|
|
exists(sha1, callback, true)
Checks if the Repository contains an object with the specified sha1 hash.
|
|
|
getBlob(sha1, callback)
Retrieves a Blob from the Repository with given id.
|
|
|
getCommit(sha1, callback)
Retrieves a Commit from the repository with the given sha1 hash id.
|
|
|
getIndex(callback)
Loads the Index for the Repository.
|
|
|
getReference(name, callback)
Retrieves a Reference from the Repository with the given name.
|
|
|
getTag(sha1, callback)
Gets a Tag from the Repository with the given sha1 hash id.
|
|
|
getTree(sha1, callback)
Retrieves a Tree from the repository with the given sha1 hash id.
|
|
|
listReferences(flags, callback)
Requests a list of References from the Repository.
|
|
|
packReferences(callback)
Orders the Repository to pack all loose References.
|
Class Detail
Repository()
Represents an open Git repository. The majority of the functionality offered
by Gitteh is contained in here.
Method Detail
-
{Blob} createBlob(data, callback)Creates a new Blob in the Repository.
- Parameters:
- {Object} data
- The data for the Blob. Valid fields in this data are the same as the fields in Blob
- {Function} callback Optional
- If provided, the Blob will be created asynchronously, and the results passed to the callback.
- Throws:
- If an error occurs while creating the Blob.
- Returns:
- {Blob}
-
createCommit(data, callback)Creates a new Commit and immediately stores it in the Repository.
- Parameters:
- {Object} data
- The data for the commit. Should be the same properties that a Commit contains.
- {Function} callback Optional
- If provided, the Commit will be created asynchronously, and the newly created Commit object returned to the callback.
- Throws:
- If Commit couldn't be created.
-
{Reference} createOidReference(name, oid, callback)Creates a new OID (direct) Reference in the Repository.
- Parameters:
- {String} name
- The name of the Reference to be created.
- {String} oid
- The ID of the Commit being pointed to.
- {Function} callback Optional
- When provided, the Reference shall be created asynchronously. The callback will be notified when creation is complete.
- Throws:
- If there was an error creating the Reference.
- Returns:
- {Reference}
-
{Reference} createSymbolicReference(name, target, callback)Creates a new symbolic (indirect) Reference in the Repository.
- Parameters:
- {String} name
- The name of the Reference to be created.
- {String} target
- The name of the Reference being pointed to.
- {Function} callback Optional
- When provided, the Reference shall be created asynchronously. The callback will be notified when creation is complete.
- Throws:
- If there was an error creating the Reference.
- Returns:
- {Reference}
-
{Tag} createTag(data, callback)Creates a new Tag with the provided data.
- Parameters:
- {Object} data
- The data to be stored in the Tag. The fields in this object should be the same as the fields in a Tag.
- {Function} callback Optional
- If provided, the tag will be created asynchronously and the newly created Tag provided to the callback.
- Throws:
- If an error occurred whilst creating the Tag.
- Returns:
- {Tag}
-
createTree(data, callback)Creates a new Tree in the Repository with the given data. NOTE: this is currently unimplemented.
- Parameters:
- {Object} data
- {Function} callback Optional
-
{RevisionWalker} createWalker(callback)Creates a new RevisionWalker.
- Parameters:
- {Function} callback Optional
- If provided, the walker will be created asychronously.
- Throws:
- If an error occurs.
- Returns:
- {RevisionWalker}
-
exists(sha1, callback, true)Checks if the Repository contains an object with the specified sha1 hash.
- Parameters:
- {String} sha1
- SHA1 hash id of the object being searched for.
- {Function} callback Optional
- If provided, the search will be performed asynchronously, with the result passed back to callback.
- {Boolean} true
- if object exists, false if not.
- Throws:
- If an error occurs.
-
{Blob} getBlob(sha1, callback)Retrieves a Blob from the Repository with given id.
- Parameters:
- {String} sha1
- The sha1 hash id of the blob.
- {Function} callback Optional
- If provided, the Blob will be retrieved asynchronously, and provided to the callback.
- Throws:
- If an error occurs while loading the Blob.
- Returns:
- {Blob}
-
{Commit} getCommit(sha1, callback)Retrieves a Commit from the repository with the given sha1 hash id.
- Parameters:
- {String} sha1
- The sha1 hash ID of the commit.
- {Function} callback Optional
- If callback is provided, Vommit will be retrieved asynchronously and passed to to the callback provided.
- Throws:
- If commit wasn't found, or there is some other error.
- Returns:
- {Commit}
-
{Index} getIndex(callback)Loads the Index for the Repository.
- Parameters:
- {Function} callback Optional
- If provided, the Index will be loaded asynchronously, and the result handed to the callback.
- Throws:
- If an error occurred while loading Index.
- Returns:
- {Index}
-
{Reference} getReference(name, callback)Retrieves a Reference from the Repository with the given name.
- Parameters:
- {String} name
- The name of the reference, for example: refs/heads/master. You may also retrieve HEAD using this method.
- {Function} callback Optional
- If provided, the reference will be obtained asychronously, and provided to the callback.
- Throws:
- If Reference does not exist, or some other error occured.
- Returns:
- {Reference}
-
{Tag} getTag(sha1, callback)Gets a Tag from the Repository with the given sha1 hash id.
- Parameters:
- {String} sha1
- the sha1 hash ID of the Tag.
- {Function} callback Optional
- When provided, the Tag will be retrieved asynchronously and results handed to the callback.
- Throws:
- If an error occurred while loading the Tag.
- Returns:
- {Tag}
-
{Tree} getTree(sha1, callback)Retrieves a Tree from the repository with the given sha1 hash id.
- Parameters:
- {String} sha1
- The sha1 hash ID of the tree.
- {Function} callback Optional
- If a callback is provided, the Tree will be retrieved asynchronously and returned via the callback given.
- Throws:
- If Tree wasn't found, or some other error occurs.
- Returns:
- {Tree}
-
{String[]} listReferences(flags, callback)Requests a list of References from the Repository. This will return a list of Strings, each String is a name of a reference in the Repository.
- Parameters:
- {Integer} flags Optional
- If provided, the list will be filtered based on input. Valid values are Gitteh.GIT_REF_OID, Gitteh.GIT_REF_SYMBOLIC, Gitteh.GIT_REF_PACKED, and Gitteh.GIT_REF_LISTALL
- {Function} callback Optional
- If provided, the list will be built asynchronously, and the results provided to the callback.
- Throws:
- If an error occurs during the listing process.
- Returns:
- {String[]}
- See:
- Gitteh.GIT_REF_OID
- Gitteh.GIT_REF_SYMBOLIC
- Gitteh.GIT_REF_PACKED
- Gitteh.GIT_REF_LISTALL
-
{Boolean} packReferences(callback)Orders the Repository to pack all loose References. This method will ensure any currently active References remain valid (even though they have now been moved inside the packed-references file).
- Parameters:
- {Function} callback Optional
- If provided, the packing process will be performed asynchronously and the callback notified of the result.
- Throws:
- If an error occurs during the packing process.
- Returns:
- {Boolean} true if successful