org.eclipse.jgit.lib.Repository.isValidRefName()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中org.eclipse.jgit.lib.Repository.isValidRefName方法的一些代码示例,展示了Repository.isValidRefName的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Repository.isValidRefName方法的具体详情如下:
包路径:org.eclipse.jgit.lib.Repository
类名称:Repository
方法名:isValidRefName

Repository.isValidRefName介绍

[英]Check validity of a ref name. It must not contain character that has a special meaning in a Git object reference expression. Some other dangerous characters are also excluded. For portability reasons '' is excluded
[中]检查引用名称的有效性。它不能包含在Git对象引用表达式中具有特殊含义的字符。其他一些危险人物也被排除在外。出于可移植性原因,不包括“\”

代码示例

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private static boolean isValidRef(Command cmd) {
  String n = cmd.getRefName();
  return HEAD.equals(n) || Repository.isValidRefName(n);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Include an object (and everything reachable from it) in the bundle.
 *
 * @param name
 *            name the recipient can discover this object as from the
 *            bundle's list of advertised refs . The name must be a valid
 *            ref format and must not have already been included in this
 *            bundle writer.
 * @param id
 *            object to pack. Multiple refs may point to the same object.
 */
public void include(String name, AnyObjectId id) {
  boolean validRefName = Repository.isValidRefName(name) || Constants.HEAD.equals(name);
  if (!validRefName)
    throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidRefName, name));
  if (include.containsKey(name))
    throw new IllegalStateException(JGitText.get().duplicateRef + name);
  include.put(name, id.toObjectId());
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private void processOptions() throws InvalidRefNameException {
  if (name == null
      || !Repository.isValidRefName(R_HEADS + name)
      || !isValidBranchName(name))
    throw new InvalidRefNameException(MessageFormat.format(JGitText
        .get().branchNameInvalid, name == null ? "<null>" : name)); //$NON-NLS-1$
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

String fullName = result.startsWith(Constants.R_HEADS) ? result
    : Constants.R_HEADS + result;
if (isValidRefName(fullName)) {
  return result;

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private void processOptions() throws InvalidRefNameException,
    RefAlreadyExistsException, IOException {
  if (((!checkoutAllPaths && paths.isEmpty()) || orphan)
      && (name == null || !Repository
          .isValidRefName(Constants.R_HEADS + name)))
    throw new InvalidRefNameException(MessageFormat.format(JGitText
        .get().branchNameInvalid, name == null ? "<null>" : name)); //$NON-NLS-1$
  if (orphan) {
    Ref refToCheck = repo.exactRef(getBranchName());
    if (refToCheck != null)
      throw new RefAlreadyExistsException(MessageFormat.format(
          JGitText.get().refAlreadyExists, name));
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Sets default values for not explicitly specified options. Then validates
 * that all required data has been provided.
 *
 * @param state
 *            the state of the repository we are working on
 *
 * @throws InvalidTagNameException
 *             if the tag name is null or invalid
 * @throws UnsupportedOperationException
 *             if the tag is signed (not supported yet)
 */
private void processOptions(RepositoryState state)
    throws InvalidTagNameException {
  if (tagger == null && annotated)
    tagger = new PersonIdent(repo);
  if (name == null || !Repository.isValidRefName(Constants.R_TAGS + name))
    throw new InvalidTagNameException(
        MessageFormat.format(JGitText.get().tagNameInvalid,
            name == null ? "<null>" : name)); //$NON-NLS-1$
  if (signed)
    throw new UnsupportedOperationException(
        JGitText.get().signingNotSupportedOnTag);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

static ReceiveCommand parseCommand(String line) throws PackProtocolException {
   if (line == null || line.length() < 83) {
    throw new PackProtocolException(
        JGitText.get().errorInvalidProtocolWantedOldNewRef);
  }
  String oldStr = line.substring(0, 40);
  String newStr = line.substring(41, 81);
  ObjectId oldId, newId;
  try {
    oldId = ObjectId.fromString(oldStr);
    newId = ObjectId.fromString(newStr);
  } catch (InvalidObjectIdException e) {
    throw new PackProtocolException(
        JGitText.get().errorInvalidProtocolWantedOldNewRef, e);
  }
  String name = line.substring(82);
  if (!Repository.isValidRefName(name)) {
    throw new PackProtocolException(
        JGitText.get().errorInvalidProtocolWantedOldNewRef);
  }
  return new ReceiveCommand(oldId, newId, name);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

@Nullable
private ObjectId resolveSimple(String revstr) throws IOException {
  if (ObjectId.isId(revstr))
    return ObjectId.fromString(revstr);
  if (Repository.isValidRefName("x/" + revstr)) { //$NON-NLS-1$
    Ref r = getRefDatabase().getRef(revstr);
    if (r != null)
      return r.getObjectId();
  }
  if (AbbreviatedObjectId.isId(revstr))
    return resolveAbbreviation(revstr);
  int dashg = revstr.indexOf("-g"); //$NON-NLS-1$
  if ((dashg + 5) < revstr.length() && 0 <= dashg
      && isHex(revstr.charAt(dashg + 2))
      && isHex(revstr.charAt(dashg + 3))
      && isAllHex(revstr, dashg + 4)) {
    // Possibly output from git describe?
    String s = revstr.substring(dashg + 2);
    if (AbbreviatedObjectId.isId(s))
      return resolveAbbreviation(s);
  }
  return null;
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

for (RemoteRefUpdate u : refUpdates.values()) {
  final String n = u.getRemoteName();
  if (!n.startsWith("refs/") || !Repository.isValidRefName(n)) { //$NON-NLS-1$
    u.setStatus(Status.REJECTED_OTHER_REASON);
    u.setMessage(JGitText.get().funnyRefname);

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

if (!Repository.isValidRefName(fullNewName))
  throw new InvalidRefNameException(MessageFormat.format(JGitText
      .get().branchNameInvalid, fullNewName));

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

if (!Repository.isValidRefName("x/" + name)) //$NON-NLS-1$
          throw new RevisionSyntaxException(MessageFormat
              .format(JGitText.get().invalidRefName,
        if (name.equals("")) //$NON-NLS-1$
          name = Constants.HEAD;
        if (!Repository.isValidRefName("x/" + name)) //$NON-NLS-1$
          throw new RevisionSyntaxException(MessageFormat
              .format(JGitText.get().invalidRefName,
  return null;
name = revstr.substring(done);
if (!Repository.isValidRefName("x/" + name)) //$NON-NLS-1$
  throw new RevisionSyntaxException(
      MessageFormat.format(JGitText.get().invalidRefName, name),

代码示例来源:origin: org.eclipse.egit/ui

private static boolean isValidRefExpression(final String s) {
  if (RefSpec.isWildcard(s)) {
    // replace wildcard with some legal name just for checking
    return isValidRefExpression(s.substring(0, s.length() - 1) + 'X');
  } else
    return Repository.isValidRefName(s)
        || Repository.isValidRefName(Constants.R_HEADS + s)
        || Repository.isValidRefName(Constants.R_TAGS + s);
}

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

private static boolean isValidRef(Command cmd) {
  String n = cmd.getRefName();
  return HEAD.equals(n) || Repository.isValidRefName(n);
}

代码示例来源:origin: berlam/github-bucket

private static boolean isValidRef(Command cmd) {
  String n = cmd.getRefName();
  return HEAD.equals(n) || Repository.isValidRefName(n);
}

代码示例来源:origin: com.beijunyi.parallelgit/parallelgit-utils

@Nonnull
public static String ensureRefPrefix(@Nonnull String name, @Nonnull String prefix) {
 if(!matchesPrefix(name, prefix)) {
  if(matchesRefPrefix(name))
   throw new IllegalArgumentException("\"" + prefix + "\" is not the prefix of " + name);
  name = prefix + name;
 }
 if(!Repository.isValidRefName(name))
  throw new IllegalArgumentException(name + " is not a valid ref name");
 return name;
}

代码示例来源:origin: beijunyi/ParallelGit

@Nonnull
public static String appendPrefix(String name, String prefix) {
 if(!matchesPrefix(name, prefix)) {
  if(matchesRefPrefix(name)) throw new IllegalArgumentException("\"" + prefix + "\" is not the prefix of " + name);
  name = prefix + name;
 }
 if(!Repository.isValidRefName(name)) throw new IllegalArgumentException(name + " is not a valid ref name");
 return name;
}

代码示例来源:origin: com.beijunyi/parallelgit-utils

@Nonnull
public static String appendPrefix(String name, String prefix) {
 if(!matchesPrefix(name, prefix)) {
  if(matchesRefPrefix(name)) throw new IllegalArgumentException("\"" + prefix + "\" is not the prefix of " + name);
  name = prefix + name;
 }
 if(!Repository.isValidRefName(name)) throw new IllegalArgumentException(name + " is not a valid ref name");
 return name;
}

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

private void processOptions() throws InvalidRefNameException {
  if (name == null
      || !Repository.isValidRefName(Constants.R_HEADS + name))
    throw new InvalidRefNameException(MessageFormat.format(JGitText
        .get().branchNameInvalid, name == null ? "<null>" : name)); //$NON-NLS-1$
}

代码示例来源:origin: berlam/github-bucket

private void processOptions() throws InvalidRefNameException {
  if (name == null
      || !Repository.isValidRefName(R_HEADS + name)
      || !isValidBranchName(name))
    throw new InvalidRefNameException(MessageFormat.format(JGitText
        .get().branchNameInvalid, name == null ? "<null>" : name)); //$NON-NLS-1$
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

|| !Repository.isValidRefName(cmd.getRefName())) {
cmd.setResult(Result.REJECTED_OTHER_REASON, JGitText.get().funnyRefname);

相关文章

Repository类方法