You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2019/07/23 07:25:37 UTC
[GitHub] [incubator-weex] YorkShen commented on a change in pull request
#2676: [Danger] Add some static check rules in dangerfile
YorkShen commented on a change in pull request #2676: [Danger] Add some static check rules in dangerfile
URL: https://github.com/apache/incubator-weex/pull/2676#discussion_r306161328
##########
File path: dangerfile.js
##########
@@ -16,15 +16,67 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { schedule, danger, fail, warn, message, markdown } from "danger";
+// Removed import
import fs from "fs";
import path from 'path';
import GitHubApi from 'github';
import parseDiff from 'parse-diff';
+// check if pr submitted to master branch
+console.log("checkMasterBranch")
+const isMergeRefMaster = danger.github.pr.base.ref === 'master';
+if(!isMergeRefMaster){
+ fail("you must submit PR to master branch");
+}
+
+// match regex line by line
+function matchRegex(pr_body,regex){
+ const lines = pr_body.split("\n");
+ for (let i = 0; i < lines.length; i++) {
+ if(lines[i].match(regex)){
+ return true;
+ }
+ }
+ return false;
+}
+
+var pr_body = danger.github.pr.body.toLowerCase();
+// Because Pr description template include the following lineļ¼
+// 1. Write the corresponding [documentation](https://weex.io/guide/contribute/how-to-contribute.html#contribute-code-or-document)
+// so we should check the documentation below the ### checklist
+console.log("checkDocumentation");
+const index = pr_body.indexOf("checklist")
+const includeChecklist = (index!=-1)
+if(includeChecklist && !matchRegex(pr_body.substring(index),/documentation.*http/)){
+ const msg = "if you update the code, "+
+ "maybe you should update the documentation and add the documentation link in the PR description. \n" +
+ "here is the guide about how to contribute documentation:https://weex.apache.org/guide/contribute/how-to-contribute.html#contribute-code-or-document \n";
+ warn(msg);
+}
+
+// check if pr contains a demo link
+console.log("checkDemo");
+if(!matchRegex(pr_body,/demo.*http/)){
Review comment:
You should allow both of the following spelling:
* demo
* Demo
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services