Example usage for org.eclipse.jgit.treewalk TreeWalk getNameString

List of usage examples for org.eclipse.jgit.treewalk TreeWalk getNameString

Introduction

In this page you can find the example usage for org.eclipse.jgit.treewalk TreeWalk getNameString.

Prototype

public String getNameString() 

Source Link

Document

Get the current entry's name within its parent tree.

Usage

From source file:au.id.soundadvice.systemdesign.versioning.jgit.GitVersionControl.java

License:Open Source License

/**
 * Find the tree that contains the required identity.
 *
 * @return The ObjectId of the tree (directory) that contains the matching
 * identity within the supplied hierarchy.
 *///from  ww  w  . ja v  a2s. c  om
private ObjectId findMatchingIdentity(IdentityValidator identityValidator, ObjectId tree) throws IOException {
    TreeWalk treeWalk = new TreeWalk(repo.getRepository());
    try {
        treeWalk.setRecursive(false);
        treeWalk.addTree(tree);

        while (treeWalk.next()) {
            if (treeWalk.isSubtree()) {
                ObjectId candidateId = findMatchingIdentity(identityValidator, treeWalk.getObjectId(0));
                if (ObjectId.zeroId().equals(candidateId)) {
                    // Keep searching
                } else {
                    return candidateId;
                }
            } else if (identityValidator.getIdentityFileName().equals(treeWalk.getNameString())) {
                // Read the identity file
                ObjectLoader loader = repo.getRepository().open(treeWalk.getObjectId(0));
                ObjectStream stream = loader.openStream();
                InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8);
                if (identityValidator.isIdentityMatched(new BufferedReader(reader))) {
                    // We found it
                    return tree;
                }
            }
        }
        return ObjectId.zeroId();
    } finally {
        treeWalk.release();
    }
}

From source file:au.id.soundadvice.systemdesign.versioning.jgit.GitVersionControl.java

License:Open Source License

@Override
public Optional<BufferedReader> getBufferedReader(IdentityValidator identityValidator, String filename,
        Optional<VersionInfo> version) throws IOException {
    if (version.isPresent()) {
        Pair<String, ObjectId> diff = diffCache.get();
        if (!version.get().getId().equals(diff.getKey())) {
            // Grab the id of the commit we are trying to diff against
            ObjectId id = ObjectId.fromString(version.get().getId());
            RevWalk revWalk = new RevWalk(repo.getRepository());
            try {
                // Read the commit
                RevCommit commit = revWalk.parseCommit(id);
                ObjectId matchedDirectory = findMatchingIdentity(identityValidator, commit.getTree());
                diff = new Pair<>(version.get().getId(), matchedDirectory);
                diffCache.set(diff);/*from  w  w  w  .  j a  va2  s. co  m*/
            } finally {
                revWalk.release();
            }
        }

        if (ObjectId.zeroId().equals(diff.getValue())) {
            // No such tree
            return Optional.empty();
        } else {
            // Find the file in this tree
            TreeWalk treeWalk = new TreeWalk(repo.getRepository());
            try {
                treeWalk.setRecursive(false);
                treeWalk.addTree(diff.getValue());

                while (treeWalk.next()) {
                    if (filename.equals(treeWalk.getNameString())) {
                        // Read the file
                        ObjectLoader loader = repo.getRepository().open(treeWalk.getObjectId(0));
                        ObjectStream stream = loader.openStream();
                        InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8);
                        return Optional.of(new BufferedReader(reader));
                    }
                }
                // No such file
                return Optional.empty();
            } finally {
                treeWalk.release();
            }
        }
    } else {
        Path path = identityValidator.getDirectoryPath().resolve(filename);
        if (Files.exists(path)) {
            return Optional.of(Files.newBufferedReader(path));
        } else {
            return Optional.empty();
        }
    }
}

From source file:com.google.gitiles.doc.DocServlet.java

License:Open Source License

private static boolean findIndexFile(TreeWalk tw) throws IOException {
    tw.enterSubtree();/*from  ww  w  .j a  v a  2 s. c o  m*/
    while (tw.next()) {
        if ((tw.getRawMode(0) & TYPE_MASK) == TYPE_FILE && INDEX_MD.equals(tw.getNameString())) {
            return true;
        }
    }
    return false;
}

From source file:com.google.gitiles.ReadmeHelper.java

License:Open Source License

