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KAAK,EAAK,gBAAgB,KAAK,QAAQ,QAErD,QAAQ,MAAM,YAAW,GACzB,EAAK,GAAG,SAAS,KACf,QAAQ,MAAM,YAAW,GACzB,QAAQ,MAAM,KAAK,GACnB,IAEH,OAAM,IACL,QAAQ,IACN,uFACD,GAEP,EAGF,OAAO,QAAU","file":"/npm/pullit@2.1.0/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/pullit@2.1.0/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const Ocktokit = require(\"@octokit/rest\");\nconst Menu = require(\"terminal-menu\");\nconst { execFileSync } = require(\"child_process\");\nconst parse = require(\"parse-github-repo-url\");\n\nclass Pullit {\n  constructor() {\n    this.init();\n    this.octokit = new Ocktokit();\n  }\n\n  init() {\n    const url = execFileSync(\"git\", [\"config\", \"--get\", \"remote.origin.url\"], {\n      encoding: \"utf8\"\n    }).trim();\n\n    return this.parsedGithubUrl(url);\n  }\n\n  parsedGithubUrl(url) {\n    const parsedUrl = parse(url);\n\n    (this.owner = parsedUrl[0]), (this.repo = parsedUrl[1]);\n  }\n\n  fetch(id) {\n    return this.octokit.pulls\n      .get({\n        owner: this.owner,\n        repo: this.repo,\n        pull_number: id\n      })\n      .then(res => {\n        const branch = res.data.head.ref;\n        execFileSync(\"git\", [\"fetch\", \"origin\", `pull/${id}/head:${branch}`]);\n        execFileSync(\"git\", [\"checkout\", branch]);\n      })\n      .catch(err => {\n        console.log(\"Error: Could not find the specified pull request.\");\n      });\n  }\n\n  fetchRequests() {\n    return this.octokit.pulls.list({\n      owner: this.owner,\n      repo: this.repo\n    });\n  }\n\n  display() {\n    this.fetchRequests()\n      .then(results => {\n        const menu = Menu({\n          width: process.stdout.columns - 4,\n          x: 0,\n          y: 2\n        });\n        menu.reset();\n        menu.write(\"Currently open pull requests:\\n\");\n        menu.write(\"-------------------------\\n\");\n\n        results.data.forEach(element => {\n          menu.add(\n            `${element.number} - ${element.title} - ${element.head.user.login}`\n          );\n        });\n\n        menu.add(`Exit`);\n\n        menu.on(\"select\", label => {\n          menu.close();\n          this.fetch(label.split(\" \")[0]);\n        });\n        process.stdin.pipe(menu.createStream()).pipe(process.stdout);\n\n        process.stdin.setRawMode(true);\n        menu.on(\"close\", () => {\n          process.stdin.setRawMode(false);\n          process.stdin.end();\n        });\n      })\n      .catch(err => {\n        console.log(\n          \"Error: could not display pull requests. Please make sure this is a valid repository.\"\n        );\n      });\n  }\n}\n\nmodule.exports = Pullit;\n"]}