mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Revert D5409825: [RN] Convert easy files to Prettier
Differential Revision: D5409825 fbshipit-source-id: f797a40b58bc6bcc6ae53ed820a10ab49d3f10f5
This commit is contained in:
committed by
Facebook Github Bot
parent
bfece1d800
commit
aafccdf622
@@ -5,8 +5,6 @@
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
@@ -19,9 +17,7 @@ if (!process.env.CI_REPO) {
|
||||
process.exit(1);
|
||||
}
|
||||
if (!process.env.GITHUB_TOKEN) {
|
||||
console.error(
|
||||
'Missing GITHUB_TOKEN. Example: 5fd88b964fa214c4be2b144dc5af5d486a2f8c1e',
|
||||
);
|
||||
console.error('Missing GITHUB_TOKEN. Example: 5fd88b964fa214c4be2b144dc5af5d486a2f8c1e');
|
||||
process.exit(1);
|
||||
}
|
||||
if (!process.env.PULL_REQUEST_NUMBER) {
|
||||
@@ -96,7 +92,7 @@ var converters = {
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
function getShaFromPullRequest(user, repo, number, callback) {
|
||||
@@ -124,6 +120,7 @@ function getFilesFromCommit(user, repo, sha, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sadly we can't just give the line number to github, we have to give the
|
||||
* line number relative to the patch file which is super annoying. This
|
||||
@@ -135,7 +132,7 @@ function getLineMapFromPatch(patchString) {
|
||||
var fileLineIndex = 0;
|
||||
var lineMap = {};
|
||||
|
||||
patchString.split('\n').forEach(line => {
|
||||
patchString.split('\n').forEach((line) => {
|
||||
if (line.match(/^@@/)) {
|
||||
fileLineIndex = line.match(/\+([0-9]+)/)[1] - 1;
|
||||
return;
|
||||
@@ -184,27 +181,27 @@ function main(messages, user, repo, number) {
|
||||
return;
|
||||
}
|
||||
|
||||
getShaFromPullRequest(user, repo, number, sha => {
|
||||
getFilesFromCommit(user, repo, sha, files => {
|
||||
files.filter(file => messages[file.filename]).forEach(file => {
|
||||
// github api sometimes does not return a patch on large commits
|
||||
if (!file.patch) {
|
||||
return;
|
||||
}
|
||||
var lineMap = getLineMapFromPatch(file.patch);
|
||||
messages[file.filename].forEach(message => {
|
||||
sendComment(user, repo, number, sha, file.filename, lineMap, message);
|
||||
getShaFromPullRequest(user, repo, number, (sha) => {
|
||||
getFilesFromCommit(user, repo, sha, (files) => {
|
||||
files
|
||||
.filter((file) => messages[file.filename])
|
||||
.forEach((file) => {
|
||||
// github api sometimes does not return a patch on large commits
|
||||
if (!file.patch) {
|
||||
return;
|
||||
}
|
||||
var lineMap = getLineMapFromPatch(file.patch);
|
||||
messages[file.filename].forEach((message) => {
|
||||
sendComment(user, repo, number, sha, file.filename, lineMap, message);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var content = '';
|
||||
process.stdin.resume();
|
||||
process.stdin.on('data', function(buf) {
|
||||
content += buf.toString();
|
||||
});
|
||||
process.stdin.on('data', function(buf) { content += buf.toString(); });
|
||||
process.stdin.on('end', function() {
|
||||
var messages = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user