Exemple #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.")
Exemple #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.")
Exemple #3
0
 def loadRepositoryDict(repositoryDict):
   """
   From a list of paths to repository lists load a single unified repository dict.
   """
   repositories = {}
   for repoName,repoAttributes in repositoryDict.items():
     subuserlib.loadMultiFallbackJsonConfigFile.expandPathsInDict(self.getUser().homeDir,["git-origin","source-dir"],repoAttributes)
     if repoName in repositoryStates:
       gitCommitHash = repositoryStates[repoName]["git-commit-hash"]
     else:
       gitCommitHash = "master"
     if "temporary" in repoAttributes:
       temporary = repoAttributes["temporary"]
     else:
       temporary=False
     if "git-origin" in repoAttributes:
       gitOriginURI = repoAttributes["git-origin"]
     else:
       gitOriginURI = None
     if "source-dir" in repoAttributes:
       sourceDir = repoAttributes["source-dir"]
     else:
       sourceDir = None
     repositories[repoName] = Repository(self.getUser(),name=repoName,gitOriginURI=gitOriginURI,gitCommitHash=gitCommitHash,temporary=temporary,sourceDir=sourceDir)
   return repositories
Exemple #4
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.")
Exemple #5
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.")
Exemple #6
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)
    user.getRegistry().getRepositories().addRepository(newTempRepo)
    return newTempRepo
Exemple #7
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.")
Exemple #8
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")
        user.getRegistry().getRepositories().addRepository(repository)
        user.getRegistry().commit()