Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Ground Controller Lvl 1
Message 1 of 1

Find all files in a repo and for each file show the name, text, and contributors

Find all files and for each file show the contributors

 

query RepoFiles($owner: String!, $name: String!) {
  repository(owner: $owner, name: $name) {
    object(expression: "master:") {
      ... on Tree {
        entries {
          name
          type
          object {
            ... on Blob {
              byteSize
              text
              id
              # TODO: Somehow get commit history or contributors for this entry
            }
          }
        }
      }
    }
  }
}

{ "owner": "mudassir-ahmed", "name": "blog" }

I have also tried the following - but nothing shows up for history.

query RepoFiles($owner: String!, $name: String!) {
  repository(owner: $owner, name: $name) {
    object(expression: "master:") {
      ... on Tree {
        entries {
          name
          type
          object {
            ... on Commit {
              history(first: 100) {
                nodes {
                  author {
                    name
                    user {
                      name
                      avatarUrl
                    }
                  }
                }
              }
            }
            ... on Blob {
              byteSize
              text
              id
            }
          }
        }
      }
    }
  }
}

I'm not sure if this is possible or am I forgetting something. The TODO explains my issue. Just to recap I want to:

  • Find all files in a repo and for each file show the name, text, and contributors
  • The contributors should come from the entry (e.g. 2 people edited a file_a.txt, 3 people edited file_b.txt)

 

I have thought about splitting the query. One to obtain the files and the id/name. Then another to get the history for that object (although this way shows commits rather than unique contributors - but I could fix that myself).