Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/update_graphql.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

graphql-client introspect-schema https://gitlab.com/api/graphql > src/providers/graphql/gitlab/schema.json
wget https://docs.github.com/public/schema.docs.graphql -O src/providers/graphql/github/schema.graphql
wget https://docs.github.com/public/fpt/schema.docs.graphql -O src/providers/graphql/github/schema.graphql
64 changes: 52 additions & 12 deletions src/providers/gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ impl From<repositories::RepositoriesNamespaceProjectsEdgesNode> for ProjectNode
}
}

impl From<repositories::RepositoriesGroupSharedProjectsEdgesNode> for ProjectNode {
fn from(item: repositories::RepositoriesGroupSharedProjectsEdgesNode) -> Self {
Self {
archived: item.archived.unwrap(),
root_ref: item.repository.and_then(|r| r.root_ref),
ssh_url: item.ssh_url_to_repo.expect("Unknown SSH URL"),
http_url: item.http_url_to_repo.expect("Unknown HTTP URL"),
full_path: item.full_path,
}
}
}

static DEFAULT_GITLAB_URL: &str = "https://gitlab.com";

fn public_gitlab_url() -> String {
Expand Down Expand Up @@ -184,18 +196,46 @@ impl Provider for GitlabProvider {
let temp_repositories: Vec<ProjectNode>;
// This is annoying but I'm still not sure how to unify it.
if let Some(group) = data.group {
let group_data = group.projects;
temp_repositories = group_data
.edges
.expect("missing edges")
.into_iter()
// Some(T) -> T
.flatten()
// Extract the node, which is also Some(T)
.filter_map(|x| x.node)
.map(ProjectNode::from)
.collect();
after = group_data.page_info.end_cursor;
let group_project_data = group.projects;
let shared_project_data = group.shared_projects;

let mut repos: Vec<ProjectNode> = Vec::new();

// Projects
if let Some(edges) = group_project_data.edges {
repos.extend(
edges
.into_iter()
// Some(T) -> T
.flatten()
// Extract the node, which is also Some(T)
.filter_map(|x| x.node)
.map(ProjectNode::from)
);
}
after = group_project_data.page_info.end_cursor;

// Shared projects
if let Some(shared) = shared_project_data {
if let Some(edges) = shared.edges {
repos.extend(
edges
.into_iter()
// Some(T) -> T
.flatten()
// Extract the node, which is also Some(T)
.filter_map(|x| x.node)
.map(ProjectNode::from)
);
}

if after.is_none() {
after = shared.page_info.end_cursor;
}
}

temp_repositories = repos;

} else if let Some(namespace) = data.namespace {
let namespace_data = namespace.projects;
temp_repositories = namespace_data
Expand Down
16 changes: 0 additions & 16 deletions src/providers/graphql/github/.graphqlconfig

This file was deleted.

9 changes: 9 additions & 0 deletions src/providers/graphql/github/graphql.config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
schema: schema.graphql
extensions:
endpoints:
Github:
url: https://api.github.com/graphql
headers:
user-agent: JS GraphQL
Authorization: Bearer ${GITHUB_TOKEN}
introspect: true
Loading