GitPathUtil { public static Optional<String> extractBranch(final String uri) { final Matcher matcher = branchNameExtractorFromPath.matcher(uri); if (matcher.matches()) { return Optional.of(matcher.group(1)); } else { return Optional.empty(); } }  static Optional<String> extractBranch(final String uri); static Optional<String> extractBranchFromRef(final String refName);  }
@Test public void extractPresentBranchName() throws Exception { final Optional<String> result = GitPathUtil.extractBranch("git: assertEquals(Optional.of("master"), result); }
@Test public void extractBranchNameWithSlashes() throws Exception { final Optional<String> result = GitPathUtil.extractBranch("git: assertEquals(Optional.of("my/master/branch"), result); }
@Test public void extractMissingBranchName() throws Exception { final Optional<String> result = GitPathUtil.extractBranch("git: assertEquals(Optional.empty(), result); }