GitHub GraphQL 获取未存档的存储库

问题描述 投票:0回答:2

有没有办法只获取未存档的存储库?

{
  user(login: "SrikanthBandaru") {
    id
    email
    isHireable
    name
    repositories(first: 100) { # fetch only the repos that are not archived
      edges {
        node {
          name
          isArchived
          shortDescriptionHTML
          description
          descriptionHTML
          repositoryTopics(first: 10) {
            edges {
              node {
                topic {
                  name
                }
              }
            }
          }
          homepageUrl
          url
        }
      }
    }
  }
}
graphql github-api github-graphql
2个回答
8
投票

除了用户查询之外,您还可以通过存档搜索参数使用搜索查询。还可以使用

fork:true
来包含叉子:

{
  user: user(login: "simon04") {
    id
    email
    isHireable
    name
  }
  repos: search(query: "user:simon04 fork:true archived:false", type: REPOSITORY, first: 100) {
    repositoryCount
    edges {
      node {
        ... on Repository {
          nameWithOwner
          name
          isArchived
          shortDescriptionHTML
          description
          descriptionHTML
          repositoryTopics(first: 10) {
            edges {
              node {
                topic {
                  name
                }
              }
            }
          }
          homepageUrl
          url
        }
      }
    }
  }
}

在资源管理器中尝试一下


0
投票

您可以运行下面的查询来过滤掉 Github 组织中的存档存储库;我使用 pageInfo 请求来获取用于分页到下一页的结束光标。

query {
  organization(login: "orgname") {
    repositories(isArchived:false, first: 100) {  # adjust this value based on your needs
      edges {
        node {
          name
          vulnerabilityAlerts(first: 100) {  # adjust this value based on your needs
            edges {
              node {
                id
                securityVulnerability {
                  package {
                    name
                    ecosystem
                  }
                  severity
                  updatedAt
                }
                vulnerableRequirements
              }
            }
          }
        }
      }
      pageInfo {
        endCursor
        hasNextPage
      } 
    }
  }
}

© www.soinside.com 2019 - 2024. All rights reserved.