pj-nodegit 0.18.4 → 0.18.5
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/README.md +3 -0
- package/lib/attr.js +20 -0
- package/lib/blame.js +20 -0
- package/lib/blob.js +73 -0
- package/lib/branch.js +19 -0
- package/lib/buf.js +11 -0
- package/lib/checkout.js +51 -0
- package/lib/cherrypick.js +73 -0
- package/lib/clone.js +33 -0
- package/lib/commit.js +437 -0
- package/lib/config.js +25 -0
- package/lib/convenient_hunks.js +61 -0
- package/lib/convenient_patch.js +131 -0
- package/lib/credential.js +33 -0
- package/lib/diff.js +113 -0
- package/lib/diff_file.js +38 -0
- package/lib/diff_line.js +32 -0
- package/lib/enums.js +689 -0
- package/lib/error.js +17 -0
- package/lib/filter_registry.js +25 -0
- package/lib/index.js +103 -0
- package/lib/libgit2.js +6 -0
- package/lib/merge.js +72 -0
- package/lib/nodegit.js +1333 -0
- package/lib/note.js +17 -0
- package/lib/object.js +45 -0
- package/lib/odb_object.js +9 -0
- package/lib/oid.js +23 -0
- package/lib/rebase.js +142 -0
- package/lib/reference.js +213 -0
- package/lib/remote.js +270 -0
- package/lib/repository.js +1982 -0
- package/lib/reset.js +76 -0
- package/lib/revert.js +77 -0
- package/lib/revwalk.js +142 -0
- package/lib/signature.js +38 -0
- package/lib/stash.js +62 -0
- package/lib/status.js +18 -0
- package/lib/status_file.js +106 -0
- package/lib/status_list.js +12 -0
- package/lib/submodule.js +51 -0
- package/lib/tag.js +135 -0
- package/lib/tree.js +175 -0
- package/lib/tree_entry.js +99 -0
- package/lib/utils/lookup_wrapper.js +39 -0
- package/lib/utils/normalize_fetch_options.js +43 -0
- package/lib/utils/normalize_options.js +29 -0
- package/lib/utils/shallow_clone.js +14 -0
- package/package.json +1 -1
package/lib/README.md
ADDED
package/lib/attr.js
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
var util = require("util");
|
2
|
+
var NodeGit = require("../");
|
3
|
+
|
4
|
+
NodeGit.Attr.STATES = {};
|
5
|
+
var DEPRECATED_STATES = {
|
6
|
+
UNSPECIFIED_T: "UNSPECIFIED",
|
7
|
+
TRUE_T: "TRUE",
|
8
|
+
FALSE_T: "FALSE",
|
9
|
+
VALUE_T: "STRING"
|
10
|
+
};
|
11
|
+
|
12
|
+
Object.keys(DEPRECATED_STATES).forEach((key) => {
|
13
|
+
const newKey = DEPRECATED_STATES[key];
|
14
|
+
Object.defineProperty(NodeGit.Attr.STATES, key, {
|
15
|
+
get: util.deprecate(
|
16
|
+
() => NodeGit.Attr.VALUE[newKey],
|
17
|
+
`Use NodeGit.Attr.VALUE.${newKey} instead of NodeGit.Attr.STATES.${key}.`
|
18
|
+
)
|
19
|
+
});
|
20
|
+
});
|
package/lib/blame.js
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
var NodeGit = require("../");
|
2
|
+
var normalizeOptions = NodeGit.Utils.normalizeOptions;
|
3
|
+
var Blame = NodeGit.Blame;
|
4
|
+
|
5
|
+
var _file = Blame.file;
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Retrieve the blame of a file
|
9
|
+
*
|
10
|
+
* @async
|
11
|
+
* @param {Repository} repo that contains the file
|
12
|
+
* @param {String} path to the file to get the blame of
|
13
|
+
* @param {BlameOptions} [options] Options for the blame
|
14
|
+
* @return {Blame} the blame
|
15
|
+
*/
|
16
|
+
Blame.file = function(repo, path, options) {
|
17
|
+
options = normalizeOptions(options, NodeGit.BlameOptions);
|
18
|
+
|
19
|
+
return _file.call(this, repo, path, options);
|
20
|
+
};
|
package/lib/blob.js
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
var util = require("util");
|
2
|
+
var NodeGit = require("../");
|
3
|
+
var Blob = NodeGit.Blob;
|
4
|
+
var LookupWrapper = NodeGit.Utils.lookupWrapper;
|
5
|
+
var TreeEntry = NodeGit.TreeEntry;
|
6
|
+
var normalizeOptions = NodeGit.Utils.normalizeOptions;
|
7
|
+
|
8
|
+
var _filteredContent = Blob.filteredContent;
|
9
|
+
var _filter = Blob.prototype.filter;
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Retrieves the blob pointed to by the oid
|
13
|
+
* @async
|
14
|
+
* @param {Repository} repo The repo that the blob lives in
|
15
|
+
* @param {String|Oid|Blob} id The blob to lookup
|
16
|
+
* @return {Blob}
|
17
|
+
*/
|
18
|
+
Blob.lookup = LookupWrapper(Blob);
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Retrieve the content of the Blob.
|
22
|
+
*
|
23
|
+
* @return {Buffer} Contents as a buffer.
|
24
|
+
*/
|
25
|
+
Blob.prototype.content = function() {
|
26
|
+
return this.rawcontent().toBuffer(this.rawsize());
|
27
|
+
};
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Retrieve the Blob's type.
|
31
|
+
*
|
32
|
+
* @return {Number} The filemode of the blob.
|
33
|
+
*/
|
34
|
+
Blob.prototype.filemode = function() {
|
35
|
+
var FileMode = TreeEntry.FILEMODE;
|
36
|
+
|
37
|
+
return this.isBinary() ? FileMode.EXECUTABLE : FileMode.BLOB;
|
38
|
+
};
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Retrieve the Blob's content as String.
|
42
|
+
*
|
43
|
+
* @return {String} Contents as a string.
|
44
|
+
*/
|
45
|
+
Blob.prototype.toString = function() {
|
46
|
+
return this.content().toString();
|
47
|
+
};
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Get a buffer with the filtered content of a blob.
|
51
|
+
*
|
52
|
+
* This applies filters as if the blob was being checked out to the
|
53
|
+
* working directory under the specified filename. This may apply
|
54
|
+
* CRLF filtering or other types of changes depending on the file
|
55
|
+
* attributes set for the blob and the content detected in it.
|
56
|
+
*
|
57
|
+
* @async
|
58
|
+
* @param asPath Path used for file attribute lookups, etc.
|
59
|
+
* @param opts Options to use for filtering the blob
|
60
|
+
* @return {Promise<string>}
|
61
|
+
*/
|
62
|
+
Blob.prototype.filter = function(asPath, opts) {
|
63
|
+
if (opts) {
|
64
|
+
opts = normalizeOptions(opts, NodeGit.BlobFilterOptions);
|
65
|
+
}
|
66
|
+
return _filter.call(this, asPath, opts);
|
67
|
+
};
|
68
|
+
|
69
|
+
Blob.filteredContent = util.deprecate(
|
70
|
+
_filteredContent,
|
71
|
+
"NodeGit.Blob.filteredContent is deprecated" +
|
72
|
+
" use NodeGit.Blob.prototype.filter instead."
|
73
|
+
);
|
package/lib/branch.js
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
var NodeGit = require("../");
|
2
|
+
var Branch = NodeGit.Branch;
|
3
|
+
|
4
|
+
var _remoteName = Branch.remoteName;
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Retrieve the Branch's Remote Name as a String.
|
8
|
+
*
|
9
|
+
* @async
|
10
|
+
* @param {Repository} repo The repo to get the remote name from
|
11
|
+
* @param {String} the refname of the branch
|
12
|
+
* @return {String} remote name as a string.
|
13
|
+
*/
|
14
|
+
Branch.remoteName = function(repo, remoteRef) {
|
15
|
+
return _remoteName.call(this, repo, remoteRef)
|
16
|
+
.then(function(remoteNameBuffer) {
|
17
|
+
return remoteNameBuffer.toString();
|
18
|
+
});
|
19
|
+
};
|
package/lib/buf.js
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
const { Buf } = require("../");
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Sets the content of a GitBuf to a string.
|
5
|
+
* @param {string} The utf8 value to set in the buffer.
|
6
|
+
* The string will be null terminated.
|
7
|
+
*/
|
8
|
+
Buf.prototype.setString = function(content) {
|
9
|
+
const buf = Buffer.from(content + "\0", "utf8");
|
10
|
+
this.set(buf, buf.length);
|
11
|
+
};
|
package/lib/checkout.js
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
var NodeGit = require("../");
|
2
|
+
var normalizeOptions = NodeGit.Utils.normalizeOptions;
|
3
|
+
|
4
|
+
var Checkout = NodeGit.Checkout;
|
5
|
+
var _head = Checkout.head;
|
6
|
+
var _index = Checkout.index;
|
7
|
+
var _tree = Checkout.tree;
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Patch head checkout to automatically coerce objects.
|
11
|
+
*
|
12
|
+
* @async
|
13
|
+
* @param {Repository} repo The repo to checkout head
|
14
|
+
* @param {CheckoutOptions} [options] Options for the checkout
|
15
|
+
* @return {Void} checkout complete
|
16
|
+
*/
|
17
|
+
Checkout.head = function(url, options) {
|
18
|
+
options = normalizeOptions(options || {}, NodeGit.CheckoutOptions);
|
19
|
+
|
20
|
+
return _head.call(this, url, options);
|
21
|
+
};
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Patch index checkout to automatically coerce objects.
|
25
|
+
*
|
26
|
+
* @async
|
27
|
+
* @param {Repository} repo The repo to checkout an index
|
28
|
+
* @param {Index} index The index to checkout
|
29
|
+
* @param {CheckoutOptions} [options] Options for the checkout
|
30
|
+
* @return {Void} checkout complete
|
31
|
+
*/
|
32
|
+
Checkout.index = function(repo, index, options) {
|
33
|
+
options = normalizeOptions(options || {}, NodeGit.CheckoutOptions);
|
34
|
+
|
35
|
+
return _index.call(this, repo, index, options);
|
36
|
+
};
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Patch tree checkout to automatically coerce objects.
|
40
|
+
*
|
41
|
+
* @async
|
42
|
+
* @param {Repository} repo
|
43
|
+
* @param {String|Tree|Commit|Reference} treeish
|
44
|
+
* @param {CheckoutOptions} [options]
|
45
|
+
* @return {Void} checkout complete
|
46
|
+
*/
|
47
|
+
Checkout.tree = function(repo, treeish, options) {
|
48
|
+
options = normalizeOptions(options || {}, NodeGit.CheckoutOptions);
|
49
|
+
|
50
|
+
return _tree.call(this, repo, treeish, options);
|
51
|
+
};
|
@@ -0,0 +1,73 @@
|
|
1
|
+
var NodeGit = require("../");
|
2
|
+
var shallowClone = NodeGit.Utils.shallowClone;
|
3
|
+
var normalizeOptions = NodeGit.Utils.normalizeOptions;
|
4
|
+
|
5
|
+
var Cherrypick = NodeGit.Cherrypick;
|
6
|
+
var _cherrypick = Cherrypick.cherrypick;
|
7
|
+
var _commit = Cherrypick.commit;
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Cherrypick a commit and, changing the index and working directory
|
11
|
+
*
|
12
|
+
* @async
|
13
|
+
* @param {Repository} repo The repo to checkout head
|
14
|
+
* @param {Commit} commit The commit to cherrypick
|
15
|
+
* @param {CherrypickOptions} [options] Options for the cherrypick
|
16
|
+
* @return {int} 0 on success, -1 on failure
|
17
|
+
*/
|
18
|
+
Cherrypick.cherrypick = function(repo, commit, options) {
|
19
|
+
var mergeOpts;
|
20
|
+
var checkoutOpts;
|
21
|
+
|
22
|
+
if (options) {
|
23
|
+
options = shallowClone(options);
|
24
|
+
mergeOpts = options.mergeOpts;
|
25
|
+
checkoutOpts = options.checkoutOpts;
|
26
|
+
delete options.mergeOpts;
|
27
|
+
delete options.checkoutOpts;
|
28
|
+
}
|
29
|
+
|
30
|
+
options = normalizeOptions(options, NodeGit.CherrypickOptions);
|
31
|
+
|
32
|
+
if (mergeOpts) {
|
33
|
+
options.mergeOpts =
|
34
|
+
normalizeOptions(mergeOpts, NodeGit.MergeOptions);
|
35
|
+
}
|
36
|
+
|
37
|
+
if (checkoutOpts) {
|
38
|
+
options.checkoutOpts =
|
39
|
+
normalizeOptions(checkoutOpts, NodeGit.CheckoutOptions);
|
40
|
+
}
|
41
|
+
|
42
|
+
return _cherrypick.call(this, repo, commit, options);
|
43
|
+
};
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Cherrypicks the given commit against "our" commit, producing an index that
|
47
|
+
* reflects the result of the cherrypick. The index is not backed by a repo.
|
48
|
+
*
|
49
|
+
* @async
|
50
|
+
* @param {Repository} repo The repo to cherrypick commits
|
51
|
+
* @param {Commit} cherrypick_commit The commit to cherrypick
|
52
|
+
* @param {Commit} our_commit The commit to revert against
|
53
|
+
* @param {int} mainline The parent of the revert commit (1 or
|
54
|
+
* 2) if it's a merge, 0 otherwise
|
55
|
+
* @param {MergeOptions} [merge_options] Merge options for the cherrypick
|
56
|
+
* @return {int} 0 on success, -1 on failure
|
57
|
+
*/
|
58
|
+
Cherrypick.commit = function(
|
59
|
+
repo,
|
60
|
+
cherrypick_commit,
|
61
|
+
our_commit,
|
62
|
+
mainline,
|
63
|
+
merge_options) {
|
64
|
+
merge_options = normalizeOptions(merge_options, NodeGit.MergeOptions);
|
65
|
+
|
66
|
+
return _commit.call(
|
67
|
+
this,
|
68
|
+
repo,
|
69
|
+
cherrypick_commit,
|
70
|
+
our_commit,
|
71
|
+
mainline,
|
72
|
+
merge_options);
|
73
|
+
};
|
package/lib/clone.js
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
var NodeGit = require("../");
|
2
|
+
var shallowClone = NodeGit.Utils.shallowClone;
|
3
|
+
var normalizeFetchOptions = NodeGit.Utils.normalizeFetchOptions;
|
4
|
+
var normalizeOptions = NodeGit.Utils.normalizeOptions;
|
5
|
+
|
6
|
+
var Clone = NodeGit.Clone;
|
7
|
+
var _clone = Clone.clone;
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Patch repository cloning to automatically coerce objects.
|
11
|
+
*
|
12
|
+
* @async
|
13
|
+
* @param {String} url url of the repository
|
14
|
+
* @param {String} local_path local path to store repository
|
15
|
+
* @param {CloneOptions} [options]
|
16
|
+
* @return {Repository} repo
|
17
|
+
*/
|
18
|
+
Clone.clone = function(url, local_path, options) {
|
19
|
+
var fetchOpts = normalizeFetchOptions(options && options.fetchOpts);
|
20
|
+
|
21
|
+
if (options) {
|
22
|
+
options = shallowClone(options);
|
23
|
+
delete options.fetchOpts;
|
24
|
+
}
|
25
|
+
|
26
|
+
options = normalizeOptions(options, NodeGit.CloneOptions);
|
27
|
+
|
28
|
+
if (options) {
|
29
|
+
options.fetchOpts = fetchOpts;
|
30
|
+
}
|
31
|
+
|
32
|
+
return _clone.call(this, url, local_path, options);
|
33
|
+
};
|