pj-nodegit 0.18.4 → 0.18.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/index.js
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
var util = require("util");
|
2
|
+
var NodeGit = require("../");
|
3
|
+
|
4
|
+
var Index = NodeGit.Index;
|
5
|
+
|
6
|
+
var _addAll = Index.prototype.addAll;
|
7
|
+
var _removeAll = Index.prototype.removeAll;
|
8
|
+
var _updateAll = Index.prototype.updateAll;
|
9
|
+
|
10
|
+
Index.prototype.addAll = function(pathspec, flags, matchedCallback) {
|
11
|
+
return _addAll.call(this, pathspec || "*", flags, matchedCallback, null);
|
12
|
+
};
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Return an array of the entries in this index.
|
16
|
+
* @return {Array<IndexEntry>} an array of IndexEntrys
|
17
|
+
*/
|
18
|
+
Index.prototype.entries = function() {
|
19
|
+
var size = this.entryCount();
|
20
|
+
var result = [];
|
21
|
+
|
22
|
+
for (var i = 0; i < size; i++) {
|
23
|
+
result.push(this.getByIndex(i));
|
24
|
+
}
|
25
|
+
|
26
|
+
return result;
|
27
|
+
};
|
28
|
+
|
29
|
+
Index.prototype.removeAll = function(pathspec, matchedCallback) {
|
30
|
+
return _removeAll.call(this, pathspec || "*", matchedCallback, null);
|
31
|
+
};
|
32
|
+
|
33
|
+
Index.prototype.updateAll = function(pathspec, matchedCallback) {
|
34
|
+
return _updateAll.call(this, pathspec || "*", matchedCallback, null);
|
35
|
+
};
|
36
|
+
|
37
|
+
// Deprecated -----------------------------------------------------------------
|
38
|
+
|
39
|
+
NodeGit.Index.CAP = {};
|
40
|
+
Object.keys(NodeGit.Index.CAPABILITY).forEach((key) => {
|
41
|
+
Object.defineProperty(NodeGit.Index.CAP, key, {
|
42
|
+
get: util.deprecate(
|
43
|
+
() => NodeGit.Index.CAPABILITY[key],
|
44
|
+
`Use NodeGit.Index.CAPABILITY.${key} instead of ` +
|
45
|
+
`NodeGit.Index.CAP.${key}.`
|
46
|
+
)
|
47
|
+
});
|
48
|
+
});
|
49
|
+
|
50
|
+
NodeGit.Enums.INDXENTRY_FLAG = {};
|
51
|
+
Object.defineProperty(NodeGit.Enums.INDXENTRY_FLAG, "IDXENTRY_EXTENDED", {
|
52
|
+
get: util.deprecate(
|
53
|
+
() => NodeGit.Index.ENTRY_FLAG.ENTRY_EXTENDED,
|
54
|
+
"Use NodeGit.Index.ENTRY_FLAG.ENTRY_EXTENDED instead of " +
|
55
|
+
"NodeGit.Enums.INDXENTRY_FLAG.IDXENTRY_EXTENDED."
|
56
|
+
)
|
57
|
+
});
|
58
|
+
Object.defineProperty(NodeGit.Enums.INDXENTRY_FLAG, "IDXENTRY_VALID", {
|
59
|
+
get: util.deprecate(
|
60
|
+
() => NodeGit.Index.ENTRY_FLAG.ENTRY_VALID,
|
61
|
+
"Use NodeGit.Index.ENTRY_FLAG.ENTRY_VALID instead of " +
|
62
|
+
"NodeGit.Enums.INDXENTRY_FLAG.IDXENTRY_VALID."
|
63
|
+
)
|
64
|
+
});
|
65
|
+
|
66
|
+
NodeGit.Enums.IDXENTRY_EXTENDED_FLAG = {};
|
67
|
+
var EXTENDED_FLAGS_MAP = {
|
68
|
+
IDXENTRY_INTENT_TO_ADD: "ENTRY_INTENT_TO_ADD",
|
69
|
+
IDXENTRY_SKIP_WORKTREE: "ENTRY_SKIP_WORKTREE",
|
70
|
+
S: "S",
|
71
|
+
IDXENTRY_UPTODATE: "ENTRY_UPTODATE"
|
72
|
+
};
|
73
|
+
Object.keys(EXTENDED_FLAGS_MAP).forEach((key) => {
|
74
|
+
const newKey = EXTENDED_FLAGS_MAP[key];
|
75
|
+
Object.defineProperty(NodeGit.Enums.IDXENTRY_EXTENDED_FLAG, key, {
|
76
|
+
get: util.deprecate(
|
77
|
+
() => NodeGit.Index.ENTRY_EXTENDED_FLAG[newKey],
|
78
|
+
`Use NodeGit.Index.ENTRY_EXTENDED_FLAG.${newKey} instead of ` +
|
79
|
+
`NodeGit.Enums.IDXENTRY_EXTENDED_FLAG.${key}.`
|
80
|
+
)
|
81
|
+
});
|
82
|
+
});
|
83
|
+
|
84
|
+
var DEPRECATED_EXTENDED_FLAGS = {
|
85
|
+
IDXENTRY_EXTENDED2: 32768,
|
86
|
+
IDXENTRY_UPDATE: 1,
|
87
|
+
IDXENTRY_REMOVE: 2,
|
88
|
+
IDXENTRY_ADDED: 8,
|
89
|
+
IDXENTRY_HASHED: 16,
|
90
|
+
IDXENTRY_UNHASHED: 32,
|
91
|
+
IDXENTRY_WT_REMOVE: 64,
|
92
|
+
IDXENTRY_CONFLICTED: 128,
|
93
|
+
IDXENTRY_UNPACKED: 256,
|
94
|
+
IDXENTRY_NEW_SKIP_WORKTREE: 512,
|
95
|
+
};
|
96
|
+
Object.keys(DEPRECATED_EXTENDED_FLAGS).forEach((key) => {
|
97
|
+
Object.defineProperty(NodeGit.Enums.IDXENTRY_EXTENDED_FLAG, key, {
|
98
|
+
get: util.deprecate(
|
99
|
+
() => DEPRECATED_EXTENDED_FLAGS[key],
|
100
|
+
"LibGit2 has removed this flag for public usage."
|
101
|
+
)
|
102
|
+
});
|
103
|
+
});
|
package/lib/libgit2.js
ADDED
package/lib/merge.js
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
var NodeGit = require("../");
|
2
|
+
var normalizeOptions = NodeGit.Utils.normalizeOptions;
|
3
|
+
|
4
|
+
var Merge = NodeGit.Merge;
|
5
|
+
var _commits = Merge.commits;
|
6
|
+
var _merge = Merge.merge;
|
7
|
+
var _file = Merge.file;
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Merge two files as they exist in the in-memory data structures, using
|
11
|
+
* the given common ancestor as the baseline. (git_merge_file)
|
12
|
+
*
|
13
|
+
* @param {MergeFileInput} ancestor The contents of the ancestor file
|
14
|
+
* @param {MergeFileInput} ours The contents of the file in "our" side
|
15
|
+
* @param {MergeFileInput} theirs The contents of the file in "theirs" side
|
16
|
+
* @param {MergeFileOptions} [options] The merge file options
|
17
|
+
* or `NULL` for defaults
|
18
|
+
*/
|
19
|
+
Merge.file = function(ancestor, ours, theirs, options) {
|
20
|
+
ancestor = normalizeOptions(ancestor, NodeGit.MergeFileInput);
|
21
|
+
ours = normalizeOptions(ours, NodeGit.MergeFileInput);
|
22
|
+
theirs = normalizeOptions(theirs, NodeGit.MergeFileInput);
|
23
|
+
options = normalizeOptions(options || {}, NodeGit.MergeFileOptions);
|
24
|
+
return _file.call(this, ancestor, ours, theirs, options);
|
25
|
+
};
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Merge 2 commits together and create an new index that can
|
29
|
+
* be used to create a merge commit.
|
30
|
+
*
|
31
|
+
* @param {Repository} repo Repository that contains the given commits
|
32
|
+
* @param {Commit} ourCommit The commit that reflects the destination tree
|
33
|
+
* @param {Commit} theirCommit The commit to merge into ourCommit
|
34
|
+
* @param {MergeOptions} [options] The merge tree options (null for default)
|
35
|
+
*/
|
36
|
+
Merge.commits = function(repo, ourCommit, theirCommit, options) {
|
37
|
+
options = normalizeOptions(options, NodeGit.MergeOptions);
|
38
|
+
|
39
|
+
return Promise.all([
|
40
|
+
repo.getCommit(ourCommit),
|
41
|
+
repo.getCommit(theirCommit)
|
42
|
+
]).then(function(commits) {
|
43
|
+
return _commits.call(this, repo, commits[0], commits[1], options);
|
44
|
+
});
|
45
|
+
};
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Merge a commit into HEAD and writes the results to the working directory.
|
49
|
+
*
|
50
|
+
* @param {Repository} repo Repository that contains the given commits
|
51
|
+
* @param {AnnotatedCommit} theirHead The annotated commit to merge into HEAD
|
52
|
+
* @param {MergeOptions} [mergeOpts] The merge tree options (null for default)
|
53
|
+
* @param {CheckoutOptions} [checkoutOpts] The checkout options
|
54
|
+
* (null for default)
|
55
|
+
*/
|
56
|
+
Merge.merge = function(repo, theirHead, mergeOpts, checkoutOpts) {
|
57
|
+
mergeOpts = normalizeOptions(mergeOpts || {}, NodeGit.MergeOptions);
|
58
|
+
checkoutOpts = normalizeOptions(checkoutOpts || {}, NodeGit.CheckoutOptions);
|
59
|
+
|
60
|
+
// Even though git_merge takes an array of annotated_commits, it expects
|
61
|
+
// exactly one to have been passed in or it will throw an error... ¯\_(ツ)_/¯
|
62
|
+
var theirHeads = [theirHead];
|
63
|
+
|
64
|
+
return _merge.call(
|
65
|
+
this,
|
66
|
+
repo,
|
67
|
+
theirHeads,
|
68
|
+
theirHeads.length,
|
69
|
+
mergeOpts,
|
70
|
+
checkoutOpts
|
71
|
+
);
|
72
|
+
};
|