Java Code Examples for org.eclipse.jgit.lib.Repository#isValidRefName()

The following examples show how to use org.eclipse.jgit.lib.Repository#isValidRefName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VersionNamer.java    From multi-module-maven-release-plugin with MIT License 6 votes vote down vote up
public VersionName name(String pomVersion, Long buildNumber, Collection<Long> previousBuildNumbers) throws ValidationException {

        if (buildNumber == null) {
            if (previousBuildNumbers.size() == 0) {
                buildNumber = 0L;
            } else {
                buildNumber = nextBuildNumber(previousBuildNumbers);
            }
        }

        VersionName versionName = new VersionName(pomVersion, pomVersion.replace("-SNAPSHOT", ""), buildNumber, this.delimiter);

        if (!Repository.isValidRefName("refs/tags/" + versionName.releaseVersion())) {
            String summary = "Sorry, '" + versionName.releaseVersion() + "' is not a valid version.";
            throw new ValidationException(summary, asList(
                summary,
                "Version numbers are used in the Git tag, and so can only contain characters that are valid in git tags.",
                "Please see https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html for tag naming rules."
            ));
        }
        return versionName;
    }
 
Example 2
Source File: TagBean.java    From onedev with MIT License 5 votes vote down vote up
@Override
public boolean isValid(ConstraintValidatorContext context) {
	if (!Repository.isValidRefName(Constants.R_TAGS + getName())) {
           context.buildConstraintViolationWithTemplate("Invalid tag name")
	            .addPropertyNode("name").addConstraintViolation()
	            .disableDefaultConstraintViolation();
           return false;
	} else {
		return true;
	}
}
 
Example 3
Source File: BranchBean.java    From onedev with MIT License 5 votes vote down vote up
@Override
public boolean isValid(ConstraintValidatorContext context) {
	if (!Repository.isValidRefName(Constants.R_HEADS + getName())) {
           context.buildConstraintViolationWithTemplate("Invalid branch name")
	            .addPropertyNode("name").addConstraintViolation()
	            .disableDefaultConstraintViolation();
           return false;
	} else {
		return true;
	}
}
 
Example 4
Source File: JGitUtils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static boolean isValidRefName (String refName) {
    return Repository.isValidRefName(refName);
}