| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -308,7 +308,7 @@ git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { | |||
| 308 | 308 | // references such as branches, tags and remote references (everything in | |
| 309 | 309 | // the .git/refs directory). | |
| 310 | 310 | ||
| 311 | - repo.getReferences(git.Reference.Type.Oid | git.Reference.Type.Symbolic, function(error, referenceNames) { | ||
| 311 | + repo.getReferences(git.Reference.Type.All, function(error, referenceNames) { | ||
| 312 | 312 | if (error) throw error; | |
| 313 | 313 | ||
| 314 | 314 | referenceNames.forEach(function(referenceName) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,8 +47,9 @@ class GitReference : public ObjectWrap { | |||
| 47 | 47 | Persistent<Function> callback; | |
| 48 | 48 | }; | |
| 49 | 49 | static Handle<Value> Oid(const Arguments& args); | |
| 50 | - static Handle<Value> Name(const Arguments& args); | ||
| 50 | + static Handle<Value> SymbolicTarget(const Arguments& args); | ||
| 51 | 51 | static Handle<Value> Type(const Arguments& args); | |
| 52 | + static Handle<Value> Name(const Arguments& args); | ||
| 52 | 53 | static Handle<Value> Resolve(const Arguments& args); | |
| 53 | 54 | static void ResolveWork(uv_work_t* req); | |
| 54 | 55 | static void ResolveAfterWork(uv_work_t* req); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,8 @@ var git = require('../'), | |||
| 3 | 3 | ||
| 4 | 4 | Reference.Type = { | |
| 5 | 5 | Oid: 1, | |
| 6 | - Symbolic: 2 | ||
| 6 | + Symbolic: 2, | ||
| 7 | + All: 3 | ||
| 7 | 8 | }; | |
| 8 | 9 | ||
| 9 | 10 | Reference.prototype.isOid = function() { | |
@@ -13,3 +14,17 @@ Reference.prototype.isOid = function() { | |||
| 13 | 14 | Reference.prototype.isSymbolic = function() { | |
| 14 | 15 | return this.type() == Reference.Type.Symbolic; | |
| 15 | 16 | }; | |
| 17 | + | ||
| 18 | + var oldSymbolicTarget = Reference.prototype.symbolicTarget; | ||
| 19 | + Reference.prototype.symbolicTarget = function() { | ||
| 20 | + if (!this.isSymbolic()) throw this.name() + " is not symbolic"; | ||
| 21 | + | ||
| 22 | + return oldSymbolicTarget.call(this); | ||
| 23 | + }; | ||
| 24 | + | ||
| 25 | + var oldOid = Reference.prototype.oid; | ||
| 26 | + Reference.prototype.oid = function() { | ||
| 27 | + if (!this.isOid()) throw this.name() + " is not oid"; | ||
| 28 | + | ||
| 29 | + return oldOid.call(this); | ||
| 30 | + }; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,8 +35,9 @@ void GitReference::Initialize(Handle<v8::Object> target) { | |||
| 35 | 35 | ||
| 36 | 36 | NODE_SET_METHOD(tpl, "oidForName", OidForName); | |
| 37 | 37 | NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); | |
| 38 | - NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); | ||
| 38 | + NODE_SET_PROTOTYPE_METHOD(tpl, "symbolicTarget", SymbolicTarget); | ||
| 39 | 39 | NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); | |
| 40 | + NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); | ||
| 40 | 41 | NODE_SET_PROTOTYPE_METHOD(tpl, "resolve", Resolve); | |
| 41 | 42 | NODE_SET_PROTOTYPE_METHOD(tpl, "setSymbolicTarget", SetSymbolicTarget); | |
| 42 | 43 | NODE_SET_PROTOTYPE_METHOD(tpl, "setTarget", setTarget); | |
@@ -179,7 +180,7 @@ Handle<Value> GitReference::Oid(const Arguments& args) { | |||
| 179 | 180 | /** | |
| 180 | 181 | * @return {String} result | |
| 181 | 182 | */ | |
| 182 | - Handle<Value> GitReference::Name(const Arguments& args) { | ||
| 183 | + Handle<Value> GitReference::SymbolicTarget(const Arguments& args) { | ||
| 183 | 184 | HandleScope scope; | |
| 184 | 185 | ||
| 185 | 186 | ||
@@ -208,6 +209,22 @@ Handle<Value> GitReference::Type(const Arguments& args) { | |||
| 208 | 209 | return scope.Close(to); | |
| 209 | 210 | } | |
| 210 | 211 | ||
| 212 | + /** | ||
| 213 | + * @return {String} result | ||
| 214 | + */ | ||
| 215 | + Handle<Value> GitReference::Name(const Arguments& args) { | ||
| 216 | + HandleScope scope; | ||
| 217 | + | ||
| 218 | + | ||
| 219 | + const char * result = git_reference_name( | ||
| 220 | + ObjectWrap::Unwrap<GitReference>(args.This())->GetValue() | ||
| 221 | + ); | ||
| 222 | + | ||
| 223 | + Handle<Value> to; | ||
| 224 | + to = String::New(result); | ||
| 225 | + return scope.Close(to); | ||
| 226 | + } | ||
| 227 | + | ||
| 211 | 228 | /** | |
| 212 | 229 | * @param {Reference} callback | |
| 213 | 230 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,8 +11,8 @@ exports.open = function(test){ | |||
| 11 | 11 | test.expect(2); | |
| 12 | 12 | ||
| 13 | 13 | // Test invalid repository | |
| 14 | - git.Repo.open('/private/etc/hosts', function(error, repository) { | ||
| 15 | - test.equals(error.message, "The `.git` file at '/private/etc/hosts' is malformed"); | ||
| 14 | + git.Repo.open('../templates', function(error, repository) { | ||
| 15 | + test.equals(error.message, "Could not find repository from '../templates'"); | ||
| 16 | 16 | ||
| 17 | 17 | // Test valid repository | |
| 18 | 18 | git.Repo.open('../.git', function(error, repository) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8123,8 +8123,8 @@ | |||
| 8123 | 8123 | "isAsync": false, | |
| 8124 | 8124 | "isConstructorMethod": false, | |
| 8125 | 8125 | "isPrototypeMethod": true, | |
| 8126 | - "jsFunctionName": "name", | ||
| 8127 | - "cppFunctionName": "Name", | ||
| 8126 | + "jsFunctionName": "symbolicTarget", | ||
| 8127 | + "cppFunctionName": "SymbolicTarget", | ||
| 8128 | 8128 | "return": { | |
| 8129 | 8129 | "cType": "const char *", | |
| 8130 | 8130 | "cppClassName": "String" | |
@@ -8162,7 +8162,6 @@ | |||
| 8162 | 8162 | "isSelf": true | |
| 8163 | 8163 | } | |
| 8164 | 8164 | ], | |
| 8165 | - "ignore": true, | ||
| 8166 | 8165 | "isAsync": false, | |
| 8167 | 8166 | "isConstructorMethod": false, | |
| 8168 | 8167 | "isPrototypeMethod": true, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments