<commit_before>package im.tox.upsourcebot.resources;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import im.tox.upsourcebot.client.GitHubConnector;
import im.tox.upsourcebot.core.payloads.IssueWebhook;
import im.tox.upsourcebot.core.payloads.PullRequestWebhook;

@Path("/github-webhook/{upsource-name}")
@Consumes(MediaType.APPLICATION_JSON)
public class GitHubWebhookResource {

  private static final Logger LOGGER = LoggerFactory.getLogger(GitHubWebhookResource.class);

  private GitHubConnector gitHubConnector;

  public GitHubWebhookResource(GitHubConnector gitHubConnector) {
    this.gitHubConnector = gitHubConnector;
  }

  @POST
  @Path("/issue")
  public Response receiveHook(IssueWebhook payload,
                              @PathParam("upsource-name") String upsourceName) {
    switch (payload.getAction()) {
      case "opened":
      case "assigned":
      case "unassigned":
      case "labeled":
      case "unlabeled":
      case "closed":
      case "reopened":
        break;
      default:
        LOGGER.error("GitHub Issue payload format changed");
        return Response.status(Response.Status.NOT_IMPLEMENTED).build();
    }
    return Response.accepted().build();
  }

  @POST
  @Path("/pull-request")
  public Response receiveHook(@Valid PullRequestWebhook payload,
                              @PathParam("upsource-name") String upsourceName) {
    switch (payload.getAction()) {
      case "opened":
        // Handle creation
        // Fall through to synchronized
      case "synchronized":
        new Thread(() -> {
          String repoName = payload.getRepository().getFullName();
          String commitSHA = payload.getPullRequest().getHead().getSha();
          String url = "http://example.com/" + upsourceName;
          String description = "Code review is pending";
          String context = "review";
          gitHubConnector.setPendingCommitStatus(repoName, commitSHA, url, description, context);
        }).start();
        break;
      case "assigned":
      case "unassigned":
      case "labeled":
      case "unlabeled":
      case "closed":
      case "reopened":
        break;
      default:
        LOGGER.error("GitHub Pull request payload format changed");
        return Response.status(Response.Status.NOT_IMPLEMENTED).build();
    }
    return Response.accepted().build();
  }
}<commit_msg>The correct event is synchronize<commit_after>package im.tox.upsourcebot.resources;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import im.tox.upsourcebot.client.GitHubConnector;
import im.tox.upsourcebot.core.payloads.IssueWebhook;
import im.tox.upsourcebot.core.payloads.PullRequestWebhook;

@Path("/github-webhook/{upsource-name}")
@Consumes(MediaType.APPLICATION_JSON)
public class GitHubWebhookResource {

  private static final Logger LOGGER = LoggerFactory.getLogger(GitHubWebhookResource.class);

  private GitHubConnector gitHubConnector;

  public GitHubWebhookResource(GitHubConnector gitHubConnector) {
    this.gitHubConnector = gitHubConnector;
  }

  @POST
  @Path("/issue")
  public Response receiveHook(IssueWebhook payload,
                              @PathParam("upsource-name") String upsourceName) {
    switch (payload.getAction()) {
      case "opened":
      case "assigned":
      case "unassigned":
      case "labeled":
      case "unlabeled":
      case "closed":
      case "reopened":
        break;
      default:
        LOGGER.error("GitHub Issue payload format changed");
        return Response.status(Response.Status.NOT_IMPLEMENTED).build();
    }
    return Response.accepted().build();
  }

  @POST
  @Path("/pull-request")
  public Response receiveHook(@Valid PullRequestWebhook payload,
                              @PathParam("upsource-name") String upsourceName) {
    switch (payload.getAction()) {
      case "opened":
        // Handle creation
        // Fall through to synchronize
      case "synchronize":
        new Thread(() -> {
          String repoName = payload.getRepository().getFullName();
          String commitSHA = payload.getPullRequest().getHead().getSha();
          String url = "http://example.com/" + upsourceName;
          String description = "Code review is pending";
          String context = "review";
          gitHubConnector.setPendingCommitStatus(repoName, commitSHA, url, description, context);
        }).start();
        break;
      case "assigned":
      case "unassigned":
      case "labeled":
      case "unlabeled":
      case "closed":
      case "reopened":
        break;
      default:
        LOGGER.error("GitHub Pull request payload format changed");
        return Response.status(Response.Status.NOT_IMPLEMENTED).build();
    }
    return Response.accepted().build();
  }
}
{'fraction_non_alphanumeric': 0.11460544086436426, 'fraction_numerical': 0.0007717538105344395, 'mean_word_length': 3.0468384074941453, 'pattern_counts': {'":': 30, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2654437', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1477, 'n_words': 314}