getTerminal = (repo, refName, depth = 10, prevRef = null) => {
  if (depth <= 0) {
    return Promise.resolve({
      error: NodeGit.Error.CODE.ENOTFOUND,
      out: prevRef
    });
  }

  return NodeGit.Reference.lookup(repo, refName)
    .then((ref) => {
      if (ref.type() === NodeGit.Reference.TYPE.DIRECT) {
        return {
          error: NodeGit.Error.CODE.OK,
          out: ref
        };
      } else {
        return getTerminal(repo, ref.symbolicTarget(), depth - 1, ref)
          .then(({ error, out }) => {
            if (error === NodeGit.Error.CODE.ENOTFOUND && !out) {
              return { error, out: ref };
            } else {
              return { error, out };
            }
          });
      }
    })
    .catch((error) => {
      return {
        error: error.errno,
        out: null
      };
    });
}
Returns the name of the reference.
@return {String}