update this!

This commit is contained in:
Letter N
2020-12-29 11:24:55 +08:00
parent 23a7d8777d
commit 3c1cfca9c5
3 changed files with 34 additions and 31 deletions

View File

@@ -5,6 +5,8 @@
* For documentation on the changelog generator see https://tgstation13.org/phpBB/viewtopic.php?f=5&t=5157
* To hide prs from being announced in game, place a [s] in front of the title
* All runtime errors are echo'ed to the webhook's logs in github
* Events to be sent via GitHub webhook: Pull Requests, Pushes
* Any other Event will result in a 404 returned to the webhook.
*/
/**CREDITS:
@@ -23,6 +25,7 @@ define('F_UNVALIDATED_USER', 1<<0);
define('F_SECRET_PR', 1<<1);
//CONFIGS ARE IN SECRET.PHP, THESE ARE JUST DEFAULTS!
$hookSecret = '08ajh0qj93209qj90jfq932j32r';
$apiKey = '209ab8d879c0f987d06a09b9d879c0f987d06a09b9d8787d0a089c';
$repoOwnerAndName = "tgstation/tgstation";
@@ -32,7 +35,7 @@ $path_to_script = 'tools/WebhookProcessor/github_webhook_processor.php';
$tracked_branch = "master";
$trackPRBalance = true;
$prBalanceJson = '';
$startingPRBalance = 5;
$startingPRBalance = 30;
$maintainer_team_id = 133041;
$validation = "org";
$validation_count = 1;
@@ -248,7 +251,7 @@ function tag_pr($payload, $opened) {
$tags[] = 'Merge Conflict';
$treetags = array('_maps' => 'Map Edit', 'tools' => 'Tools', 'SQL' => 'SQL', '.github' => 'GitHub');
$addonlytags = array('icons' => 'Sprites', 'sound' => 'Sound', 'config' => 'Config Update', 'code/controllers/configuration/entries' => 'Config Update', 'tgui' => 'UI');
$addonlytags = array('icons' => 'Sprites', 'sound' => 'Sound', 'config' => 'Config Update', 'code/controllers/configuration/entries' => 'Config Update', 'code/modules/unit_tests' => 'Unit Tests', 'tgui' => 'UI');
foreach($treetags as $tree => $tag)
if(has_tree_been_edited($payload, $tree))
$tags[] = $tag;
@@ -392,14 +395,12 @@ function handle_pr($payload) {
set_labels($payload, $labels, $remove);
if($no_changelog)
check_dismiss_changelog_review($payload);
/*
if(get_pr_code_friendliness($payload) <= 0){
$balances = pr_balances();
$author = $payload['pull_request']['user']['login'];
if(isset($balances[$author]) && $balances[$author] < 0 && !is_maintainer($payload, $author))
create_comment($payload, 'You currently have a negative Fix/Feature pull request delta of ' . $balances[$author] . '. Maintainers may close this PR at will. Fixing issues or improving the codebase will improve this score.');
}
*/
break;
case 'edited':
check_dismiss_changelog_review($payload);
@@ -642,36 +643,38 @@ function get_pr_code_friendliness($payload, $oldbalance = null){
$labels = get_pr_labels_array($payload);
//anything not in this list defaults to 0
$label_values = array(
'Fix' => 2,
'Refactor' => 2,
'CI/Tests' => 3,
'Code Improvement' => 1,
'Fix' => 3,
'Refactor' => 10,
'Code Improvement' => 2,
'Grammar and Formatting' => 1,
'Priority: High' => 4,
'Priority: CRITICAL' => 5,
'Priority: High' => 15,
'Priority: CRITICAL' => 20,
'Unit Tests' => 6,
'Logging' => 1,
'Feedback' => 1,
'Performance' => 3,
'Feature' => -1,
'Balance/Rebalance' => -1,
'PRB: Reset' => $startingPRBalance - $oldbalance,
'Feedback' => 2,
'Performance' => 12,
'Feature' => -10,
'Balance/Rebalance' => -8,
'Tweak' => -2,
'GBP: Reset' => $startingPRBalance - $oldbalance,
);
$affecting = 0;
$is_neutral = FALSE;
$found_something_positive = false;
$maxNegative = 0;
$maxPositive = 0;
foreach($labels as $l){
if($l == 'PRB: No Update') { //no effect on balance
$affecting = 0;
break;
if($l == 'GBP: No Update') { //no effect on balance
return 0;
}
else if(isset($label_values[$l])) {
$friendliness = $label_values[$l];
if($friendliness > 0)
$found_something_positive = true;
$affecting = $found_something_positive ? max($affecting, $friendliness) : $friendliness;
$maxPositive = max($friendliness, $maxPositive);
else
$maxNegative = min($friendliness, $maxNegative);
}
}
$affecting = abs($maxNegative) >= $maxPositive ? $maxNegative : $maxPositive;
return $affecting;
}