gabrielcsapo / node-git-server

🎡 A configurable git server written in Node.js
https://gabrielcsapo.github.io/node-git-server
MIT License
253 stars 73 forks source link

`create` should throw an error if the repo already exists #56

Closed brandonros closed 5 years ago

brandonros commented 5 years ago

or at least return some kind of variable to after (err) in cb so that the calling function knows whether or not the repo was created?

https://github.com/gabrielcsapo/node-git-server/blob/master/lib/git.js#L215

brandonros commented 5 years ago
const repoExists = await new Promise((resolve, reject) => {
    repos.exists(`${name}.git`, resolve);
  });
  if (repoExists) {
    return { status: 400, body: 'repo already exists' };
  }

I just did this instead. Maybe refactor that code to not call .exists but .access instead?