number: Number()

in preview/clean.js [43:103]


            number: Number(found[3]),
          });
        }
        return acc;
      }, [])
      .sort((lhs, rhs) => {
        if (lhs.repo < rhs.repo) {
          return -1;
        }
        if (lhs.repo > rhs.repo) {
          return 1;
        }
        return lhs.number - rhs.number;
      });
  }

  const cleanup_closed_prs = async prs => {
    const now = Date.now() / 1000;
    for (let pr of prs) {
      const url = `https://www.github.com/elastic/${pr.repo}/pull/${pr.number}`;
      const age = await prAge(pr);
      const days = (now - age) / 24 / 60 / 60;
      if (days > EXPIRE_DAYS) {
        console.log(`Deleting ${pr.branch} for ${days.toFixed(2)} days old pr at ${url}`);
        deleteBranch(pr);
      } else if (await is_pr_closed(pr)) {
        console.info(`Deleting ${pr.branch} for closed pr at ${url}`);
        deleteBranch(pr);
      } else {
        console.info(`Preserving ${pr.branch} for open pr at ${url}`);
      }
    }
  }

  const prAge = async function (pr) {
    return parseInt(await exec_git(
      [
        "show", "--pretty=%ad", "--no-notes", "--no-patch", "--date=unix",
        pr.branch
      ],
      { cwd: local_path }
    ));
  }

  const deleteBranch = async function (pr) {
    if (pr.branch === 'master' || pr.branch === 'staging') {
      // Just for super double ultra paranoia.
      throw "Can't delete master!";
    }
    await exec_git(
      ['push', 'origin', '--delete', pr.branch],
      { cwd: local_path }
    );
  }

  const is_pr_closed = function (pr) {
    console.info(`Checking status of https://github.com/elastic/${pr.repo}/pull/${pr.number}`);
    return new Promise((resolve, reject) => {
      const body = {
        query: `
          query PRClosed($repo: String!, $number: Int!) {