void considerEntry(TreeWalk tw) {
    if (render && FileMode.REGULAR_FILE.equals(tw.getRawMode(0)) && isReadmeFile(tw.getNameString())) {
        readmePath = tw.getPathString();
        readmeId = tw.getObjectId(0);//from www .  j a  v a 2 s  .  co  m
    }
}

From source file:com.google.gitiles.TreeJsonData.java

License:Open Source License

static Tree toJsonData(ObjectId id, TreeWalk tw) throws IOException {
    Tree tree = new Tree();
    tree.id = id.name();//from   ww w.j  a  v a  2  s  .  c  o  m
    tree.entries = Lists.newArrayList();
    while (tw.next()) {
        Entry e = new Entry();
        FileMode mode = tw.getFileMode(0);
        e.mode = mode.getBits();
        e.type = Constants.typeString(mode.getObjectType());
        e.id = tw.getObjectId(0).name();
        e.name = tw.getNameString();
        tree.entries.add(e);
    }
    return tree;
}

From source file:com.google.gitiles.TreeSoyData.java

License:Open Source License

public Map<String, Object> toSoyData(ObjectId treeId, TreeWalk tw) throws MissingObjectException, IOException {
    List<Object> entries = Lists.newArrayList();
    GitilesView.Builder urlBuilder = GitilesView.path().copyFrom(view);
    while (tw.next()) {
        FileType type = FileType.forEntry(tw);
        String name = tw.getNameString();

        switch (view.getType()) {
        case PATH:
            urlBuilder.setTreePath(view.getTreePath() + "/" + name);
            break;
        case REVISION:
            // Got here from a tag pointing at a tree.
            urlBuilder.setTreePath(name);
            break;
        default:/*w ww.  jav  a 2s  .  c  om*/
            throw new IllegalStateException(
                    String.format("Cannot render TreeSoyData from %s view", view.getType()));
        }

        String url = urlBuilder.toUrl();
        if (type == FileType.TREE) {
            name += "/";
            url += "/";
        }
        Map<String, String> entry = Maps.newHashMapWithExpectedSize(4);
        entry.put("type", type.toString());
        entry.put("name", name);
        entry.put("url", url);
        if (type == FileType.SYMLINK) {
            String target = new String(rw.getObjectReader().open(tw.getObjectId(0)).getCachedBytes(),
                    Charsets.UTF_8);
            // TODO(dborowitz): Merge Shawn's changes before copying these methods
            // in.
            entry.put("targetName", getTargetDisplayName(target));
            String targetUrl = resolveTargetUrl(view, target);
            if (targetUrl != null) {
                entry.put("targetUrl", targetUrl);
            }
        }
        entries.add(entry);
    }

    Map<String, Object> data = Maps.newHashMapWithExpectedSize(3);
    data.put("sha", treeId.name());
    data.put("entries", entries);

    if (view.getType() == GitilesView.Type.PATH && view.getRevision().getPeeledType() == OBJ_COMMIT) {
        data.put("logUrl", GitilesView.log().copyFrom(view).toUrl());
    }

    return data;
}

From source file:com.googlesource.gerrit.plugins.findowners.OwnersValidator.java

License:Apache License

/**
 * Find all changed OWNERS files which differ between the commit and its parents. Return a map
 * from "Path to the changed file" to "ObjectId of the file".
 *//* w  ww  . j  a  v a2s.  co  m*/
private static Map<String, ObjectId> getChangedOwners(RevCommit c, RevWalk revWalk, String ownersFileName)
        throws IOException {
    final Map<String, ObjectId> content = new HashMap<>();
    visitChangedEntries(c, revWalk, new TreeWalkVisitor() {
        @Override
        public void onVisit(TreeWalk tw) {
            if (isFile(tw) && ownersFileName.equals(tw.getNameString())) {
                content.put(tw.getPathString(), tw.getObjectId(0));
            }
        }
    });
    return content;
}

From source file:com.madgag.agit.BlobViewFragment.java

License:Open Source License

