Ejemplo n.º 1
0
function search(array $params)
{
    $client = new jsonRPCClient("https://bugzilla.wikimedia.org/jsonrpc.cgi");
    try {
        $result = $client->call('Bug.search', array($params));
    } catch (\Exception $e) {
        Fail::log($e);
        return false;
    }
    $bugs = array();
    for ($i = 0, $c = count($result[1]['bugs']); $i < $c; ++$i) {
        $bugs[] = (object) $result[1]['bugs'][$i];
    }
    return $bugs;
}
$changes = search_gerrit_for_changes();
$bugs = search(array("component" => "WikidataClient", "product" => "MediaWiki extensions", "status" => "RESOLVED", "resolution" => "FIXED"));
$bugs_repo = search(array("component" => "WikidataRepo", "product" => "MediaWiki extensions", "status" => "RESOLVED", "resolution" => "FIXED"));
//echo "Out of ".sizeof($bugs)." Bugzilla bugs with status RESOLVED FIXED,".PHP_EOL;
$bugs = array_merge($bugs, $bugs_repo);
$file = get_content("http://meta.wikimedia.org/wiki/Wikidata/Development/Current_sprint");
$current_sprint_bugs = array();
$resolved_bug_ids = array();
$current_sprint_descriptions = array();
preg_match_all("/<a[^>]*href=\"https:\\/\\/bugzilla\\.wikimedia\\.org\\/show_bug\\.cgi\\?id=([^\"]*)[^>]*>[^<]*<\\/a>([^<]*)<\\/li>/s", $file, $bugzilla_id_matches);
foreach ($bugzilla_id_matches[1] as $id => $bugzilla_id) {
    if (is_numeric($bugzilla_id)) {
        $current_sprint_bugs[] = $bugzilla_id;
        $current_sprint_descriptions[$bugzilla_id] = $bugzilla_id_matches[2][$id];
    }
}
            }
            if (sizeof($comments_mentioning_commit) == 0) {
                $added_text = "Adding https://gerrit.wikimedia.org/r/#/c/" . $change_id . "/ to https://bugzilla.wikimedia.org/show_bug.cgi?id=" . $bug_id . "." . PHP_EOL;
                echo $added_text;
                file_put_contents($log_file, $added_text, FILE_APPEND | LOCK_EX);
                var_dump($change);
                // .".\nChange merged."
                $result = $client->call('Bug.add_comment', array(array("id" => $bug_id, "comment" => "Change " . $short_change_hash . ": " . $change->subject)), $login);
            }
        }
    }
    if (preg_match("/\\(no bug\\)/i", $change->subject, $matches) || preg_match("/\\(minor\\)/i", $change->subject, $matches)) {
    } else {
    }
}
$changes = search_gerrit_for_changes(true);
foreach ($changes as $change_id => $change) {
    $change_hash = $change->key;
    $change_hash = $change_hash["id"];
    $short_change_hash = substr($change_hash, 0, 9);
    //echo $change->subject.PHP_EOL;
    if (preg_match("/^\\(bug ([0-9]*)\\) (.*)/i", trim($change->subject), $matches)) {
        $bug_id = (int) $matches[1];
        if (isset($bugs[$bug_id])) {
            $bug = $bugs[$bug_id];
            $comments = comments($bug_id);
            $comments_mentioning_commit = array();
            foreach ($comments as $comment) {
                $gerrit_url = "https:\\/\\/gerrit\\.wikimedia\\.org\\/r\\/#\\/c\\/";
                if (preg_match("/" . $gerrit_url . $change_id . "\\//i", $comment["text"])) {
                    $comments_mentioning_commit[] = $comment["text"];