Пример #1
0
 public static boolean isUrlAccessible(String url) {
   try {
     Git.lsRemoteRepository().setRemote(url).call();
   } catch (GitAPIException e) {
     return false;
   }
   return true;
 }
Пример #2
0
 public static String getHashOfBound(String url, UpdateBound bound) {
   if (bound instanceof CommitHashBound) {
     return bound.getBoundHash();
   }
   String refName = bound.getBound();
   try {
     Collection<Ref> refs =
         Git.lsRemoteRepository().setRemote(url).setHeads(true).setTags(true).call();
     for (Ref ref : refs) {
       boolean isCorrectRef = ref.getName().contains(refName);
       if (isCorrectRef) {
         ObjectId objectId = ref.getPeeledObjectId();
         if (objectId == null) {
           objectId = ref.getObjectId();
         }
         return ObjectId.toString(objectId);
       }
     }
   } catch (GitAPIException e) {
     return null;
   }
   return null;
 }