@Override
public Loader<BlobView> onCreateLoader(int id, Bundle b) {
    return new AsyncLoader<BlobView>(getActivity()) {
        public BlobView loadInBackground() {
            Bundle args = getArguments();
            try {
                Repository repo = new FileRepository(args.getString(GITDIR));
                ObjectId revision = repo.resolve(args.getString(UNTIL_REVS));
                RevWalk revWalk = new RevWalk(repo);
                RevCommit commit = revWalk.parseCommit(revision);
                TreeWalk treeWalk = TreeWalk.forPath(repo, args.getString(PATH), commit.getTree());
                ObjectId blobId = treeWalk.getObjectId(0);

                ObjectLoader objectLoader = revWalk.getObjectReader().open(blobId, Constants.OBJ_BLOB);
                ObjectStream binaryTestStream = objectLoader.openStream();
                boolean blobIsBinary = RawText.isBinary(binaryTestStream);
                binaryTestStream.close();
                Log.d(TAG, "blobIsBinary=" + blobIsBinary);
                return blobIsBinary ? new BinaryBlobView(objectLoader, treeWalk.getNameString())
                        : new TextBlobView(objectLoader);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }/*ww  w .  j a  va2 s  . c  om*/
        }

    };
}

From source file:com.tasktop.c2c.server.scm.service.GitBrowseUtil.java

License:Open Source License

public static Trees getTrees(Repository r, String revision, String path, boolean history, int recursion)
        throws IOException, GitAPIException, EntityNotFoundException {
    if (path.startsWith("/")) {
        path = path.substring(1);/*w  w  w .  j a v a2 s.c  o  m*/
    }

    RevObject revId = resolveRevision(r, revision);

    MutableObjectId revTree = new MutableObjectId();
    TreeWalk treeWalk = getTreeOnPath(revTree, r, revId, path);

    if (treeWalk == null) {
        throw new EntityNotFoundException("Revision: " + revision + ", path: " + path + " not found.");
    }

    Trees trees = new Trees(revTree.name());

    Git git = history ? new Git(r) : null;

    while (treeWalk.next()) {
        ObjectLoader loader = r.open(treeWalk.getObjectId(0));
        Trees.Tree t = new Trees.Tree(treeWalk.getObjectId(0).getName(), // sha
                treeWalk.getPathString(), // path
                treeWalk.getNameString(), // name
                getType(loader.getType()), // type
                treeWalk.getRawMode(0), // mode
                loader.getSize() // size
        );
        trees.getTree().add(t);

        if (recursion == -2 && t.getType() == Item.Type.TREE) {
            t.setEmpty(getEmptyPath(r, treeWalk.getObjectId(0)));
        }

        if (history) {
            addHistory(git, t, revId, /* path + ( path.length() == 0 ? "" : "/") + */t.getPath());
        }

    }

    return trees;
}

From source file:i5.las2peer.services.codeGenerationService.generators.MicroserviceGenerator.java

/**
 * /*from w w w  . j a v  a2s  .  c o  m*/
 * Creates source code from a CAE microservice model and pushes it to GitHub.
 * 
 * @param microservice the microservice model
 * @param templateRepositoryName the name of the template repository on GitHub
 * @param gitHubOrganization the organization that is used in the CAE
 * @param gitHubUser the CAE user
 * @param gitHubUserMail the mail of the CAE user
 * @param gitHubPassword the password of the CAE user
 * 
 * @throws GitHubException thrown if anything goes wrong during this process. Wraps around all
 *         other exceptions and prints their message.
 * 
 */
