MCPcopy Create free account
hub / github.com/TGX-Android/Publisher / newFetchGithubDetailsTask

Function newFetchGithubDetailsTask

main.js:2647–2680  ·  view source on GitHub ↗
(pullRequestId)

Source from the content-addressed store, hash-verified

2645 echo "Using commit $(git rev-parse --short HEAD) ($(git rev-parse --abbrev-ref HEAD)): $(git show -s --format=%s)"'
2646 };
2647 const newFetchGithubDetailsTask = (pullRequestId) => {
2648 return {
2649 name: 'fetchGithubDetails',
2650 act: (task, callback) => {
2651 const infoUrl = build.git.remoteUrl.replace(/(?<=(^https?:\/\/))github\.com(?=\/)/gi, 'api.github.com/repos') + '/pulls/' + pullRequestId;
2652 const url = new URL(infoUrl);
2653 fetchHttp(url, false, {
2654 headers: {
2655 'User-Agent': 'Telegram-X-Publisher'
2656 }
2657 }).then((response) => {
2658 if (response.statusCode < 200 || response.statusCode >= 300) {
2659 console.log('fetchHttp failed', response.statusCode, response.statusMessage, response.contentType, response.content);
2660 callback(1);
2661 return;
2662 }
2663 const githubInfo = JSON.parse(response.content);
2664 const author = githubInfo.user.login;
2665 const authorUrl = githubInfo.user.html_url;
2666 const pullRequest = build.pullRequests[pullRequestId];
2667 pullRequest.github = {
2668 name: author,
2669 url: authorUrl,
2670 additions: githubInfo.additions || 0,
2671 deletions: githubInfo.deletions || 0
2672 };
2673 callback(0);
2674 }).catch((e) => {
2675 console.log('fetchHttp failed', infoUrl, e);
2676 callback(1);
2677 })
2678 }
2679 };
2680 };
2681 if (command === '/checkout') {
2682 let appId = commandArgs['app.id'] || settings.app.id;
2683 let appName = commandArgs['app.name'] || settings.app.name;

Callers 1

processPrivateCommandFunction · 0.85

Calls 1

fetchHttpFunction · 0.85

Tested by

no test coverage detected