You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, in fact I need more than resolveRef(). I need something to also expand intermediate refs so that I can expand, for example, HEAD which resolves to a ref. For example, this is what I am using now:
functionresolveRef(repo,ref){// Shouldn’t js-git also expose some helper for this?if(/^[0-9a-f]{40}$/.test(ref)){returnref;}constrefRefMatch=/^ref: *(.*)$/.exec(ref);if(refRefMatch){returnresolveRef(repo,refRefMatch[1]);}returnnewPromise((resolve,reject)=>repo.readRef(ref,(ex,ref)=>ex ? reject(ex) : resolve(ref))).then(ref=>{if(!ref){// Indicates that the ref could not be resolved to a hash.returnnull;}returnresolveRef(repo,ref);});}functionresolveRefOrFail(repo,ref){returnresolveRef(repo,resolvedRef=>{if(!resolvedRef){thrownewError(`Unable to resolve ref ${ref}`);}returnresolvedRef;});}
js-git/mixins/walkers.js
Line 100 in bc266d7
To do something, I have to basically copy this entire function into my own code. It would be useful if this were available through a mix-in.
The text was updated successfully, but these errors were encountered: