Created
February 28, 2018 04:53
-
-
Save yuanliwei/e25b9e660319fddcdb0b3d7e33b6a552 to your computer and use it in GitHub Desktop.
通过解析.patch文件查找提交的代码中新增的数据库字段
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| 通过解析.patch文件查找提交的代码中新增的数据库字段 | |
| */ | |
| const fs = require('fs'); | |
| console.log(process.argv); | |
| var arr = fs.readFileSync(process.argv[2], 'utf-8').split('\n') | |
| var tmpArr = [] | |
| for (var i = 0; i < arr.length; i++) { | |
| var line = arr[i] | |
| if (line.startsWith('+++')) { | |
| tmpArr.push(line) | |
| } | |
| if (line.startsWith('+ @Column') | |
| || line.startsWith('+ @Id')) { | |
| tmpArr.push(line) | |
| i++ | |
| tmpArr.push(arr[i]) | |
| } | |
| } | |
| arr = tmpArr | |
| tmpArr = [] | |
| for (var i = 0; i < arr.length; i++) { | |
| var line = arr[i] | |
| if (line.startsWith('+++')) { | |
| if (arr[i+1]&&arr[i+1].startsWith('+ ')) { | |
| tmpArr.push(line) | |
| } | |
| } | |
| if (line.startsWith('+ ')) { | |
| tmpArr.push(line) | |
| } | |
| } | |
| console.log(tmpArr.join('\n')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment