forked from AnzhiZhang/MCDReforgedPlugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangeFinder.js
38 lines (34 loc) · 1.31 KB
/
changeFinder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const core = require('@actions/core');
const execSync = require('child_process').execSync;
const pluginList = require('./plugin_list.json');
const tagList = execSync('git tag', {encoding: 'utf-8'}).trim().split('\n').reverse();
function isAffectReleaseLog(log) {
return log.includes('fix') || log.includes('feat') || log.includes('!') || log.includes('Release-As: ');
}
let changedList = [];
for (let pluginKey in pluginList) {
let pluginID = pluginList[pluginKey];
let findTagFlag = false;
for (let tagKey in tagList) {
let tagName = tagList[tagKey];
if (tagName.startsWith(pluginID)) {
let gitLog = execSync(`git log ${tagName}...HEAD ${pluginID}`, {encoding: 'utf-8'});
if (isAffectReleaseLog(gitLog)) {
changedList.push(pluginID);
}
findTagFlag = true;
break;
}
}
if (!findTagFlag) {
let gitLog = execSync(`git log ${pluginID}`, {encoding: 'utf-8'});
if (isAffectReleaseLog(gitLog)) {
changedList.push(pluginID);
}
}
}
function isAffectReleaseLog(log) {
return log.includes('fix') || log.includes('feat') || log.includes('!') || log.includes('Release-As: ');
}
core.setOutput('changed', changedList.length > 0);
core.setOutput('plugins', JSON.stringify(changedList));