• Patrick Steinhardt's avatar
    repository: Do not fail if repository exists already · ddf054fe
    Patrick Steinhardt authored
    The `#create_if_not_exists` function is supposed to create a repository
    if it doesn't exist yet. It may happen though that the existence-cache
    may pretend a repo doesn't exist yet even though it does, and in that
    case we'd call the CreateRepository RPC. This worked alright until now
    given that this RPC call is idempotent and simply reinitializes the repo
    in case it exists already. But Gitaly is going to change semantics of
    the RPC such that it raises an error if the repo exists already, where
    it then won't touch the preexisting repo at all.
    
    Prepare for this change by introducing a new `RepositoryExists` error
    which gets raised when `#create_repository` returns an AlreadyExists
    error. This error is rescued from in `#create_if_not_exists` such that
    semantics of this RPC call remain the same.
    ddf054fe
repository.rb 32.2 KB