Search in sources :

Example 1 with TreeElement

use of com.google.copybara.git.GitRepository.TreeElement in project copybara by google.

the class GitDestinationReader method copyDestinationFiles.

@Override
public void copyDestinationFiles(Glob glob) throws RepoException {
    ImmutableList<TreeElement> treeElements = repository.lsTree(baseline, null, true, true);
    PathMatcher pathMatcher = glob.relativeTo(workDir);
    for (TreeElement file : treeElements) {
        Path path = workDir.resolve(file.getPath());
        if (pathMatcher.matches(path)) {
            try {
                Files.createDirectories(path.getParent());
            } catch (IOException e) {
                throw new RepoException(String.format("Cannot create parent directory for %s", path), e);
            }
        }
    }
    repository.checkout(glob, workDir, baseline);
}
Also used : Path(java.nio.file.Path) PathMatcher(java.nio.file.PathMatcher) IOException(java.io.IOException) RepoException(com.google.copybara.exception.RepoException) TreeElement(com.google.copybara.git.GitRepository.TreeElement)

Aggregations

RepoException (com.google.copybara.exception.RepoException)1 TreeElement (com.google.copybara.git.GitRepository.TreeElement)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 PathMatcher (java.nio.file.PathMatcher)1