Skip to content

Commit 98b7e68

Browse files
committed
Merge branch 'master' into release/4
# Conflicts: # version
2 parents 2bbcb79 + bc7a3c1 commit 98b7e68

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ jacocoTestReport {
2525
}
2626
}
2727

28+
test {
29+
testLogging {
30+
events "failed"
31+
exceptionFormat "full"
32+
}
33+
}
34+
35+
2836
repositories {
2937
maven { url "https://jitpack.io" }
3038
mavenCentral()

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.util.Set;
1414

1515
import org.apache.commons.io.FileUtils;
16+
import org.apache.commons.lang3.StringUtils;
1617
import org.scm4j.vcs.api.IVCS;
1718
import org.scm4j.vcs.api.VCSChangeType;
1819
import org.scm4j.vcs.api.VCSCommit;
@@ -451,12 +452,16 @@ public List<VCSDiffEntry> getBranchesDiff(final String srcBranchName, final Stri
451452
public Set<String> getBranches(String path) {
452453
try {
453454
List<String> entries = listEntries(SVNVCS.BRANCHES_PATH, path == null ? "" : path);
454-
Set<String> res = new HashSet<>(entries);
455+
Set<String> tempRes = new HashSet<>(entries);
455456
if (repository.checkPath(MASTER_PATH, -1) == SVNNodeKind.DIR) {
456457
if (path == null || MASTER_PATH.startsWith(path) ) {
457-
res.add(MASTER_PATH.replace("/", ""));
458+
tempRes.add(MASTER_PATH.replace("/", ""));
458459
}
459460
}
461+
Set<String> res = new HashSet<>();
462+
for (String str : tempRes) {
463+
res.add(StringUtils.removeStart(str, SVNVCS.BRANCHES_PATH));
464+
}
460465
return res;
461466
} catch (SVNException e) {
462467
throw new EVCSException(e);
@@ -465,13 +470,13 @@ public Set<String> getBranches(String path) {
465470
}
466471
}
467472

468-
protected List<String> listEntries(String path, String subdir) throws Exception {
473+
protected List<String> listEntries(String path, String subdirStartsWith) throws Exception {
469474
List<String> res = new ArrayList<>();
470-
if (repository.checkPath(path + subdir , -1) == SVNNodeKind.NONE) {
475+
if (repository.checkPath(path , -1) == SVNNodeKind.NONE) {
471476
return res;
472477
}
473478
@SuppressWarnings("unchecked")
474-
Collection<SVNDirEntry> subEntries = repository.getDir(path + subdir, -1, null, (Collection<SVNDirEntry>) null);
479+
Collection<SVNDirEntry> subEntries = repository.getDir(path, -1, null, (Collection<SVNDirEntry>) null);
475480
List<SVNDirEntry> list = new ArrayList<>(subEntries);
476481
Collections.sort(list, new Comparator<SVNDirEntry>() {
477482
@Override
@@ -486,9 +491,8 @@ public int compare(SVNDirEntry o1, SVNDirEntry o2) {
486491
}
487492
});
488493
for (SVNDirEntry entry : list) {
489-
if (entry.getKind() == SVNNodeKind.DIR) {
490-
res.add(((path.equals(SVNVCS.BRANCHES_PATH) ? "" : path) + subdir + entry.getName())
491-
.replace(SVNVCS.BRANCHES_PATH, ""));
494+
if (entry.getKind() == SVNNodeKind.DIR && entry.getName().startsWith(subdirStartsWith)) {
495+
res.add(path + entry.getName());
492496
}
493497
}
494498
return res;
@@ -634,21 +638,20 @@ public Boolean fileExists(String branchName, String filePath) {
634638

635639
@Override
636640
public VCSTag createTag(String branchName, String tagName, String tagMessage, String revisionToTag) throws EVCSTagExists {
637-
try {
641+
try (IVCSLockedWorkingCopy wc = repo.getVCSLockedWorkingCopy()) {
638642
SVNURL srcURL = getBranchUrl(branchName);
639643
SVNURL dstURL = SVNURL.parseURIEncoded(repoUrl + TAGS_PATH + tagName);
644+
SVNLogEntry copyFromEntry = revToSVNEntry(getBranchName(branchName),
645+
revisionToTag == null ? SVNRevision.HEAD.getNumber() : Long.parseLong(revisionToTag));
640646
SVNCopySource copySource = revisionToTag == null ?
641-
new SVNCopySource(SVNRevision.HEAD, SVNRevision.HEAD, srcURL) :
647+
new SVNCopySource(SVNRevision.HEAD, SVNRevision.create(copyFromEntry.getRevision()), srcURL) :
642648
new SVNCopySource(SVNRevision.parse(revisionToTag), SVNRevision.parse(revisionToTag), srcURL);
643649

644650
clientManager.getCopyClient().doCopy(new SVNCopySource[] {copySource}, dstURL,
645651
false, false, true, tagMessage, null);
646-
652+
647653
SVNDirEntry entry = repository.info(TAGS_PATH + tagName, -1);
648654

649-
SVNLogEntry copyFromEntry = revToSVNEntry(getBranchName(branchName),
650-
revisionToTag == null ? SVNRevision.HEAD.getNumber() : Long.parseLong(revisionToTag));
651-
652655
return new VCSTag(tagName, tagMessage, entry.getAuthor(), svnLogEntryToVCSCommit(copyFromEntry));
653656
} catch (SVNException e) {
654657
if (e.getErrorMessage().getErrorCode().getCode() == SVN_ITEM_EXISTS_ERROR_CODE) {
@@ -691,10 +694,11 @@ public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
691694
public List<VCSTag> getTags() {
692695
try {
693696
List<String> entries = listEntries(TAGS_PATH, "");
697+
694698
List<VCSTag> res = new ArrayList<>();
695699
SVNTagBaseCommit handler;
696700
for (String entryStr : entries) {
697-
701+
698702
SVNLogEntry entry = revToSVNEntry(entryStr, -1L);
699703

700704
handler = new SVNTagBaseCommit();

src/test/java/org/scm4j/vcs/svn/SVNVCSTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ public void testSVNVCSUtilsCreation() {
435435
public void testListEntriesNone() throws Exception {
436436
SVNRepository mockedRepo = spy(svn.getSVNRepository());
437437
svn.setSVNRepository(mockedRepo);
438-
doReturn(SVNNodeKind.NONE).when(mockedRepo).checkPath(anyString(), anyLong());
438+
doReturn(SVNNodeKind.NONE).when(mockedRepo).checkPath((String) isNull(), anyLong());
439439
svn.listEntries(null, null); // expecting no NPE
440440
}
441441
}

0 commit comments

Comments
 (0)