message: Improve node-git error handling
diff: const Git = require('nodegit');
  import type {
  + CredAcquireCb as CredCb,
  + Remote,
  Repository,
  - Signature,
  Revparse,
  - Remote,
  - CredAcquireCb as CredCb,
  + Signature,
  } from 'nodegit';
  export type {
  - Repository,
  CredAcquireCb as CredCb,
  Remote,
  + Repository,
  Signature,
  } from 'nodegit';
  @@ -45,6 +45,7 @@ const getRepository = async (
  // Get the repository if it already exists.
  return await Git.Repository.open(destination);
  } catch (e) {
  + if (e.message.includes('No such file or directory')) {
  // Repository doesn't exist locally yet. Clone it.
  return Git.Clone.clone(url, destination, {
  checkoutBranch: branch,
  @@ -53,6 +54,10 @@ const getRepository = async (
  },
  });
  }
  +
  + // Wrap e.message in a new Error because no stack is available from node-git
  + throw new Error(e.message);
  + }
  };
  const getRemote = (repository: Repository, remote: string): Promise<Remote> =>
  @@ -89,12 +94,15 @@ const ensureRepository = async (
  destination: string,
  credCb: CredCb
  ): Promise<Repository> => {
  + try {
  const repository = await getRepository(url, branch, destination, credCb);
  -
  // Ensure that we are on the right branch.
  await repository.checkoutBranch(branch);
  -
  return expectDefaultState(repository);
  + } catch (e) {
  + // Wrap e.message in a new Error because no stack is available from node-git
  + throw new Error(`(node-git) ${e.message}`);
  + }
  };
  const rebase = (
  