use of com.epam.pipeline.entity.git.GitPushCommitActionEntry in project cloud-pipeline by epam.
the class GitManager method createFolder.
private GitCommitEntry createFolder(Pipeline pipeline, String folder, String lastCommitId, String commitMessage) throws GitClientException {
Assert.isTrue(lastCommitId.equals(pipeline.getCurrentVersion().getCommitId()), messageHelper.getMessage(MessageConstants.ERROR_REPOSITORY_FILE_WAS_UPDATED, folder));
if (commitMessage == null) {
commitMessage = String.format("Creating update %s", folder);
}
List<String> filesToCreate = new ArrayList<>();
Path folderToCreate = Paths.get(folder);
while (folderToCreate != null && !StringUtils.isNullOrEmpty(folderToCreate.toString())) {
if (!this.folderExists(pipeline, folderToCreate.toString())) {
filesToCreate.add(Paths.get(folderToCreate.toString(), GIT_FOLDER_TOKEN_FILE).toString());
}
folderToCreate = folderToCreate.getParent();
}
GitPushCommitEntry gitPushCommitEntry = new GitPushCommitEntry();
gitPushCommitEntry.setCommitMessage(commitMessage);
for (String file : filesToCreate) {
GitPushCommitActionEntry gitPushCommitActionEntry = new GitPushCommitActionEntry();
gitPushCommitActionEntry.setAction("create");
gitPushCommitActionEntry.setFilePath(file);
gitPushCommitActionEntry.setContent("");
gitPushCommitEntry.getActions().add(gitPushCommitActionEntry);
}
return this.getGitlabClientForPipeline(pipeline).commit(gitPushCommitEntry);
}
use of com.epam.pipeline.entity.git.GitPushCommitActionEntry in project cloud-pipeline by epam.
the class GitManager method deleteFile.
public GitCommitEntry deleteFile(Pipeline pipeline, String filePath, String lastCommitId, String commitMessage) throws GitClientException {
Assert.isTrue(lastCommitId.equals(pipeline.getCurrentVersion().getCommitId()), messageHelper.getMessage(MessageConstants.ERROR_REPOSITORY_FILE_WAS_UPDATED, filePath));
GitlabClient gitlabClient = this.getGitlabClientForPipeline(pipeline);
GitPushCommitActionEntry gitPushCommitActionEntry = new GitPushCommitActionEntry();
gitPushCommitActionEntry.setAction("delete");
gitPushCommitActionEntry.setFilePath(filePath);
GitPushCommitEntry gitPushCommitEntry = new GitPushCommitEntry();
gitPushCommitEntry.setCommitMessage(commitMessage);
gitPushCommitEntry.getActions().add(gitPushCommitActionEntry);
return gitlabClient.commit(gitPushCommitEntry);
}
Aggregations