Skip to content

Commit 0ab3b16

Browse files
committed
setFilesContent() implemented
1 parent 867787e commit 0ab3b16

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

src/main/java/org/scm4j/vcs/svn/SVNVCS.java

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -253,26 +253,35 @@ private String getBranchName(String branchName) {
253253
}
254254

255255
@Override
256-
public void VCSCommit setFilesContent(String branchName, List<String> filePathes, List<String> contents, String commitMessage) {
256+
public VCSCommit setFilesContent(String branchName, List<String> filePathes, List<String> contents, String commitMessage) {
257+
if (filePathes.isEmpty()) {
258+
return null;
259+
}
257260
try (IVCSLockedWorkingCopy wc = repo.getVCSLockedWorkingCopy()) {
258261
checkout(getBranchUrl(branchName), wc.getFolder(), null);
259-
File file = new File(wc.getFolder(), filePath);
260-
Boolean needToAdd = !file.exists();
261-
if (!file.exists()) {
262-
FileUtils.forceMkdir(file.getParentFile());
263-
file.createNewFile();
264-
}
265-
266-
FileWriter writer = new FileWriter(file);
267-
writer.write(content);
268-
writer.close();
269-
270-
if (needToAdd) {
271-
clientManager
272-
.getWCClient()
273-
.doAdd(file,
274-
true /* force, avoiding "file is already under version control" exception */,
275-
false, false, SVNDepth.EMPTY, false, true);
262+
int contentId = 0;
263+
for (int filePathId = 0; filePathId < filePathes.size(); filePathId++) {
264+
String filePath = filePathes.get(filePathId);
265+
File file = new File(wc.getFolder(), filePath);
266+
Boolean needToAdd = !file.exists();
267+
if (needToAdd) {
268+
FileUtils.forceMkdir(file.getParentFile());
269+
file.createNewFile();
270+
}
271+
272+
String content = contents.get(contentId);
273+
FileWriter writer = new FileWriter(file);
274+
writer.write(content);
275+
writer.close();
276+
contentId++;
277+
278+
if (needToAdd) {
279+
clientManager
280+
.getWCClient()
281+
.doAdd(file,
282+
true /* force, avoiding "file is already under version control" exception */,
283+
false, false, SVNDepth.EMPTY, false, true);
284+
}
276285
}
277286

278287
try {

0 commit comments

Comments
 (0)