class GitManager {

    public GitCommitEntry removeFolder(Pipeline pipeline,
                                       String folder,
                                       String lastCommitId,
                                       String commitMessage) throws GitClientException {
        if (commitMessage == null) {
            commitMessage = String.format("Removing update %s", folder);
        }
        Assert.isTrue(lastCommitId.equals(pipeline.getCurrentVersion().getCommitId()),
                messageHelper.getMessage(MessageConstants.ERROR_REPOSITORY_FILE_WAS_UPDATED, folder));
        Assert.isTrue(!StringUtils.isNullOrEmpty(folder),
                messageHelper.getMessage(MessageConstants.ERROR_REPOSITORY_ROOT_FOLDER_CANNOT_BE_REMOVED));
        Assert.isTrue(!folder.equalsIgnoreCase(srcDirectory),
                messageHelper.getMessage(MessageConstants.ERROR_REPOSITORY_FOLDER_CANNOT_BE_REMOVED, folder));
        GitlabClient gitlabClient = this.getGitlabClientForPipeline(pipeline);
        List<GitRepositoryEntry> allFiles = gitlabClient.getRepositoryContents(folder,
                GIT_MASTER_REPOSITORY,
                true);

        GitPushCommitEntry gitPushCommitEntry = new GitPushCommitEntry();
        gitPushCommitEntry.setCommitMessage(commitMessage);
        for (GitRepositoryEntry file : allFiles) {
            if (file.getType().equalsIgnoreCase("tree")) {
                continue;
            }
            GitPushCommitActionEntry gitPushCommitActionEntry = new GitPushCommitActionEntry();
            gitPushCommitActionEntry.setAction("delete");
            gitPushCommitActionEntry.setFilePath(file.getPath());
            gitPushCommitEntry.getActions().add(gitPushCommitActionEntry);
        }
        return gitlabClient.commit(gitPushCommitEntry);
    }

}