<commit_before>exports.run = (client, comment, issue, repository) => {
  const commenter = comment.user.login;
  const repoName = repository.name;
  const repoOwner = repository.owner.login;
  if (issue.assignees && issue.assignees.find(assignee => assignee.login === commenter)) {
    return client.newComment(issue, repository, "**ERROR:** You have already claimed this issue.");
  }
  client.repos.checkCollaborator({
    owner: repoOwner, repo: repoName, username: commenter
  }).then((response) => {
    if (response.meta.status !== "204 No Content") {
      return client.newComment(issue, repository, "**ERROR:** Unexpected response from GitHub API.");
    }
    exports.claimIssue(client, comment, issue, repository);
  }, (response) => {
    if (response.headers.status !== "404 Not Found") {
      return client.newComment(issue, repository, "**ERROR:** Unexpected response from GitHub API.");
    }
    exports.addCollaborator(client, comment, issue, repository);
  });
};

exports.addCollaborator = (client, comment, issue, repository) => {
  const commenter = comment.user.login;
  const repoName = repository.name;
  const repoOwner = repository.owner.login;
  if (!client.cfg.addCollabPermission) {
    const comment = "**ERROR:** `client.cfg.addCollabPermission` wasn't specified in `src/config.js`.";
    return client.newComment(issue, repository, comment);
  }
  client.repos.addCollaborator({
    owner: repoOwner, repo: repoName, username: commenter, permission: client.cfg.addCollabPermission
  }).then(() => exports.claimIssue(client, comment, issue, repository, true));
};

exports.claimIssue = (client, comment, issue, repository, newContrib) => {
  const commenter = comment.user.login;
  const issueNumber = issue.number;
  const repoName = repository.name;
  const repoOwner = repository.owner.login;
  client.issues.addAssigneesToIssue({
    owner: repoOwner, repo: repoName, number: issueNumber, assignees: [commenter]
  }).then(() => {
    if (newContrib) {
      client.newComment(issue, repository, client.templates.get("newContributor").replace("[commenter]", commenter));
    }
  });
};

exports.aliases = require("../config.js").claimCommands;
exports.args = false;<commit_msg>issues: Throw error if no assignee was added during issue claiming.<commit_after>exports.run = (client, comment, issue, repository) => {
  const commenter = comment.user.login;
  const repoName = repository.name;
  const repoOwner = repository.owner.login;
  if (issue.assignees && issue.assignees.find(assignee => assignee.login === commenter)) {
    return client.newComment(issue, repository, "**ERROR:** You have already claimed this issue.");
  }
  client.repos.checkCollaborator({
    owner: repoOwner, repo: repoName, username: commenter
  }).then((response) => {
    if (response.meta.status !== "204 No Content") {
      return client.newComment(issue, repository, "**ERROR:** Unexpected response from GitHub API.");
    }
    exports.claimIssue(client, comment, issue, repository);
  }, (response) => {
    if (response.headers.status !== "404 Not Found") {
      return client.newComment(issue, repository, "**ERROR:** Unexpected response from GitHub API.");
    }
    exports.addCollaborator(client, comment, issue, repository);
  });
};

exports.addCollaborator = (client, comment, issue, repository) => {
  const commenter = comment.user.login;
  const repoName = repository.name;
  const repoOwner = repository.owner.login;
  if (!client.cfg.addCollabPermission) {
    const comment = "**ERROR:** `client.cfg.addCollabPermission` wasn't specified in `src/config.js`.";
    return client.newComment(issue, repository, comment);
  }
  client.repos.addCollaborator({
    owner: repoOwner, repo: repoName, username: commenter, permission: client.cfg.addCollabPermission
  }).then(() => exports.claimIssue(client, comment, issue, repository, true));
};

exports.claimIssue = (client, comment, issue, repository, newContrib) => {
  const commenter = comment.user.login;
  const issueNumber = issue.number;
  const repoName = repository.name;
  const repoOwner = repository.owner.login;
  client.issues.addAssigneesToIssue({
    owner: repoOwner, repo: repoName, number: issueNumber, assignees: [commenter]
  }).then((response) => {
    if (!response.data.assignees) {
      return client.newComment(issue, repository, "**ERROR:** Issue claiming failed (no assignee was added).");
    }
    if (!newContrib) return;
    client.newComment(issue, repository, client.templates.get("newContributor").replace("[commenter]", commenter));
  });
};

exports.aliases = require("../config.js").claimCommands;
exports.args = false;
{'fraction_non_alphanumeric': 0.14544279250161604, 'fraction_numerical': 0.002585649644473174, 'mean_word_length': 4.633495145631068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '1740073', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1321, 'n_words': 333}