Skip to content

Commit 1ffd20a

Browse files
authored
Merge pull request #1711 from implausible/feature/additional-deprecation-warnings
Add deprecation warnings for enums that need them.
2 parents 04ee1fe + c69e193 commit 1ffd20a

3 files changed

Lines changed: 57 additions & 0 deletions

File tree

lib/attr.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
});

lib/config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var util = require("util");
12
var NodeGit = require("../");
23

34
var Config = NodeGit.Config;
@@ -6,3 +7,19 @@ var Config = NodeGit.Config;
67
Config.prototype.getString = function() {
78
return this.getStringBuf.apply(this, arguments);
89
};
10+
11+
NodeGit.Enums.CVAR = {};
12+
var DEPRECATED_CVAR_ENUMS = [
13+
"FALSE",
14+
"TRUE",
15+
"INT32",
16+
"STRING"
17+
];
18+
DEPRECATED_CVAR_ENUMS.forEach((key) => {
19+
Object.defineProperty(NodeGit.Enums.CVAR, key, {
20+
get: util.deprecate(
21+
() => Config.MAP[key],
22+
`Use NodeGit.Config.MAP.${key} instead of NodeGit.Enums.CVAR.${key}.`
23+
)
24+
});
25+
});

lib/remote.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var util = require("util");
12
var NodeGit = require("../");
23
var normalizeFetchOptions = NodeGit.Utils.normalizeFetchOptions;
34
var normalizeOptions = NodeGit.Utils.normalizeOptions;
@@ -182,3 +183,22 @@ Remote.prototype.upload = function(refSpecs, opts) {
182183

183184
return _upload.call(this, refSpecs, opts);
184185
};
186+
187+
188+
NodeGit.Remote.COMPLETION_TYPE = {};
189+
var DEPRECATED_STATES = {
190+
COMPLETION_DOWNLOAD: "DOWNLOAD",
191+
COMPLETION_INDEXING: "INDEXING",
192+
COMPLETION_ERROR: "ERROR"
193+
};
194+
195+
Object.keys(DEPRECATED_STATES).forEach((key) => {
196+
const newKey = DEPRECATED_STATES[key];
197+
Object.defineProperty(NodeGit.Remote.COMPLETION_TYPE, key, {
198+
get: util.deprecate(
199+
() => NodeGit.Remote.COMPLETION[newKey],
200+
`Use NodeGit.Remote.COMPLETION.${newKey} instead of ` +
201+
`NodeGit.Remote.COMPLETION_TYPE.${key}.`
202+
)
203+
});
204+
});

0 commit comments

Comments
 (0)