(sha)
| 96 | } |
| 97 | |
| 98 | async function getCommitLog(sha) { |
| 99 | let shortLog = ''; |
| 100 | let formattedLog = ''; |
| 101 | |
| 102 | const hasGh = await hasGithubCLI(); |
| 103 | const rawLog = await execRead(` |
| 104 | git log --topo-order --pretty=format:'%s' ${sha}...HEAD -- packages/react-devtools* |
| 105 | `); |
| 106 | const lines = rawLog.split('\n'); |
| 107 | for (let i = 0; i < lines.length; i++) { |
| 108 | const line = lines[i].replace(/^\[devtools\] */i, ''); |
| 109 | const match = line.match(/(.+) \(#([0-9]+)\)/); |
| 110 | if (match !== null) { |
| 111 | const title = match[1]; |
| 112 | const pr = match[2]; |
| 113 | let username; |
| 114 | if (hasGh) { |
| 115 | const response = await execRead( |
| 116 | `gh api /repos/facebook/react/pulls/${pr}` |
| 117 | ); |
| 118 | const {user} = JSON.parse(response); |
| 119 | username = `[${user.login}](${user.html_url})`; |
| 120 | } else { |
| 121 | username = '[USERNAME](https://github.com/USERNAME)'; |
| 122 | } |
| 123 | formattedLog += `\n* ${title} (${username} in [#${pr}](${PULL_REQUEST_BASE_URL}${pr}))`; |
| 124 | shortLog += `\n* ${title}`; |
| 125 | } else { |
| 126 | formattedLog += `\n* ${line}`; |
| 127 | shortLog += `\n* ${line}`; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | return [shortLog, formattedLog]; |
| 132 | } |
| 133 | |
| 134 | async function hasGithubCLI() { |
| 135 | try { |
no test coverage detected