Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.ReceiveCommand


      return;
    }

    ReceiveCommandEvent branchUpdate = (ReceiveCommandEvent) event;
    RepositoryModel repository = branchUpdate.model;
    ReceiveCommand cmd = branchUpdate.cmd;
    try {
      switch (cmd.getType()) {
      case CREATE:
      case UPDATE_NONFASTFORWARD:
        // reindex everything
        reindex(repository);
        break;
      case UPDATE:
        // incrementally index ticket updates
        resetCaches(repository);
        long start = System.nanoTime();
        log.info("incrementally indexing {} ticket branch due to received ref update", repository.name);
        Repository db = repositoryManager.getRepository(repository.name);
        try {
          Set<Long> ids = new HashSet<Long>();
          List<PathChangeModel> paths = JGitUtils.getFilesInRange(db,
              cmd.getOldId().getName(), cmd.getNewId().getName());
          for (PathChangeModel path : paths) {
            String name = path.name.substring(path.name.lastIndexOf('/') + 1);
            if (!JOURNAL.equals(name)) {
              continue;
            }
            String tid = path.path.split("/")[2];
            long ticketId = Long.parseLong(tid);
            if (!ids.contains(ticketId)) {
              ids.add(ticketId);
              TicketModel ticket = getTicket(repository, ticketId);
              log.info(MessageFormat.format("indexing ticket #{0,number,0}: {1}",
                  ticketId, ticket.title));
              indexer.index(ticket);
            }
          }
          long end = System.nanoTime();
          log.info("incremental indexing of {0} ticket(s) completed in {1} msecs",
              ids.size(), TimeUnit.NANOSECONDS.toMillis(end - start));
        } finally {
          db.close();
        }
        break;
      default:
        log.warn("Unexpected receive type {} in BranchTicketService.onRefsChanged" + cmd.getType());
        break;
      }
    } catch (Exception e) {
      log.error("failed to reindex " + repository.name, e);
    }
View Full Code Here


        final boolean testing = false;
        Git git = new Git(repository);
        FetchResult result = git.fetch().setRemote(mirror.getName()).setDryRun(testing).call();
        Collection<TrackingRefUpdate> refUpdates = result.getTrackingRefUpdates();
        if (refUpdates.size() > 0) {
          ReceiveCommand ticketBranchCmd = null;
          for (TrackingRefUpdate ru : refUpdates) {
            StringBuilder sb = new StringBuilder();
            sb.append("updated mirror ");
            sb.append(repositoryName);
            sb.append(" ");
            sb.append(ru.getRemoteName());
            sb.append(" -> ");
            sb.append(ru.getLocalName());
            if (ru.getResult() == Result.FORCED) {
              sb.append(" (forced)");
            }
            sb.append(" ");
            sb.append(ru.getOldObjectId() == null ? "" : ru.getOldObjectId().abbreviate(7).name());
            sb.append("..");
            sb.append(ru.getNewObjectId() == null ? "" : ru.getNewObjectId().abbreviate(7).name());
            logger.info(sb.toString());

            if (BranchTicketService.BRANCH.equals(ru.getLocalName())) {
              ReceiveCommand.Type type = null;
              switch (ru.getResult()) {
              case NEW:
                type = Type.CREATE;
                break;
              case FAST_FORWARD:
                type = Type.UPDATE;
                break;
              case FORCED:
                type = Type.UPDATE_NONFASTFORWARD;
                break;
              default:
                type = null;
                break;
              }

              if (type != null) {
                ticketBranchCmd = new ReceiveCommand(ru.getOldObjectId(),
                  ru.getNewObjectId(), ru.getLocalName(), type);
              }
            }
          }
View Full Code Here

  public void testFogbugz() throws Exception {
    MockGitblit gitblit = new MockGitblit();
    MockLogger logger = new MockLogger();
    MockClientLogger clientLogger = new MockClientLogger();
    List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
    commands.add(new ReceiveCommand(ObjectId
        .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
        .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
    commands.add(new ReceiveCommand(ObjectId
        .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
        .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master2"));

    RepositoryModel repository = repositories().getRepositoryModel("helloworld.git");
    repository.customFields = new HashMap<String,String>();
View Full Code Here

  public void testSendHtmlMail() throws Exception {
    MockGitblit gitblit = new MockGitblit();
    MockLogger logger = new MockLogger();
    MockClientLogger clientLogger = new MockClientLogger();
    List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
    commands.add(new ReceiveCommand(ObjectId
        .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
        .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
    commands.add(new ReceiveCommand(ObjectId
        .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
        .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master2"));

    RepositoryModel repository = repositories().getRepositoryModel("helloworld.git");
    repository.mailingLists.add("list@helloworld.git");
View Full Code Here

  public void testSendMail() throws Exception {
    MockGitblit gitblit = new MockGitblit();
    MockLogger logger = new MockLogger();
    MockClientLogger clientLogger = new MockClientLogger();
    List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
    commands.add(new ReceiveCommand(ObjectId
        .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
        .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
    commands.add(new ReceiveCommand(ObjectId
        .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
        .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master2"));

    RepositoryModel repository = repositories().getRepositoryModel("helloworld.git");
    repository.mailingLists.add("list@helloworld.git");
View Full Code Here

  public void testProtectRefsCreateBranch() throws Exception {
    MockGitblit gitblit = new MockGitblit();
    MockLogger logger = new MockLogger();
    MockClientLogger clientLogger = new MockClientLogger();
    List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
    commands.add(new ReceiveCommand(ObjectId.zeroId(), ObjectId
        .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));

    RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());

    test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);
View Full Code Here

  public void testProtectRefsCreateTag() throws Exception {
    MockGitblit gitblit = new MockGitblit();
    MockLogger logger = new MockLogger();
    MockClientLogger clientLogger = new MockClientLogger();
    List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
    commands.add(new ReceiveCommand(ObjectId.zeroId(), ObjectId
        .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/tags/v1.0"));

    RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());

    test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);
View Full Code Here

  public void testProtectRefsFastForward() throws Exception {
    MockGitblit gitblit = new MockGitblit();
    MockLogger logger = new MockLogger();
    MockClientLogger clientLogger = new MockClientLogger();
    List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
    commands.add(new ReceiveCommand(ObjectId
        .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
        .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));

    RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
View Full Code Here

  public void testProtectRefsDeleteMasterBranch() throws Exception {
    MockGitblit gitblit = new MockGitblit();
    MockLogger logger = new MockLogger();
    MockClientLogger clientLogger = new MockClientLogger();
    List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
    ReceiveCommand command = new ReceiveCommand(ObjectId
        .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(),
        "refs/heads/master");
    commands.add(command);

    RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());

    test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);
    assertEquals(ReceiveCommand.Result.REJECTED_NODELETE, command.getResult());
    assertEquals(0, logger.messages.size());
  }
View Full Code Here

  public void testProtectRefsDeleteOtherBranch() throws Exception {
    MockGitblit gitblit = new MockGitblit();
    MockLogger logger = new MockLogger();
    MockClientLogger clientLogger = new MockClientLogger();
    List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
    commands.add(new ReceiveCommand(ObjectId
        .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(),
        "refs/heads/other"));

    RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.transport.ReceiveCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.