🏡 index : ~doyle/gitlab-cargo-shim.git

author Jordan Doyle <jordan@doyle.la> 2022-03-12 17:32:16.0 +00:00:00
committer Jordan Doyle <jordan@doyle.la> 2022-03-12 17:32:16.0 +00:00:00
commit
6afb3da17e7d990ea057a2fd3a5c2cc73ab9f895 [patch]
tree
54c8dc1478b9533daa1437ecfe17be68fca7b619
parent
6f6a60e29bee2af14768ec4e00b376d790167bcd
download
6afb3da17e7d990ea057a2fd3a5c2cc73ab9f895.tar.gz

Each release shouldn't have more than one crate file



Diff

 src/providers/gitlab.rs | 56 ++++++++++++++++++--------------------------------------
 1 file changed, 18 insertions(+), 38 deletions(-)

diff --git a/src/providers/gitlab.rs b/src/providers/gitlab.rs
index 850e405..062cea8 100644
--- a/src/providers/gitlab.rs
+++ a/src/providers/gitlab.rs
@@ -183,52 +183,32 @@
                        .json()
                        .await?;

                    Ok::<_, anyhow::Error>(Some(
                    let expected_file_name = format!("{}-{}.crate", release.name, release.version);

                    Ok::<_, anyhow::Error>(
                        package_files
                            .into_iter()
                            .filter_map(|package_file| {
                                #[allow(clippy::case_sensitive_file_extension_comparisons)]
                                if package_file.file_name.ends_with(".crate") {
                                    if package_file.file_name
                                        == format!("{}-{}.crate", release.name, release.version)
                                    {
                                        Some((
                                            package_path.clone(),
                                            Release {
                                                name: release.name.clone(),
                                                version: release.version.clone(),
                                                checksum: package_file.file_sha256,
                                            },
                                        ))
                                    } else {
                                        tracing::info!(
                                            "{}/{}/{}/{} should be called {}-{}.crate",
                                            project,
                                            release.name,
                                            release.version,
                                            package_file.file_name,
                                            release.name,
                                            release.version
                                        );
                                        None
                                    }
                                } else {
                                    None
                                }
                            })
                            .collect(),
                    ))
                            .find(|package_file| package_file.file_name == expected_file_name)
                            .map(move |package_file| {
                                (
                                    package_path.clone(),
                                    Release {
                                        name: release.name,
                                        version: release.version,
                                        checksum: package_file.file_sha256,
                                    },
                                )
                            }),
                    )
                }));
            }
        }

        let x: Vec<Vec<_>> = futures
        futures
            .err_into()
            .filter_map(|v| async move { v.and_then(|v| v).transpose() })
            .try_collect()
            .await?;

        Ok(x.into_iter().flatten().collect())
            .await
    }

    async fn fetch_metadata_for_release(
@@ -263,7 +243,7 @@
        Err(anyhow::Error::msg(
            resp.message
                .or(resp.error)
                .map_or_else(|| Cow::Borrowed("unknown error"), Cow::Owned)
                .map_or_else(|| Cow::Borrowed("unknown error"), Cow::Owned),
        ))
    }
}