// Path: src/main/java/com/github/danielflower/mavenplugins/release/GitHelper.java
// public class GitHelper {
//     public static boolean hasLocalTag(Git repo, String tagToCheck) throws GitAPIException {
//         return tag(repo, new EqualsMatcher(tagToCheck)) != null;
//     }
// 
//     public static Ref refStartingWith(Git repo, final String tagPrefix) throws GitAPIException {
//         return tag(repo, new Matcher() {
//             @Override
//             public boolean matches(String tagName) {
//                 return tagName.startsWith(tagPrefix);
//             }
//         });
//     }
// 
//     private static Ref tag(Git repo, Matcher matcher) throws GitAPIException {
//         for (Ref ref : repo.tagList().call()) {
//             String currentTag = ref.getName().replace("refs/tags/", "");
//             if (matcher.matches(currentTag)) {
//                 return ref;
//             }
//         }
//         return null;
//     }
// 
//     public static String scmUrlToRemote(String scmUrl) throws ValidationException {
//         String GIT_PREFIX = "scm:git:";
//         if (!scmUrl.startsWith(GIT_PREFIX)) {
//             List<String> messages = new ArrayList<String>();
//             String summary = "Cannot run the release plugin with a non-Git version control system";
//             messages.add(summary);
//             messages.add("The value in your scm tag is " + scmUrl);
//             throw new ValidationException(summary, messages);
//         }
//         String remote = scmUrl.substring(GIT_PREFIX.length());
//         remote  = remote.replace("file://localhost/", "file:///");
//         return remote;
//     }
// 
//     private interface Matcher {
//         public boolean matches(String tagName);
//     }
// 
//     private static class EqualsMatcher implements Matcher {
//         private final String tagToCheck;
// 
//         public EqualsMatcher(String tagToCheck) {
//             this.tagToCheck = tagToCheck;
//         }
// 
//         @Override
//         public boolean matches(String tagName) {
//             return tagToCheck.equals(tagName);
//         }
//     }
// }


import com.github.danielflower.mavenplugins.release.GitHelper;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.Status;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Ref;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeDiagnosingMatcher;
import java.util.List;
import static org.eclipse.jgit.lib.Constants.R_TAGS;
package scaffolding;




public class GitMatchers {

    public static Matcher<Git> hasTag(final String tag) {
        return new TypeSafeDiagnosingMatcher<Git>() {
            @Override
            protected boolean matchesSafely(Git repo, Description mismatchDescription) {
                try {
                    mismatchDescription.appendValueList("a git repo with tags: ", ", ", "", repo.getRepository().getTags().keySet());
// Path: src/main/java/com/github/danielflower/mavenplugins/release/GitHelper.java
// public class GitHelper {
//     public static boolean hasLocalTag(Git repo, String tagToCheck) throws GitAPIException {
//         return tag(repo, new EqualsMatcher(tagToCheck)) != null;
//     }
// 
//     public static Ref refStartingWith(Git repo, final String tagPrefix) throws GitAPIException {
//         return tag(repo, new Matcher() {
//             @Override
//             public boolean matches(String tagName) {
//                 return tagName.startsWith(tagPrefix);
//             }
//         });
//     }
// 
//     private static Ref tag(Git repo, Matcher matcher) throws GitAPIException {
//         for (Ref ref : repo.tagList().call()) {
//             String currentTag = ref.getName().replace("refs/tags/", "");
//             if (matcher.matches(currentTag)) {
//                 return ref;
//             }
//         }
//         return null;
//     }
// 
//     public static String scmUrlToRemote(String scmUrl) throws ValidationException {
//         String GIT_PREFIX = "scm:git:";
//         if (!scmUrl.startsWith(GIT_PREFIX)) {
//             List<String> messages = new ArrayList<String>();
//             String summary = "Cannot run the release plugin with a non-Git version control system";
//             messages.add(summary);
//             messages.add("The value in your scm tag is " + scmUrl);
//             throw new ValidationException(summary, messages);
//         }
//         String remote = scmUrl.substring(GIT_PREFIX.length());
//         remote  = remote.replace("file://localhost/", "file:///");
//         return remote;
//     }
// 
//     private interface Matcher {
//         public boolean matches(String tagName);
//     }
// 
//     private static class EqualsMatcher implements Matcher {
//         private final String tagToCheck;
// 
//         public EqualsMatcher(String tagToCheck) {
//             this.tagToCheck = tagToCheck;
//         }
// 
//         @Override
//         public boolean matches(String tagName) {
//             return tagToCheck.equals(tagName);
//         }
//     }
// }


// Path: src/test/java/scaffolding/GitMatchers.java
import com.github.danielflower.mavenplugins.release.GitHelper;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.Status;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Ref;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeDiagnosingMatcher;
import java.util.List;
import static org.eclipse.jgit.lib.Constants.R_TAGS;

package scaffolding;




public class GitMatchers {

    public static Matcher<Git> hasTag(final String tag) {
        return new TypeSafeDiagnosingMatcher<Git>() {
            @Override
            protected boolean matchesSafely(Git repo, Description mismatchDescription) {
                try {
                    mismatchDescription.appendValueList("a git repo with tags: ", ", ", "", repo.getRepository().getTags().keySet());
                    return GitHelper.hasLocalTag(repo, tag);