public static void createSourceCode(Microservice microservice, String templateRepositoryName,
        String gitHubOrganization, String gitHubUser, String gitHubUserMail, String gitHubPassword)
        throws GitHubException {

    // variables to be closed in the final block
    Repository microserviceRepository = null;
    TreeWalk treeWalk = null;

    // helper variables
    String packageName = microservice.getResourceName().substring(0, 1).toLowerCase()
            + microservice.getResourceName().substring(1);
    // get the port: skip first 6 characters for search (http: / https:)
    String port = microservice.getPath().substring(microservice.getPath().indexOf(":", 6) + 1,
            microservice.getPath().indexOf("/", microservice.getPath().indexOf(":", 6)));

    // variables holding content to be modified and added to repository later
    String projectFile = null;
    BufferedImage logo = null;
    String readMe = null;
    String license = null;
    String buildFile = null;
    String startScriptWindows = null;
    String startScriptUnix = null;
    String userAgentGeneratorWindows = null;
    String userAgentGeneratorUnix = null;
    String nodeInfo = null;
    String antServiceProperties = null;
    String antUserProperties = null;
    String ivy = null;
    String ivySettings = null;
    String serviceProperties = null;
    String webConnectorConfig = null;
    String gitignore = null;
    String classpath = null;
    String databaseManager = null;
    String serviceClass = null;
    String serviceTest = null;
    String genericHttpMethod = null;
    String genericApiResponse = null;
    String genericHttpResponse = null;
    String genericTestCase = null;
    String databaseConfig = null;
    String databaseInstantiation = null;
    String serviceInvocation = null;
    String databaseScript = null;
    String genericTable = null;

    try {
        PersonIdent caeUser = new PersonIdent(gitHubUser, gitHubUserMail);
        String repositoryName = "microservice-" + microservice.getName().replace(" ", "-");
        microserviceRepository = generateNewRepository(repositoryName, gitHubOrganization, gitHubUser,
                gitHubPassword);

        try {
            // now load the TreeWalk containing the template repository content
            treeWalk = getTemplateRepositoryContent(templateRepositoryName, gitHubOrganization);
            treeWalk.setFilter(PathFilter.create("backend/"));
            ObjectReader reader = treeWalk.getObjectReader();
            // walk through the tree and retrieve the needed templates
            while (treeWalk.next()) {
                ObjectId objectId = treeWalk.getObjectId(0);
                ObjectLoader loader = reader.open(objectId);

                switch (treeWalk.getNameString()) {
                // start with the "easy" replacements, and store the other template files for later
                case ".project":
                    projectFile = new String(loader.getBytes(), "UTF-8");
                    projectFile = projectFile.replace("$Microservice_Name$", microservice.getName());
                    break;
                case "logo_services.png":
                    logo = ImageIO.read(loader.openStream());
                    break;
                case "README.md":
                    readMe = new String(loader.getBytes(), "UTF-8");
                    readMe = readMe.replace("$Repository_Name$", repositoryName);
                    readMe = readMe.replace("$Organization_Name$", gitHubOrganization);
                    readMe = readMe.replace("$Microservice_Name$", microservice.getName());
                    break;
                case "LICENSE.txt":
                    license = new String(loader.getBytes(), "UTF-8");
                    break;
                case "build.xml":
                    buildFile = new String(loader.getBytes(), "UTF-8");
                    buildFile = buildFile.replace("$Microservice_Name$", microservice.getName());
                    break;
                case "start_network.bat":
                    startScriptWindows = new String(loader.getBytes(), "UTF-8");
                    startScriptWindows = startScriptWindows.replace("$Resource_Name$",
                            microservice.getResourceName());
                    startScriptWindows = startScriptWindows.replace("$Lower_Resource_Name$", packageName);
                    startScriptWindows = startScriptWindows.replace("$Microservice_Version$",
                            microservice.getVersion() + "");
                    break;
                case "start_network.sh":
                    startScriptUnix = new String(loader.getBytes(), "UTF-8");
                    startScriptUnix = startScriptUnix.replace("$Resource_Name$",
                            microservice.getResourceName());
                    startScriptUnix = startScriptUnix.replace("$Lower_Resource_Name$", packageName);
                    startScriptUnix = startScriptUnix.replace("$Microservice_Version$",
                            microservice.getVersion() + "");
                    break;
                case "start_UserAgentGenerator.bat":
                    userAgentGeneratorWindows = new String(loader.getBytes(), "UTF-8");
                    break;
                case "start_UserAgentGenerator.sh":
                    userAgentGeneratorUnix = new String(loader.getBytes(), "UTF-8");
                    break;
                case "nodeInfo.xml":
                    nodeInfo = new String(loader.getBytes(), "UTF-8");
                    nodeInfo = nodeInfo.replace("$Developer$", microservice.getDeveloper());
                    nodeInfo = nodeInfo.replace("$Resource_Name$", microservice.getResourceName());
                    break;
                case "service.properties":
                    antServiceProperties = new String(loader.getBytes(), "UTF-8");
                    antServiceProperties = antServiceProperties.replace("$Microservice_Version$",
                            microservice.getVersion() + "");
                    antServiceProperties = antServiceProperties.replace("$Lower_Resource_Name$", packageName);
                    antServiceProperties = antServiceProperties.replace("$Resource_Name$",
                            microservice.getResourceName());
                    antServiceProperties = antServiceProperties.replace("$Microservice_Version$",
                            microservice.getVersion() + "");
                    break;
                case "user.properties":
                    antUserProperties = new String(loader.getBytes(), "UTF-8");
                    break;
                case "ivy.xml":
                    ivy = new String(loader.getBytes(), "UTF-8");
                    // add mysql dependency only if a database exists
                    if (microservice.getDatabase() != null) {
                        ivy = ivy.replace("$MySQL_Dependencies$",
                                "<dependency org=\"mysql\" name=\"mysql-connector-java\" rev=\"5.1.6\" />\n"
                                        + "    <dependency org=\"org.apache.commons\" name=\"commons-pool2\" rev=\"2.2\" />\n"
                                        + "    <dependency org=\"org.apache.commons\" name=\"commons-dbcp2\" rev=\"2.0\" />");
                    } else {
                        ivy = ivy.replace("    $MySQL_Dependencies$\n", "");
                    }
                    break;
                case "ivysettings.xml":
                    ivySettings = new String(loader.getBytes(), "UTF-8");
                    break;
                case "i5.las2peer.services.servicePackage.ServiceClass.properties":
                    serviceProperties = new String(loader.getBytes(), "UTF-8");
                    // if database does not exist, clear the file
                    if (microservice.getDatabase() == null) {
                        serviceProperties = "";
                    } else {
                        serviceProperties = serviceProperties.replace("$Database_Address$",
                                microservice.getDatabase().getAddress());
                        serviceProperties = serviceProperties.replace("$Database_Schema$",
                                microservice.getDatabase().getSchema());
                        serviceProperties = serviceProperties.replace("$Database_User$",
                                microservice.getDatabase().getLoginName());
                        serviceProperties = serviceProperties.replace("$Database_Password$",
                                microservice.getDatabase().getLoginPassword());
                    }
                case "i5.las2peer.webConnector.WebConnector.properties":
                    webConnectorConfig = new String(loader.getBytes(), "UTF-8");
                    webConnectorConfig = webConnectorConfig.replace("$HTTP_Port$", port);
                    break;
                case ".gitignore":
                    gitignore = new String(loader.getBytes(), "UTF-8");
                    break;
                case ".classpath":
                    classpath = new String(loader.getBytes(), "UTF-8");
                    if (microservice.getDatabase() != null) {
                        classpath = classpath.replace("$Database_Libraries$",
                                "<classpathentry kind=\"lib\" path=\"lib/mysql-connector-java-5.1.6.jar\"/>\n"
                                        + "  <classpathentry kind=\"lib\" path=\"lib/commons-dbcp2-2.0.jar\"/>");
                    } else {
                        classpath = classpath.replace("$Database_Libraries$\n", "");
                    }
                    break;
                case "DatabaseManager.java":
                    if (microservice.getDatabase() != null) {
                        databaseManager = new String(loader.getBytes(), "UTF-8");
                        databaseManager = databaseManager.replace("$Lower_Resource_Name$", packageName);
                    }
                    break;
                case "ServiceClass.java":
                    serviceClass = new String(loader.getBytes(), "UTF-8");
                    break;
                case "genericHTTPMethod.txt":
                    genericHttpMethod = new String(loader.getBytes(), "UTF-8");
                    break;
                case "genericHTTPResponse.txt":
                    genericHttpResponse = new String(loader.getBytes(), "UTF-8");
                    break;
                case "genericApiResponse.txt":
                    genericApiResponse = new String(loader.getBytes(), "UTF-8");
                    break;
                case "ServiceTest.java":
                    serviceTest = new String(loader.getBytes(), "UTF-8");
                    break;
                case "genericTestMethod.txt":
                    genericTestCase = new String(loader.getBytes(), "UTF-8");
                    break;
                case "databaseConfig.txt":
                    databaseConfig = new String(loader.getBytes(), "UTF-8");
                    break;
                case "databaseInstantiation.txt":
                    databaseInstantiation = new String(loader.getBytes(), "UTF-8");
                    break;
                case "genericServiceInvocation.txt":
                    serviceInvocation = new String(loader.getBytes(), "UTF-8");
                    break;
                case "database.sql":
                    databaseScript = new String(loader.getBytes(), "UTF-8");
                    break;
                case "genericTable.txt":
                    genericTable = new String(loader.getBytes(), "UTF-8");
                    break;
                }
            }
        } catch (Exception e) {
            logger.printStackTrace(e);
            throw new GitHubException(e.getMessage());
        }

        // generate service class and test
        String repositoryLocation = "https://github.com/" + gitHubOrganization + "/" + repositoryName;
        serviceClass = generateNewServiceClass(serviceClass, microservice, repositoryLocation,
                genericHttpMethod, genericApiResponse, genericHttpResponse, databaseConfig,
                databaseInstantiation, serviceInvocation);
        serviceTest = generateNewServiceTest(serviceTest, microservice, genericTestCase);
        if (microservice.getDatabase() != null) {
            databaseScript = generateDatabaseScript(databaseScript, genericTable, microservice);
        }
        // add files to new repository
        // configuration and build stuff
        microserviceRepository = createTextFileInRepository(microserviceRepository, "etc/ivy/", "ivy.xml", ivy);
        microserviceRepository = createTextFileInRepository(microserviceRepository, "etc/ivy/",
                "ivysettings.xml", ivySettings);
        microserviceRepository = createTextFileInRepository(microserviceRepository, "", "build.xml", buildFile);
        microserviceRepository = createTextFileInRepository(microserviceRepository, "etc/ant_configuration/",
                "user.properties", antUserProperties);
        microserviceRepository = createTextFileInRepository(microserviceRepository, "etc/ant_configuration/",
                "service.properties", antServiceProperties);
        microserviceRepository = createTextFileInRepository(microserviceRepository, "etc/", "nodeInfo.xml",
                nodeInfo);
        microserviceRepository = createTextFileInRepository(microserviceRepository, "", ".project",
                projectFile);
        microserviceRepository = createTextFileInRepository(microserviceRepository, "", ".gitignore",
                gitignore);
        microserviceRepository = createTextFileInRepository(microserviceRepository, "", ".classpath",
                classpath);
        // property files
        microserviceRepository = createTextFileInRepository(microserviceRepository, "etc/",
                "i5.las2peer.services." + packageName + "." + microservice.getResourceName() + ".properties",
                serviceProperties);
        microserviceRepository = createTextFileInRepository(microserviceRepository, "etc/",
                "i5.las2peer.webConnector.WebConnector.properties", webConnectorConfig);
        // scripts
        microserviceRepository = createTextFileInRepository(microserviceRepository, "bin/", "start_network.bat",
                startScriptWindows);
        microserviceRepository = createTextFileInRepository(microserviceRepository, "bin/", "start_network.sh",
                startScriptUnix);
        microserviceRepository = createTextFileInRepository(microserviceRepository, "bin/",
                "start_UserAgentGenerator.bat", userAgentGeneratorWindows);
        microserviceRepository = createTextFileInRepository(microserviceRepository, "bin/",
                "start_UserAgentGenerator.sh", userAgentGeneratorUnix);
        // doc
        microserviceRepository = createTextFileInRepository(microserviceRepository, "", "README.md", readMe);
        microserviceRepository = createTextFileInRepository(microserviceRepository, "", "LICENSE.txt", license);
        microserviceRepository = createImageFileInRepository(microserviceRepository, "img/", "logo.png", logo);
        // source code
        if (databaseManager != null) {
            microserviceRepository = createTextFileInRepository(microserviceRepository,
                    "src/main/i5/las2peer/services/" + packageName + "/database/", "DatabaseManager.java",
                    databaseManager);
            // database script (replace spaces in filename for better usability later on)
            microserviceRepository = createTextFileInRepository(microserviceRepository, "db/",
                    microservice.getName().replace(" ", "_") + "_create_tables.sql", databaseScript);
        }
        microserviceRepository = createTextFileInRepository(microserviceRepository,
                "src/main/i5/las2peer/services/" + packageName + "/", microservice.getResourceName() + ".java",
                serviceClass);
        microserviceRepository = createTextFileInRepository(microserviceRepository,
                "src/test/i5/las2peer/services/" + packageName + "/",
                microservice.getResourceName() + "Test.java", serviceTest);
        // commit files
        try {
            Git.wrap(microserviceRepository).commit()
                    .setMessage("Generated microservice version " + microservice.getVersion())
                    .setCommitter(caeUser).call();
        } catch (Exception e) {
            logger.printStackTrace(e);
            throw new GitHubException(e.getMessage());
        }

        // push (local) repository content to GitHub repository
        try {
            pushToRemoteRepository(microserviceRepository, gitHubUser, gitHubPassword);
        } catch (Exception e) {
            logger.printStackTrace(e);
            throw new GitHubException(e.getMessage());
        }

        // close all open resources
    } finally {
        microserviceRepository.close();
        treeWalk.close();
    }
}