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
{{ message }}
Repository navigation
resolveRef should be available through a mix-in #142
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;});}
Activity
binki commentedon Jul 7, 2018
Hi, in fact I need more than
resolveRef(). I need something to also expand intermediate refs so that I can expand, for example,HEADwhich resolves to a ref. For example, this is what I am using now:TheKnarf commentedon Jul 13, 2018
Feel free to send a pull-request.