@swimlane/nodegit 1.1.2
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/.dockerignore +2 -0
- package/.github/workflows/publish.yml +126 -0
- package/.github/workflows/tests.yml +85 -0
- package/LICENSE +19 -0
- package/README.md +193 -0
- package/lib/attr.js +20 -0
- package/lib/blob.js +51 -0
- package/lib/branch.js +19 -0
- package/lib/buf.js +43 -0
- package/lib/commit.js +437 -0
- package/lib/config.js +48 -0
- package/lib/convenient_hunks.js +61 -0
- package/lib/convenient_patch.js +131 -0
- package/lib/credential.js +33 -0
- package/lib/deprecated/structs/ApplyOptions.js +3 -0
- package/lib/deprecated/structs/BlameOptions.js +6 -0
- package/lib/deprecated/structs/BlobFilterOptions.js +3 -0
- package/lib/deprecated/structs/CheckoutOptions.js +8 -0
- package/lib/deprecated/structs/CherrypickOptions.js +5 -0
- package/lib/deprecated/structs/CloneOptions.js +6 -0
- package/lib/deprecated/structs/DescribeFormatOptions.js +4 -0
- package/lib/deprecated/structs/DescribeOptions.js +6 -0
- package/lib/deprecated/structs/DiffFindOptions.js +8 -0
- package/lib/deprecated/structs/DiffOptions.js +8 -0
- package/lib/deprecated/structs/FetchOptions.js +7 -0
- package/lib/deprecated/structs/MergeFileInput.js +4 -0
- package/lib/deprecated/structs/MergeFileOptions.js +5 -0
- package/lib/deprecated/structs/MergeOptions.js +8 -0
- package/lib/deprecated/structs/ProxyOptions.js +3 -0
- package/lib/deprecated/structs/PushOptions.js +5 -0
- package/lib/deprecated/structs/RebaseOptions.js +6 -0
- package/lib/deprecated/structs/RemoteCreateOptions.js +3 -0
- package/lib/deprecated/structs/RepositoryInitOptions.js +4 -0
- package/lib/deprecated/structs/RevertOptions.js +5 -0
- package/lib/deprecated/structs/StashApplyOptions.js +4 -0
- package/lib/deprecated/structs/StatusOptions.js +4 -0
- package/lib/deprecated/structs/SubmoduleUpdateOptions.js +5 -0
- package/lib/diff.js +67 -0
- package/lib/diff_file.js +38 -0
- package/lib/diff_line.js +32 -0
- package/lib/error.js +17 -0
- package/lib/filter_registry.js +22 -0
- package/lib/graph.js +15 -0
- package/lib/index.js +103 -0
- package/lib/merge.js +41 -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 +86 -0
- package/lib/reference.js +213 -0
- package/lib/remote.js +45 -0
- package/lib/repository.js +1973 -0
- package/lib/reset.js +51 -0
- package/lib/revparse.js +18 -0
- package/lib/revwalk.js +142 -0
- package/lib/signature.js +38 -0
- package/lib/stash.js +16 -0
- package/lib/status.js +16 -0
- package/lib/status_file.js +106 -0
- package/lib/submodule.js +10 -0
- package/lib/tag.js +141 -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/shallow_clone.js +14 -0
- package/lifecycleScripts/clean.js +5 -0
- package/lifecycleScripts/install.js +32 -0
- package/lifecycleScripts/postinstall.js +83 -0
- package/lifecycleScripts/preinstall.js +47 -0
- package/lifecycleScripts/submodules/getStatus.js +50 -0
- package/lifecycleScripts/submodules/index.js +84 -0
- package/package.json +83 -0
- package/prebuilds/darwin-arm64/@swimlane+nodegit.glibc.node +0 -0
- package/prebuilds/darwin-x64/@swimlane+nodegit.glibc.node +0 -0
- package/prebuilds/linux-arm64/@swimlane+nodegit.glibc.node +0 -0
- package/prebuilds/linux-x64/@swimlane+nodegit.glibc.node +0 -0
- package/prebuilds/linux-x64/@swimlane+nodegit.musl.node +0 -0
- package/scripts/Dockerfile.alpine +10 -0
- package/scripts/Dockerfile.debian +15 -0
- package/utils/acquireOpenSSL.js +436 -0
- package/utils/build-openssl.bat +13 -0
- package/utils/buildFlags.js +19 -0
- package/utils/configureLibssh2.js +54 -0
- package/utils/defaultCxxStandard.js +18 -0
- package/utils/execPromise.js +24 -0
- package/utils/getElectronOpenSSLRoot.js +10 -0
- package/utils/gitExecutableLocation.js +23 -0
- package/utils/isBuildingForElectron.js +30 -0
- package/utils/retry.js +51 -0
package/lib/diff.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var NodeGit = require("../");
|
|
2
|
+
var Diff = NodeGit.Diff;
|
|
3
|
+
var Patch = NodeGit.Patch;
|
|
4
|
+
|
|
5
|
+
var _blobToBuffer = Diff.blobToBuffer;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Directly run a diff between a blob and a buffer.
|
|
9
|
+
* @async
|
|
10
|
+
* @param {Blob} old_blob Blob for old side of diff, or NULL for empty blob
|
|
11
|
+
* @param {String} old_as_path Treat old blob as if it had this filename;
|
|
12
|
+
* can be NULL
|
|
13
|
+
* @param {String} buffer Raw data for new side of diff, or NULL for empty
|
|
14
|
+
* @param {String} buffer_as_path Treat buffer as if it had this filename;
|
|
15
|
+
* can be NULL
|
|
16
|
+
* @param {DiffOptions} opts Options for diff, or NULL for default options
|
|
17
|
+
* @param {Function} file_cb Callback for "file"; made once if there is a diff;
|
|
18
|
+
* can be NULL
|
|
19
|
+
* @param {Function} binary_cb Callback for binary files; can be NULL
|
|
20
|
+
* @param {Function} hunk_cb Callback for each hunk in diff; can be NULL
|
|
21
|
+
* @param {Function} line_cb Callback for each line in diff; can be NULL
|
|
22
|
+
*/
|
|
23
|
+
Diff.blobToBuffer= function(
|
|
24
|
+
old_blob,
|
|
25
|
+
old_as_path,
|
|
26
|
+
buffer,
|
|
27
|
+
buffer_as_path,
|
|
28
|
+
opts,
|
|
29
|
+
file_cb,
|
|
30
|
+
binary_cb,
|
|
31
|
+
hunk_cb,
|
|
32
|
+
line_cb) {
|
|
33
|
+
var bufferText;
|
|
34
|
+
var bufferLength;
|
|
35
|
+
if (buffer instanceof Buffer) {
|
|
36
|
+
bufferText = buffer.toString("utf8");
|
|
37
|
+
bufferLength = Buffer.byteLength(buffer, "utf8");
|
|
38
|
+
} else {
|
|
39
|
+
bufferText = buffer;
|
|
40
|
+
bufferLength = !buffer ? 0 : Buffer.byteLength(buffer, "utf8");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return _blobToBuffer.call(
|
|
44
|
+
this,
|
|
45
|
+
old_blob,
|
|
46
|
+
old_as_path,
|
|
47
|
+
bufferText,
|
|
48
|
+
bufferLength,
|
|
49
|
+
buffer_as_path,
|
|
50
|
+
opts,
|
|
51
|
+
file_cb,
|
|
52
|
+
binary_cb,
|
|
53
|
+
hunk_cb,
|
|
54
|
+
line_cb,
|
|
55
|
+
null);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Retrieve patches in this difflist
|
|
60
|
+
*
|
|
61
|
+
* @async
|
|
62
|
+
* @return {Array<ConvenientPatch>} a promise that resolves to an array of
|
|
63
|
+
* ConvenientPatches
|
|
64
|
+
*/
|
|
65
|
+
Diff.prototype.patches = function(idxs) {
|
|
66
|
+
return Patch.convenientFromDiff(this, idxs);
|
|
67
|
+
};
|
package/lib/diff_file.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var NodeGit = require("../");
|
|
2
|
+
|
|
3
|
+
var DiffFile = NodeGit.DiffFile;
|
|
4
|
+
|
|
5
|
+
var flags = DiffFile.prototype.flags;
|
|
6
|
+
/**
|
|
7
|
+
* Returns the file's flags
|
|
8
|
+
* @return {Number}
|
|
9
|
+
*/
|
|
10
|
+
DiffFile.prototype.flags = flags;
|
|
11
|
+
|
|
12
|
+
var id = DiffFile.prototype.id;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the file's Oid
|
|
15
|
+
* @return {Oid}
|
|
16
|
+
*/
|
|
17
|
+
DiffFile.prototype.id = id;
|
|
18
|
+
|
|
19
|
+
var mode = DiffFile.prototype.mode;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the file's mode
|
|
22
|
+
* @return {Number}
|
|
23
|
+
*/
|
|
24
|
+
DiffFile.prototype.mode = mode;
|
|
25
|
+
|
|
26
|
+
var path = DiffFile.prototype.path;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the file's path
|
|
29
|
+
* @return {String}
|
|
30
|
+
*/
|
|
31
|
+
DiffFile.prototype.path = path;
|
|
32
|
+
|
|
33
|
+
var size = DiffFile.prototype.size;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the file's size
|
|
36
|
+
* @return {Number}
|
|
37
|
+
*/
|
|
38
|
+
DiffFile.prototype.size = size;
|
package/lib/diff_line.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var NodeGit = require("../");
|
|
2
|
+
var DiffLine = NodeGit.DiffLine;
|
|
3
|
+
|
|
4
|
+
var _rawContent = DiffLine.prototype.content;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The relevant line
|
|
8
|
+
* @return {String}
|
|
9
|
+
*/
|
|
10
|
+
DiffLine.prototype.content = function() {
|
|
11
|
+
if (!this._cache) {
|
|
12
|
+
this._cache = {};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!this._cache.content) {
|
|
16
|
+
this._cache.content = Buffer.from(this.rawContent())
|
|
17
|
+
.slice(0, this.contentLen())
|
|
18
|
+
.toString("utf8");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return this._cache.content;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The non utf8 translated text
|
|
26
|
+
* @return {String}
|
|
27
|
+
*/
|
|
28
|
+
DiffLine.prototype.rawContent = function() {
|
|
29
|
+
return _rawContent.call(this);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
NodeGit.DiffLine = DiffLine;
|
package/lib/error.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var util = require("util");
|
|
2
|
+
var NodeGit = require("../");
|
|
3
|
+
|
|
4
|
+
// Deprecated -----------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
// In 0.28.0 git_error was majorly refactored to have better naming in libgit2
|
|
7
|
+
// We will continue to support the old enum entries but with a deprecation
|
|
8
|
+
// warning as they will go away soon.
|
|
9
|
+
Object.keys(NodeGit.Error.CODE).forEach((key) => {
|
|
10
|
+
Object.defineProperty(NodeGit.Error.CODE, `GITERR_${key}`, {
|
|
11
|
+
get: util.deprecate(
|
|
12
|
+
() => NodeGit.Error.CODE[key],
|
|
13
|
+
`Use NodeGit.Error.CODE.${key} instead of ` +
|
|
14
|
+
`NodeGit.Error.CODE.GETERR_${key}.`
|
|
15
|
+
)
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var NodeGit = require("../");
|
|
2
|
+
|
|
3
|
+
var FilterRegistry = NodeGit.FilterRegistry;
|
|
4
|
+
|
|
5
|
+
var _register = FilterRegistry.register;
|
|
6
|
+
|
|
7
|
+
// register should add filter by name to dict and return
|
|
8
|
+
// Override FilterRegistry.register to normalize Filter
|
|
9
|
+
FilterRegistry.register = function(name, filter, priority) {
|
|
10
|
+
// setting default value of attributes
|
|
11
|
+
if (filter.attributes === undefined) {
|
|
12
|
+
filter.attributes = "";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!filter.check || !filter.apply) {
|
|
16
|
+
return Promise.reject(new Error(
|
|
17
|
+
"ERROR: please provide check and apply callbacks for filter"
|
|
18
|
+
));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return _register(name, filter, priority);
|
|
22
|
+
};
|
package/lib/graph.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var NodeGit = require("../");
|
|
2
|
+
|
|
3
|
+
var Graph = NodeGit.Graph;
|
|
4
|
+
|
|
5
|
+
var _reachableFromAny = Graph.reachableFromAny;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Determine if a commit is reachable from any of a list of commits by following parent edges.
|
|
9
|
+
* @param {repository} the repository where the commits exist
|
|
10
|
+
* @param {commit} a previously loaded commit
|
|
11
|
+
* @param {descendant_array} oids of the commits
|
|
12
|
+
*/
|
|
13
|
+
Graph.reachableFromAny = function(repository, commit, descendant_array) {
|
|
14
|
+
return _reachableFromAny(repository, commit, descendant_array, descendant_array.length);
|
|
15
|
+
};
|
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/merge.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var NodeGit = require("../");
|
|
2
|
+
|
|
3
|
+
var Merge = NodeGit.Merge;
|
|
4
|
+
var _commits = Merge.commits;
|
|
5
|
+
var _merge = Merge.merge;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Merge 2 commits together and create an new index that can
|
|
9
|
+
* be used to create a merge commit.
|
|
10
|
+
*
|
|
11
|
+
* @param {Repository} repo Repository that contains the given commits
|
|
12
|
+
* @param {Commit} ourCommit The commit that reflects the destination tree
|
|
13
|
+
* @param {Commit} theirCommit The commit to merge into ourCommit
|
|
14
|
+
* @param {MergeOptions} [options] The merge tree options (null for default)
|
|
15
|
+
*/
|
|
16
|
+
Merge.commits = function(repo, ourCommit, theirCommit, options) {
|
|
17
|
+
return Promise.all([
|
|
18
|
+
repo.getCommit(ourCommit),
|
|
19
|
+
repo.getCommit(theirCommit)
|
|
20
|
+
]).then(function(commits) {
|
|
21
|
+
return _commits.call(this, repo, commits[0], commits[1], options);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Merge a commit into HEAD and writes the results to the working directory.
|
|
27
|
+
*
|
|
28
|
+
* @param {Repository} repo Repository that contains the given commits
|
|
29
|
+
* @param {AnnotatedCommit} theirHead The annotated commit to merge into HEAD
|
|
30
|
+
* @param {MergeOptions} [mergeOpts] The merge tree options (null for default)
|
|
31
|
+
* @param {CheckoutOptions} [checkoutOpts] The checkout options
|
|
32
|
+
* (null for default)
|
|
33
|
+
*/
|
|
34
|
+
Merge.merge = function(repo, theirHead, mergeOpts, checkoutOpts) {
|
|
35
|
+
// Even though git_merge takes an array of annotated_commits, it expects
|
|
36
|
+
// exactly one to have been passed in or it will throw an error... ¯\_(ツ)_/¯
|
|
37
|
+
var theirHeads = [theirHead];
|
|
38
|
+
|
|
39
|
+
return _merge.call(this, repo, theirHeads, theirHeads.length,
|
|
40
|
+
mergeOpts, checkoutOpts);
|
|
41
|
+
};
|
package/lib/note.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var NodeGit = require("../");
|
|
2
|
+
|
|
3
|
+
var Note = NodeGit.Note;
|
|
4
|
+
|
|
5
|
+
var _foreach = Note.foreach;
|
|
6
|
+
|
|
7
|
+
// Override Note.foreach to eliminate the need to pass null payload
|
|
8
|
+
Note.foreach = function(repo, notesRef, callback) {
|
|
9
|
+
function wrapperCallback(blobId, objectId) {
|
|
10
|
+
// We need to copy the OID since libgit2 types are getting cleaned up
|
|
11
|
+
// incorrectly right now in callbacks
|
|
12
|
+
|
|
13
|
+
return callback(blobId.copy(), objectId.copy());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return _foreach(repo, notesRef, wrapperCallback, null);
|
|
17
|
+
};
|
package/lib/object.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var util = require("util");
|
|
2
|
+
var NodeGit = require("../");
|
|
3
|
+
|
|
4
|
+
var Obj = NodeGit.Object;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Is this object a blob?
|
|
8
|
+
* @return {Boolean}
|
|
9
|
+
*/
|
|
10
|
+
Obj.prototype.isBlob = function() {
|
|
11
|
+
return this.type() == Obj.TYPE.BLOB;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Is this object a commit?
|
|
16
|
+
* @return {Boolean}
|
|
17
|
+
*/
|
|
18
|
+
Obj.prototype.isCommit = function() {
|
|
19
|
+
return this.type() == Obj.TYPE.COMMIT;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Is this object a tag?
|
|
24
|
+
* @return {Boolean}
|
|
25
|
+
*/
|
|
26
|
+
Obj.prototype.isTag = function() {
|
|
27
|
+
return this.type() == Obj.TYPE.TAG;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Is this object a tree?
|
|
32
|
+
* @return {Boolean}
|
|
33
|
+
*/
|
|
34
|
+
Obj.prototype.isTree = function() {
|
|
35
|
+
return this.type() == Obj.TYPE.TREE;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Deprecated -----------------------------------------------------------------
|
|
39
|
+
|
|
40
|
+
Object.defineProperty(Obj.TYPE, "BAD", {
|
|
41
|
+
get: util.deprecate(
|
|
42
|
+
() => Obj.TYPE.INVALID,
|
|
43
|
+
"Use NodeGit.Object.TYPE.INVALID instead of NodeGit.Object.TYPE.BAD."
|
|
44
|
+
)
|
|
45
|
+
});
|
package/lib/oid.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var NodeGit = require("../");
|
|
2
|
+
|
|
3
|
+
var Oid = NodeGit.Oid;
|
|
4
|
+
|
|
5
|
+
// Backwards compatibility.
|
|
6
|
+
Object.defineProperties(Oid.prototype, {
|
|
7
|
+
"allocfmt": {
|
|
8
|
+
value: Oid.prototype.tostrS,
|
|
9
|
+
enumerable: false
|
|
10
|
+
},
|
|
11
|
+
"toString": {
|
|
12
|
+
value: Oid.prototype.tostrS,
|
|
13
|
+
enumerable: false
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
Oid.prototype.copy = function() {
|
|
18
|
+
return this.cpy(); // seriously???
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
Oid.prototype.inspect = function() {
|
|
22
|
+
return "[Oid " + this.allocfmt() + "]";
|
|
23
|
+
};
|
package/lib/rebase.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
var NodeGit = require("../");
|
|
2
|
+
var Rebase = NodeGit.Rebase;
|
|
3
|
+
|
|
4
|
+
var _init = Rebase.init;
|
|
5
|
+
var _open = Rebase.open;
|
|
6
|
+
|
|
7
|
+
function defaultRebaseOptions(repository, options, checkoutStrategy) {
|
|
8
|
+
if (options) {
|
|
9
|
+
// Ensure we don't modify the passed-in options object.
|
|
10
|
+
// This could lead to us recursing commitCreateCb if the same
|
|
11
|
+
// options object is later re-used.
|
|
12
|
+
options = Object.assign({}, options);
|
|
13
|
+
|
|
14
|
+
if (options.signingCb && !options.commitCreateCb) {
|
|
15
|
+
console.warn("signingCb is deperecated, use commitCreateCb instead.");
|
|
16
|
+
|
|
17
|
+
let signingCb = options.signingCb;
|
|
18
|
+
options.commitCreateCb = function (
|
|
19
|
+
author,
|
|
20
|
+
committer,
|
|
21
|
+
message_encoding,
|
|
22
|
+
message,
|
|
23
|
+
tree,
|
|
24
|
+
parent_count,
|
|
25
|
+
parents
|
|
26
|
+
) {
|
|
27
|
+
return repository.createCommitWithSignature(
|
|
28
|
+
null,
|
|
29
|
+
author,
|
|
30
|
+
committer,
|
|
31
|
+
message,
|
|
32
|
+
tree,
|
|
33
|
+
parents,
|
|
34
|
+
signingCb).then((oid) => {
|
|
35
|
+
return oid;
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
} else if (checkoutStrategy) {
|
|
40
|
+
options = {
|
|
41
|
+
checkoutOptions: {
|
|
42
|
+
checkoutStrategy: checkoutStrategy
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return options;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Initializes a rebase
|
|
52
|
+
* @async
|
|
53
|
+
* @param {Repository} repo The repository to perform the rebase
|
|
54
|
+
* @param {AnnotatedCommit} branch The terminal commit to rebase, or NULL to
|
|
55
|
+
* rebase the current branch
|
|
56
|
+
* @param {AnnotatedCommit} upstream The commit to begin rebasing from, or NULL
|
|
57
|
+
* to rebase all reachable commits
|
|
58
|
+
* @param {AnnotatedCommit} onto The branch to rebase onto, or NULL to rebase
|
|
59
|
+
* onto the given upstream
|
|
60
|
+
* @param {RebaseOptions} options Options to specify how rebase is performed,
|
|
61
|
+
* or NULL
|
|
62
|
+
* @return {Remote}
|
|
63
|
+
*/
|
|
64
|
+
Rebase.init = function(repository, branch, upstream, onto, options) {
|
|
65
|
+
return _init(repository, branch, upstream, onto, defaultRebaseOptions(
|
|
66
|
+
repository,
|
|
67
|
+
options,
|
|
68
|
+
NodeGit.Checkout.STRATEGY.FORCE
|
|
69
|
+
));
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Opens an existing rebase that was previously started by either an invocation
|
|
74
|
+
* of Rebase.open or by another client.
|
|
75
|
+
* @async
|
|
76
|
+
* @param {Repository} repo The repository that has a rebase in-progress
|
|
77
|
+
* @param {RebaseOptions} options Options to specify how rebase is performed
|
|
78
|
+
* @return {Remote}
|
|
79
|
+
*/
|
|
80
|
+
Rebase.open = function(repository, options) {
|
|
81
|
+
return _open(repository, defaultRebaseOptions(
|
|
82
|
+
repository,
|
|
83
|
+
options,
|
|
84
|
+
NodeGit.Checkout.STRATEGY.SAFE
|
|
85
|
+
));
|
|
86
|
+
};
|