class RepositoryManager {

    public static boolean isOnBranch(Path repositoryDirectory, String branchName) {
        Git git = null;
        try {
            git = Git.open(repositoryDirectory.toFile());
            return branchName.equals(git.getRepository().getBranch());
        } catch (IOException e) {
            throw new GitException("Unable to open the git repository", e);
        } finally {
            close(git);
        }
    }

}