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:33:46 UTC

[GitHub] [incubator-weex] wrmswindmill commented on a change in pull request #2676: [Danger] Add some static check rules in dangerfile

wrmswindmill 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_r306167077
 
 

 ##########
 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/)){
 
 Review comment:
   I hava consider this situation.
   
   ```
   var pr_body = danger.github.pr.body.toLowerCase();
   ```

----------------------------------------------------------------
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