pub async fn sync_github_outside_collaborators(github: &Github, outside_collaborators: BTreeMap<String, GitHubOutsideCollaboratorsConfig>) {
    let github_org = github_org();

    // Add the outside contributors to the specified repos.
    for (name, outside_collaborators_config) in outside_collaborators {
        println!("Running configuration for outside collaborators: {}", name);
        for repo in &outside_collaborators_config.repos {
            // Get the repository collaborators interface from hubcaps.
            let repo_collaborators = github.repo(github_org.to_string(), repo.to_string()).collaborators();

            let mut perm = Permissions::Pull;
            if outside_collaborators_config.perm == "push" {
                perm = Permissions::Push;
            }

            // Iterate over the users.
            for user in &outside_collaborators_config.users {
                if !repo_collaborators.is_collaborator(&user).await.unwrap_or(false) {
                    // Add the collaborator.
                    match repo_collaborators.add(&user, &perm).await {
                        Ok(_) => {
                            println!("[{}] added user {} as a collaborator ({}) on repo {}", name, user, perm, repo);
                        }
                        Err(e) => println!("[{}] adding user {} as a collaborator ({}) on repo {} FAILED: {}", name, user, perm, repo, e),
                    }
                } else {
                    println!("[{}] user {} is already a collaborator ({}) on repo {}", name, user, perm, repo);
                }
            }
        }

        println!("Successfully ran configuration for outside collaborators: {}", name);
    }
}
/// Sync GitHub outside collaborators with our configs.
Sync GitHub outside collaborators with our configs.
Sync GitHub outside collaborators with our configs .
pub async fn sync_github_outside_collaborators(github: &Github, outside_collaborators: BTreeMap<String, GitHubOutsideCollaboratorsConfig>) {
    let github_org = github_org();
    // Add the outside contributors to the specified repos.
    for (name, outside_collaborators_config) in outside_collaborators {
        println!("Running configuration for outside collaborators: {}", name);
        for repo in &outside_collaborators_config.repos {
            // Get the repository collaborators interface from hubcaps.
            let repo_collaborators = github.repo(github_org.to_string(), repo.to_string()).collaborators();
            let mut perm = Permissions::Pull;
            if outside_collaborators_config.perm == "push" {
                perm = Permissions::Push;
            }
            // Iterate over the users.
            for user in &outside_collaborators_config.users {
                if !repo_collaborators.is_collaborator(&user).await.unwrap_or(false) {
                    // Add the collaborator.
                    match repo_collaborators.add(&user, &perm).await {
                        Ok(_) => {
                            println!("[{}] added user {} as a collaborator ({}) on repo {}", name, user, perm, repo);
                        }
                        Err(e) => println!("[{}] adding user {} as a collaborator ({}) on repo {} FAILED: {}", name, user, perm, repo, e),
                    }
                } else {
                    println!("[{}] user {} is already a collaborator ({}) on repo {}", name, user, perm, repo);
                }
            }
        }
        println!("Successfully ran configuration for outside collaborators: {}", name);
    }
}
pub async fn sync_github_outside_collaborators ( github : & Github , outside_collaborators : BTreeMap < String , GitHubOutsideCollaboratorsConfig > ) { let github_org = github_org ( ) ; // Add the outside contributors to the specified repos. for ( name , outside_collaborators_config ) in outside_collaborators { println ! ( " " name ) ; for repo in & outside_collaborators_config . repos { // Get the repository collaborators interface from hubcaps. let repo_collaborators = github . repo ( github_org . to_string ( ) , repo . to_string ( ) ) . collaborators ( ) ; let mut perm = Permissions :: Pull ; if outside_collaborators_config . perm == " " { perm = Permissions :: Push ; } // Iterate over the users. for user in & outside_collaborators_config . users { if ! repo_collaborators . is_collaborator ( & user ) . await . unwrap_or ( false ) { // Add the collaborator. match repo_collaborators . add ( & user , & perm ) . await { Ok ( _ ) => { println ! ( " " name user perm repo ) ; } Err ( e ) => println ! ( " " name user perm repo e ) , } } else { println ! ( " " name user perm repo ) ; } } } println ! ( " " name ) ; } }
Sync GitHub outside collaborators with our configs.
Sync GitHub outside collaborators with our configs .
github
&Github
outside_collaborators
BTreeMap<String, GitHubOutsideCollaboratorsConfig>
github
&Github
outside_collaborators
BTreeMap<String, GitHubOutsideCollaboratorsConfig>