class GitManager {

    public GitCommitEntry uploadFiles(Pipeline pipeline,
                                     String folder,
                                     List<UploadFileMetadata> files,
                                     String lastCommitId,
                                     String commitMessage) throws GitClientException {
        Assert.isTrue(lastCommitId.equals(pipeline.getCurrentVersion().getCommitId()),
                messageHelper.getMessage(MessageConstants.ERROR_REPOSITORY_WAS_UPDATED));
        GitlabClient gitlabClient = this.getGitlabClientForPipeline(pipeline);
        GitPushCommitEntry gitPushCommitEntry = new GitPushCommitEntry();

        for (UploadFileMetadata file : files) {
            String filePath = folder + PATH_DELIMITER + file.getFileName();
            Arrays.stream(filePath.split(PATH_DELIMITER)).forEach(pathPart ->
                    Assert.isTrue(GitUtils.checkGitNaming(pathPart),
                            messageHelper.getMessage(MessageConstants.ERROR_INVALID_PIPELINE_FILE_NAME, filePath)));

            boolean fileExists = false;
            try {
                fileExists = gitlabClient.getFileContents(filePath, GIT_MASTER_REPOSITORY) != null;
            } catch (UnexpectedResponseStatusException exception) {
                LOGGER.debug(exception.getMessage(), exception);
            }
            GitPushCommitActionEntry gitPushCommitActionEntry = new GitPushCommitActionEntry();
            commitMessage =
                    getCommitMessage(commitMessage, filePath, fileExists, gitPushCommitActionEntry);
            gitPushCommitActionEntry.setFilePath(filePath);
            gitPushCommitActionEntry.setContent(Base64.getEncoder().encodeToString(file.getBytes()));
            gitPushCommitActionEntry.setEncoding(BASE64_ENCODING);
            gitPushCommitEntry.getActions().add(gitPushCommitActionEntry);
        }

        gitPushCommitEntry.setCommitMessage(commitMessage);
        return gitlabClient.commit(gitPushCommitEntry);
    }

}