Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I query the GitHub v4 API for directory contents at a certain tag?

How do I query the GitHub API v4 for the contents of a certain directory of a repository at a certain tag?

This is the best I've come up with so far:

query {
  repository(owner:"example", name:"example") {
    refs(refPrefix: "tags") {
    }
  } 
}
like image 874
aknuds1 Avatar asked Sep 14 '25 16:09

aknuds1


1 Answers

From this post, you can get the GitObject with object to filter on branch:/path/folder and print the Tree. The following will get the tree from gson folder from tag gson-2.4 and print name, type and mode :

query {
  repository(owner:"google", name:"gson") {
      object(expression: "gson-2.4:gson") {
      ... on Tree{
        entries{
          name
          type
          mode
        }
      }
    }
  } 
}
like image 96
Bertrand Martel Avatar answered Sep 16 '25 15:09

Bertrand Martel