2

I'd like to get the output of git blame <file> for all files in a repository recursively.

I want to do this without cloning the repository first, by using Github's GraphQL v4 api.

Is this possible?

I've managed to get a list of files via this query:

query {
  repository(owner: "some owner", name: "some repository") {
    object(expression: "HEAD:") {
      ... on Tree {
        entries {
          name
          type
          mode
          
          object {
            ... on Blob {
              byteSize
              text
              isBinary
            }
          }
        }
      }
    }
  }
}

as well as a single file's git blame via this query:

query {
  repositoryOwner(login: "some owner") {
      repository(name: "some repo") {
      object(expression: "some branch") {
        ... on Commit {
          blame(path: "some/file/path.js") {
            ranges {
              startingLine
              endingLine
              age
              commit {
                oid
                author {
                  name
                }
              }
            }
          }
        }
      }
    }
  }
}

Is it possible to combine these queries into one?

If not, it probably makes sense to clone the repo first and run git blame recursively locally, right?

CiriousJoker
  • 552
  • 1
  • 7
  • 18

0 Answers0