# GitWrapper # A set of classes for working with git repositories. The repository is examined using a wrapper around native git calls. The current feature set is limited to extraction of merge commits and associated operations. ### Setup ### GitWrapper uses the Gradle build system. Using `./gradlew build` will assemble a .jar file containing the library in the `build/libs` directory. The dependencies of the library may be displayed using `./gradlew dependencies --configuration runtime`. If the project using the library is also a gradle project, it is far more convenient to add the library as a sub-project. The code below assumes that the directory of your clone of GitWrapper is a sibling of the project directory using it. Extend your `settings.gradle` and `build.gradle` as follows: **settings.gradle** ``` #!groovy includeFlat 'GitWrapper' // The name of the folder containing your clone of GitWrapper. ``` **build.gradle** ``` #!groovy dependencies { compile project(':GitWrapper') } ``` ### Example ### The following example code will clone a given repository to the current working directory and display the SHA1 hashes of all merge commits. ``` #!Java GitWrapper git; try { git = new GitWrapper("git"); // Or /usr/bin/git, C:\Program Files\Git\bin\git. } catch (ToolNotWorkingException ex) { // Handle the case that git can not be called using the supplied command. return; } Optional<Repository> optRepo = git.clone(new File("."), "git@github.com:se-passau/jdime.git", false); optRepo.ifPresent(repo -> repo.getMergeCommits().forEach(mergeCommit -> { System.out.println("Merge Commit: " + mergeCommit.getId()); })); ``` ### Contact ### * Georg Seibt (seibt[at]fim.uni-passau.de)