<commit_before><?php

class version extends CI_Model{

    // Requires two parameters for product and the latest version
    // Automatically generates a new version for this product in the DB
    // Returns the ID of the new version that was created.
    function make_new_for_product( $version = array(), $product = array() ) {
        // Set the tag and part of the title
        $new_version_tag = '';        
        $new_version_number = '';
        if ( $version->product_id == 3 ) {
            // B2G alert
            $break_tag = explode('_', $version->tag);
            $break_tag[1]++;
            $new_version_tag = implode('_', $break_tag);
            $new_version_number = implode('.', $break_tag);
        } else {
            // Firefox / Fennec alert
            $source = 'https://wiki.mozilla.org/Template:CENTRAL_VERSION';
            $content = file_get_contents_via_curl( $source );
            if( $content === false ) {
                // Failed to retrieve external version tag
                // Manually calculate for nightly version number
                log_message('error', 'Failed to access: '.$source);
            
                $new_version_tag = $version->tag + 1;
                $new_version_number = $version->tag + 1;
            } else {
                // Extract externally retrieved version tag
                preg_match("/<p>(.*?)<\/p>/s", $content, $match);
                $new_version_tag = trim( $match[1] );    
                $new_version_number = trim( $match[1] );
            }
        }

        // Get the product if it was not specified
        // We need the product title for creating the new version
        if ( empty($product) ) {
            $product = $this->product->retrieve( 
                array(
                    'id' => $version->product_id
                )
            );
            
            $product = $product[0];
        }
<commit_msg>retrieve b2g version from wiki instead of compute<commit_after><?php

class version extends CI_Model{

    // Requires two parameters for product and the latest version
    // Automatically generates a new version for this product in the DB
    // Returns the ID of the new version that was created.
    function make_new_for_product( $version = array(), $product = array() ) {
        // Set the tag and part of the title
        $new_version_tag = '';        
        $new_version_number = '';
        if ( $version->product_id == 3 ) {
            // B2G alert
            $source = "https://wiki.mozilla.org/Template:B2G_DEV_VERSION";
            $content = file_get_contents_via_curl( $source );
            if( $content === false ) {
                // Failed to retrieve external version tag
                // Manually calculate for next B2G version number
                log_message('error', 'Failed to access: '.$source);
                
                $break_tag = explode('_', $version->tag);
                $break_tag[1]++;
                $new_version_tag = implode('_', $break_tag);
                $new_version_number = implode('_', $break_tag);
            } else {
                // Extract externally retrieved version tag
                preg_match("/<p>(.*?)<\/p>/s", $content, $match);
                $new_version_tag =  str_replace('.', '_', trim($match[1]) );    
                $new_version_number = str_replace('.', '_', trim($match[1]) );
            }
        } else {
            // Firefox / Fennec alert
            $source = 'https://wiki.mozilla.org/Template:CENTRAL_VERSION';
            $content = file_get_contents_via_curl( $source );
            if( $content === false ) {
                // Failed to retrieve external version tag
                // Manually calculate for nightly version number
                log_message('error', 'Failed to access: '.$source);
            
                $new_version_tag = $version->tag + 1;
                $new_version_number = $version->tag + 1;
            } else {
                // Extract externally retrieved version tag
                preg_match("/<p>(.*?)<\/p>/s", $content, $match);
                $new_version_tag = trim( $match[1] );    
                $new_version_number = trim( $match[1] );
            }
        }

        // Get the product if it was not specified
        // We need the product title for creating the new version
        if ( empty($product) ) {
            $product = $this->product->retrieve( 
                array(
                    'id' => $version->product_id
                )
            );
            
            $product = $product[0];
        }

{'fraction_non_alphanumeric': 0.1179787464758187, 'fraction_numerical': 0.004554326610279766, 'mean_word_length': 1.5866517106001121, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4913591', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1190, 'n_words': 334}