pub async fn new_from_github(repo: &Repository, branch: &str, file_path: &str, commit_date: DateTime<Utc>) -> Self {
        // Get the file from GitHub.
        let mut content = String::new();
        let mut link = String::new();
        let mut sha = String::new();
        if let Ok(file) = repo.content().file(file_path, branch).await {
            content = from_utf8(&file.content).unwrap().trim().to_string();
            link = file.html_url;
            sha = file.sha;
        }

        // Parse the RFD directory as an int.
        let (dir, _) = file_path.trim_start_matches("rfd/").split_once('/').unwrap();
        let number = dir.trim_start_matches('0').parse::<i32>().unwrap();

        let number_string = NewRFD::generate_number_string(number);

        // Parse the RFD title from the contents.
        let title = NewRFD::get_title(&content);
        let name = NewRFD::generate_name(number, &title);

        // Parse the state from the contents.
        let state = NewRFD::get_state(&content);

        // Parse the discussion from the contents.
        let discussion = NewRFD::get_discussion(&content);

        NewRFD {
            number,
            number_string,
            title,
            name,
            state,
            link,
            short_link: Default::default(),
            rendered_link: Default::default(),
            discussion,
            authors: Default::default(),
            // We parse this below.
            html: Default::default(),
            content,
            sha,
            commit_date,
            // Only exists in Airtable,
            milestones: Default::default(),
            // Only exists in Airtable,
            relevant_components: Default::default(),
            pdf_link_github: Default::default(),
            pdf_link_google_drive: Default::default(),
        }
    }
/// Return a NewRFD from a parsed file on a specific GitHub branch.
Return a NewRFD from a parsed file on a specific GitHub branch.
Return a NewRFD from a parsed file on a specific GitHub branch .
pub async fn new_from_github(repo: &Repository, branch: &str, file_path: &str, commit_date: DateTime<Utc>) -> Self {
        // Get the file from GitHub.
        let mut content = String::new();
        let mut link = String::new();
        let mut sha = String::new();
        if let Ok(file) = repo.content().file(file_path, branch).await {
            content = from_utf8(&file.content).unwrap().trim().to_string();
            link = file.html_url;
            sha = file.sha;
        }
        // Parse the RFD directory as an int.
        let (dir, _) = file_path.trim_start_matches("rfd/").split_once('/').unwrap();
        let number = dir.trim_start_matches('0').parse::<i32>().unwrap();
        let number_string = NewRFD::generate_number_string(number);
        // Parse the RFD title from the contents.
        let title = NewRFD::get_title(&content);
        let name = NewRFD::generate_name(number, &title);
        // Parse the state from the contents.
        let state = NewRFD::get_state(&content);
        // Parse the discussion from the contents.
        let discussion = NewRFD::get_discussion(&content);
        NewRFD {
            number,
            number_string,
            title,
            name,
            state,
            link,
            short_link: Default::default(),
            rendered_link: Default::default(),
            discussion,
            authors: Default::default(),
            // We parse this below.
            html: Default::default(),
            content,
            sha,
            commit_date,
            // Only exists in Airtable,
            milestones: Default::default(),
            // Only exists in Airtable,
            relevant_components: Default::default(),
            pdf_link_github: Default::default(),
            pdf_link_google_drive: Default::default(),
        }
    }
pub async fn new_from_github ( repo : & Repository , branch : & str , file_path : & str , commit_date : DateTime < Utc > ) -> Self { // Get the file from GitHub. let mut content = String :: new ( ) ; let mut link = String :: new ( ) ; let mut sha = String :: new ( ) ; if let Ok ( file ) = repo . content ( ) . file ( file_path , branch ) . await { content = from_utf8 ( & file . content ) . unwrap ( ) . trim ( ) . to_string ( ) ; link = file . html_url ; sha = file . sha ; } // Parse the RFD directory as an int. let ( dir , _ ) = file_path . trim_start_matches ( " " ) . split_once ( '/' ) . unwrap ( ) ; let number = dir . trim_start_matches ( '0' ) . parse :: < i32 > ( ) . unwrap ( ) ; let number_string = NewRFD :: generate_number_string ( number ) ; // Parse the RFD title from the contents. let title = NewRFD :: get_title ( & content ) ; let name = NewRFD :: generate_name ( number , & title ) ; // Parse the state from the contents. let state = NewRFD :: get_state ( & content ) ; // Parse the discussion from the contents. let discussion = NewRFD :: get_discussion ( & content ) ; NewRFD { number , number_string , title , name , state , link , short_link : Default :: default ( ) , rendered_link : Default :: default ( ) , discussion , authors : Default :: default ( ) , // We parse this below. html : Default :: default ( ) , content , sha , commit_date , // Only exists in Airtable, milestones : Default :: default ( ) , // Only exists in Airtable, relevant_components : Default :: default ( ) , pdf_link_github : Default :: default ( ) , pdf_link_google_drive : Default :: default ( ) , } }
Return a NewRFD from a parsed file on a specific GitHub branch.
Return a NewRFD from a parsed file on a specific GitHub branch .
repo
&Repository
branch
&str
file_path
&str
commit_date
DateTime<Utc>
repo
&Repository
branch
&str
file_path
&str
commit_date
DateTime<Utc>