Skip to content

Commit af90e00

Browse files
vladakVladimir Kotal
authored andcommitted
make Subversion repository detect current branch
1 parent 15e55fe commit af90e00

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/org/opensolaris/opengrok/history/RepositoryInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public void setType(String type) {
137137
}
138138

139139
/**
140-
* get property type
140+
* get property parent
141141
*
142142
* @return parent
143143
*/

src/org/opensolaris/opengrok/history/SubversionRepository.java

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public class SubversionRepository extends Repository {
7272
*/
7373
public static final String CMD_FALLBACK = "svn";
7474

75+
private static final String URLprefix = "URL:";
76+
7577
protected String reposPath;
7678

7779
public SubversionRepository() {
@@ -424,9 +426,8 @@ private List<String> getAuthCommandLineParams() {
424426
return result;
425427
}
426428

427-
@Override
428-
String determineParent() throws IOException {
429-
String parent = null;
429+
private String getInfoPart(String partName) throws IOException {
430+
String part = null;
430431
File directory = new File(directoryName);
431432

432433
List<String> cmd = new ArrayList<>();
@@ -441,23 +442,37 @@ String determineParent() throws IOException {
441442
try (BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
442443
String line;
443444
while ((line = in.readLine()) != null) {
444-
if (line.startsWith("URL:")) {
445+
if (line.startsWith(partName)) {
445446
String parts[] = line.split("\\s+");
446447
if (parts.length != 2) {
447448
LOGGER.log(Level.WARNING,
448449
"Failed to get parent for {0}", directoryName);
449450
}
450-
parent = parts[1];
451+
part = parts[1];
451452
break;
452453
}
453454
}
454455
}
455456

456-
return parent;
457+
return part;
457458
}
458459

459460
@Override
460-
String determineBranch() {
461-
return null;
461+
String determineParent() throws IOException {
462+
return getInfoPart(URLprefix);
463+
}
464+
465+
@Override
466+
String determineBranch() throws IOException {
467+
String branch = null;
468+
469+
String url = getInfoPart(URLprefix);
470+
int idx;
471+
final String branchesStr = "branches/";
472+
if ((idx = url.indexOf(branchesStr)) > 0) {
473+
branch = url.substring(idx + branchesStr.length());
474+
}
475+
476+
return branch;
462477
}
463478
}

0 commit comments

Comments
 (0)