FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add deprecation warnings for enums that need them. by implausible · Pull Request #1711 · nodegit/nodegit · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
20 changes: 20 additions & 0 deletions lib/attr.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var util = require("util");
var NodeGit = require("../");

NodeGit.Attr.STATES = {};
var DEPRECATED_STATES = {
UNSPECIFIED_T: "UNSPECIFIED",
TRUE_T: "TRUE",
FALSE_T: "FALSE",
VALUE_T: "STRING"
};

Object.keys(DEPRECATED_STATES).forEach((key) => {
const newKey = DEPRECATED_STATES[key];
Object.defineProperty(NodeGit.Attr.STATES, key, {
get: util.deprecate(
() => NodeGit.Attr.VALUE[newKey],
`Use NodeGit.Attr.VALUE.${newKey} instead of NodeGit.Attr.STATES.${key}.`
)
});
});
17 changes: 17 additions & 0 deletions lib/config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var util = require("util");
var NodeGit = require("../");

var Config = NodeGit.Config;
Expand All @@ -6,3 +7,19 @@ var Config = NodeGit.Config;
Config.prototype.getString = function() {
return this.getStringBuf.apply(this, arguments);
};

NodeGit.Enums.CVAR = {};
var DEPRECATED_CVAR_ENUMS = [
"FALSE",
"TRUE",
"INT32",
"STRING"
];
DEPRECATED_CVAR_ENUMS.forEach((key) => {
Object.defineProperty(NodeGit.Enums.CVAR, key, {
get: util.deprecate(
() => Config.MAP[key],
`Use NodeGit.Config.MAP.${key} instead of NodeGit.Enums.CVAR.${key}.`
)
});
});
20 changes: 20 additions & 0 deletions lib/remote.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var util = require("util");
var NodeGit = require("../");
var normalizeFetchOptions = NodeGit.Utils.normalizeFetchOptions;
var normalizeOptions = NodeGit.Utils.normalizeOptions;
Expand Down Expand Up @@ -182,3 +183,22 @@ Remote.prototype.upload = function(refSpecs, opts) {

return _upload.call(this, refSpecs, opts);
};


NodeGit.Remote.COMPLETION_TYPE = {};
var DEPRECATED_STATES = {
COMPLETION_DOWNLOAD: "DOWNLOAD",
COMPLETION_INDEXING: "INDEXING",
COMPLETION_ERROR: "ERROR"
};

Object.keys(DEPRECATED_STATES).forEach((key) => {
const newKey = DEPRECATED_STATES[key];
Object.defineProperty(NodeGit.Remote.COMPLETION_TYPE, key, {
get: util.deprecate(
() => NodeGit.Remote.COMPLETION[newKey],
`Use NodeGit.Remote.COMPLETION.${newKey} instead of ` +
`NodeGit.Remote.COMPLETION_TYPE.${key}.`
)
});
});

Back | FazBrowse Home | New Git URL