微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.eclipse.jgit.lib.SymbolicRef的实例源码

项目:appformer    文件RefTreeUpdateCommand.java   
private void symRef(final Git git,final String name,final String dst)
        throws java.io.IOException {
    commit(git.getRepository(),null,(reader,tree) -> {
               Ref old = tree.exactRef(reader,name);
               Ref newx = tree.exactRef(reader,dst);
               final Command n;
               if (newx != null) {
                   n = new Command(old,new SymbolicRef(name,newx));
               } else {
                   n = new Command(old,new ObjectIdRef.Unpeeled(Ref.Storage.NEW,dst,null)));
               }
               return tree.apply(Collections.singleton(n));
           });
}
项目:jgit-cassandra    文件RefStore.java   
/**
 * Parses a Cassandra refs table row and converts it to a Ref
 *
 * @param row a single Cassandra row to parse
 * @return a ref,or null if the "row" parameter is null
 * @throws IOException           if an exception occurs when communicating to the
 *                               database
 * @throws IllegalStateException if the "type" field read back from the
 *                               database is not one of the four handled
 *                               types (@see RefType).
 */
private Ref rowToRef(Row row) throws IOException {
    if (row == null) {
        return null;
    }

    final String name = row.getString("name");
    final String value = row.getString("value");
    final int refType = row.getInt("type");

    if (refType == RefType.PEELED_NONTAG.getValue()) {
        return new ObjectIdRef.PeelednonTag(Ref.Storage.NETWORK,name,ObjectId.fromString(value));
    } else if (refType == RefType.PEELED_TAG.getValue()) {
        final String auxValue = row.getString("aux_value");
        return new ObjectIdRef.PeeledTag(Ref.Storage.NETWORK,ObjectId.fromString(value),ObjectId.fromString(auxValue));
    } else if (refType == RefType.UNPEELED.getValue()) {
        return new ObjectIdRef.Unpeeled(Ref.Storage.NETWORK,ObjectId.fromString(value));
    } else if (refType == RefType.SYMBOLIC.getValue()) {
        return new SymbolicRef(name,get(value));
    } else {
        throw new IllegalStateException("Unhandled ref type: " + refType);
    }
}
项目:jgit-cassandra    文件RefStore.java   
/**
 * Inserts a single ref into the database
 *
 * @throws IllegalStateException if the reference concrete type is not
 *                               one of the four handled classes
 *                               (@see RefType).
 */
private void putRef(String name,Ref r) throws IOException {
    if (r instanceof SymbolicRef) {
        putRow(name,RefType.SYMBOLIC,r.getTarget().getName(),"");
    } else if (r instanceof ObjectIdRef.PeelednonTag) {
        putRow(name,RefType.PEELED_NONTAG,r.getobjectId().name(),"");
    } else if (r instanceof ObjectIdRef.PeeledTag) {
        putRow(name,RefType.PEELED_TAG,r.getPeeledobjectId().toString());
    } else if (r instanceof ObjectIdRef.Unpeeled) {
        putRow(name,RefType.UNPEELED,"");
    } else {
        throw new IllegalStateException("Unhandled ref type: " + r);
    }
}
项目:gerrit    文件VisibleRefFilter.java   
private Map<String,Ref> addUseRSSelfSymref(Map<String,Ref> refs) {
  if (user.get().isIdentifiedUser()) {
    Ref r = refs.get(RefNames.refsUsers(user.get().getAccountId()));
    if (r != null) {
      SymbolicRef s = new SymbolicRef(REFS_USERS_SELF,r);
      refs = new HashMap<>(refs);
      refs.put(s.getName(),s);
    }
  }
  return refs;
}
项目:cloudata    文件CloudRefDatabase.java   
static RefData toModel(RepositoryData repositoryData,Ref ref) {
  RefData.Builder data = RefData.newBuilder();

  String name = ref.getName();
  if (name != null) {
    data.setName(name);
  }

  if (ref instanceof SymbolicRef) {
    Ref target = ref.getTarget();
    if (target == null) {
      throw new IllegalStateException();
    }

    if (target instanceof Unpeeled) {
      String targetName = target.getName();
      if (targetName != null) {
        data.setTargetName(targetName);
      } else {
        throw new IllegalStateException();
      }
    } else {
      throw new IllegalArgumentException();
    }
  } else if (ref instanceof PeelednonTag) {
    ObjectId objectId = ref.getobjectId();
    if (objectId != null) {
      byte[] buf = new byte[20];
      objectId.copyRawTo(buf,0);
      data.setobjectId(ByteString.copyFrom(buf));
    } else {
      throw new IllegalArgumentException();
    }
  } else {
    throw new IllegalArgumentException();
  }

  data.setRepositoryId(repositoryData.getRepositoryId());
  return data.build();
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。