Esempio n. 1
0
def getRepositoryFromPath(user,path):
  repository = lookupRepositoryByPath(user,path)
  if repository:
    return repository
  else:
    # If it doesn't, create a new repo and return it.
    newTempRepo = Repository(user=user,name=user.getRegistry().getRepositories().getNewUniqueTempRepoId(),temporary=True,sourceDir=path)
    if newTempRepo.isPresent():
      user.getRegistry().getRepositories().addRepository(newTempRepo)
      return newTempRepo
    else:
      raise ResolutionError("Repo at "+path+" does not exist.")
Esempio n. 2
0
def getRepositoryFromURI(user,uri):
  """
  Either return the repository who's URI is equal to the given URI or return a new temporary repository with that URI.
  """
  #First check if a repository with this URI already exists
  repository = lookupRepositoryByURI(user,uri)
  if repository:
    return repository
  # If it doesn't, create a new repo and return it.
  newTempRepo = Repository(user=user,name=user.getRegistry().getRepositories().getNewUniqueTempRepoId(),gitOriginURI=uri,gitCommitHash="master",temporary=True)
  if newTempRepo.isPresent():
    user.getRegistry().getRepositories().addRepository(newTempRepo)
    return newTempRepo
  else:
    raise ResolutionError("Repo at "+uri+" does not exist.")
Esempio n. 3
0
def getRepositoryFromPath(user, path):
    repository = lookupRepositoryByPath(user, path)
    if repository:
        return repository
    else:
        # If it doesn't, create a new repo and return it.
        newTempRepo = Repository(
            user=user,
            name=user.getRegistry().getRepositories().getNewUniqueTempRepoId(),
            temporary=True,
            sourceDir=path)
        if newTempRepo.isPresent():
            user.getRegistry().getRepositories().addRepository(newTempRepo)
            return newTempRepo
        else:
            raise ResolutionError("Repo at " + path + " does not exist.")
Esempio n. 4
0
def add(user,name,url):
  repository = subuserlib.resolve.lookupRepositoryByURIOrPath(user,url)
  if repository:
    if repository.isTemporary():
      sys.exit("A temporary repository with this url already exists.  Cannot add.  The ability to uprade temporary repositories to named repositories is a wanted feature.  Feal free to send a quality, well thought out, pull request.")
    else:
      sys.exit("The repository named:" +repository.getName()+" already has this URL.  Cannot add.")
  else:
    if url.startswith("/"):
      repository = Repository(user,name=name,sourceDir=url)
    else:
      repository = Repository(user,name=name,gitOriginURI=url,gitCommitHash="master")
    if repository.isPresent():
      user.getRegistry().getRepositories().addRepository(repository)
      user.getRegistry().commit()
    else:
      sys.exit("Cannot load repository, path or URL not found.")
Esempio n. 5
0
def getRepositoryFromURI(user, uri):
    """
  Either return the repository who's URI is equal to the given URI or return a new temporary repository with that URI.
  """
    #First check if a repository with this URI already exists
    repository = lookupRepositoryByURI(user, uri)
    if repository:
        return repository
    # If it doesn't, create a new repo and return it.
    newTempRepo = Repository(
        user=user,
        name=user.getRegistry().getRepositories().getNewUniqueTempRepoId(),
        gitOriginURI=uri,
        gitCommitHash="master",
        temporary=True)
    if newTempRepo.isPresent():
        user.getRegistry().getRepositories().addRepository(newTempRepo)
        return newTempRepo
    else:
        raise ResolutionError("Repo at " + uri + " does not exist.")
Esempio n. 6
0
def add(user, name, url):
    repository = subuserlib.resolve.lookupRepositoryByURIOrPath(user, url)
    if repository:
        if repository.temporary:
            sys.exit(
                "A temporary repository with this url already exists.  Cannot add.  The ability to uprade temporary repositories to named repositories is a wanted feature.  Feal free to send a quality, well thought out, pull request."
            )
        else:
            sys.exit("The repository named:" + repository.name +
                     " already has this URL.  Cannot add.")
    else:
        if url.startswith("/"):
            repository = Repository(user, name=name, sourceDir=url)
        else:
            repository = Repository(user,
                                    name=name,
                                    gitOriginURI=url,
                                    gitCommitHash="master")
        if repository.isPresent():
            user.registry.repositories.addRepository(repository)
            user.registry.commit()
        else:
            sys.exit("Cannot load repository, path or URL not found.")