Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String findBranchHeadRevision( ScmFileHistory file, String revisionNumber) {
- String sRevBase = revisionNumber.replaceFirst("(.*)\\.0(\\.\\d+)", "$1$2."); // sRevBase = "1.3.2."
- String sBranchHead = revisionNumber.replaceFirst("(.*)\\.0\\.\\d+", "$1"); // sBranchHead = "1.3"
- int maxRevNum = -1;
- for (String rev : file.getRevisions()) { // Loop all revisions
- if (rev.startsWith(sRevBase))
- {
- String tail = rev.substring(sRevBase.length());
- if (tail.indexOf('.') == -1) {
- int num = Integer.parseInt(tail);
- if (num > maxRevNum) {
- maxRevNum = num;
- sBranchHead = rev; // sBranchHead = "1.3.2.1", then "1.3.2.3", and finally "1.3.2.4"
- }
- }
- }
- }
- return sBranchHead;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement