<commit_before>extern crate hyper;

use hubcaps::{self, Credentials};
use super::{Config, Pull};

/// Content associated with a pull request
#[derive(Debug, Default)]
pub struct Content {
    pub commits: Vec<String>,
    pub comments: Vec<String>,
}

/// interface for fetching pull request information
pub trait Github: Sync + Send {
    /// get a collection of content associated with a given pull
    fn content(&self, pull: Pull) -> Content;
}


pub struct DefaultGithub {
    client: hyper::Client,
    config: Config,
}


impl DefaultGithub {
    pub fn new(client: hyper::Client, config: Config) -> DefaultGithub {
        DefaultGithub {
            client: client,
            config: config,
        }
    }
}

impl Github for DefaultGithub {
    fn content(&self, pull: Pull) -> Content {
        let gh = hubcaps::Github::new(format!("{}/{}",
                                              env!("CARGO_PKG_NAME"),
                                              env!("CARGO_PKG_VERSION")),
                                      &self.client,
                                      Credentials::Token(self.config.github_token.clone()));
        let repo_uri = pull.repo_slug.split("/").collect::<Vec<_>>();
        // fetch all comments
        let comments = gh.repo(repo_uri[0], repo_uri[1])
            .pulls()
            .get(pull.number)
            .comments()
            .list(&Default::default())
            .unwrap_or(vec![]);
        // fetch all commits
        let commits = match gh.repo(repo_uri[0], repo_uri[1])
            .pulls()
            .get(pull.number)
            .commits()
            .iter() {
            Ok(iter) => iter.collect::<Vec<_>>(),
            _ => vec![],
        };
        info!("fetched {} comments and {} commits for pull {} in repo {}",
               comments.len(),<commit_msg>if there is an error, report it<commit_after>extern crate hyper;

use hubcaps::{self, Credentials};
use super::{Config, Pull};

/// Content associated with a pull request
#[derive(Debug, Default)]
pub struct Content {
    pub commits: Vec<String>,
    pub comments: Vec<String>,
}

/// interface for fetching pull request information
pub trait Github: Sync + Send {
    /// get a collection of content associated with a given pull
    fn content(&self, pull: Pull) -> Content;
}


pub struct DefaultGithub {
    client: hyper::Client,
    config: Config,
}


impl DefaultGithub {
    pub fn new(client: hyper::Client, config: Config) -> DefaultGithub {
        DefaultGithub {
            client: client,
            config: config,
        }
    }
}

impl Github for DefaultGithub {
    fn content(&self, pull: Pull) -> Content {
        let gh = hubcaps::Github::new(format!("{}/{}",
                                              env!("CARGO_PKG_NAME"),
                                              env!("CARGO_PKG_VERSION")),
                                      &self.client,
                                      Credentials::Token(self.config.github_token.clone()));
        let repo_uri = pull.repo_slug.split("/").collect::<Vec<_>>();
        // fetch all comments
        let comments = gh.repo(repo_uri[0], repo_uri[1])
            .pulls()
            .get(pull.number)
            .comments()
            .list(&Default::default()).or_else(|e| {
                error!("error fetching comments for pull {}: {}", pull.number, e);
                Err(e)
            }).unwrap_or(Vec::new());
        // fetch all commits
        let commits = match gh.repo(repo_uri[0], repo_uri[1])
            .pulls()
            .get(pull.number)
            .commits()
            .iter() {
            Ok(iter) => iter.collect::<Vec<_>>(),
            _ => Vec::new(),
        };
        info!("fetched {} comments and {} commits for pull {} in repo {}",
               comments.len(),
{'fraction_non_alphanumeric': 0.13755230125523013, 'fraction_numerical': 0.0020920502092050207, 'mean_word_length': 1.763728323699422, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2522340', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1037, 'n_words': 269}