Instead of a completer, use chained Futures:

    return getHeadRef().then((String headRefName) => _getHeadForRef(headRefName));