Getting the line content for git blame

How can I get the line content when runing “git blame”? Like if I use git blame on CLI I get the results in the format:

Id Author Timestamp Line Number Line Content
89feb84d Albert So 2018-03-01 00:54:03 +0000 3 This repository is an example of a project with multiple contributors making commits.

I’d like to know what to add to the bellow “blame” query?

query blame {
repository(name: “my_git-hammer”, owner: “dimiterbak”) {
ref(qualifiedName: “master”) {
target {
… on Commit {
blame(path: “azbg_digital_health_id-config.json”) {
ranges {
commit {
oid
author {
name
}
commitResourcePath
}
startingLine
endingLine
age
}
}
}
}
}
}
}

When I run it I get the bellow response:

{
“data”: {
“repository”: {
“ref”: {
“target”: {
“blame”: {
“ranges”: [
{
“commit”: {
“oid”: “41f32d92ad849ac7e177c4001ea61055f1238d4c”,
“author”: {
“name”: “Dimitar”
},
“commitResourcePath”: “/dimiterbak/my_git-hammer/commit/41f32d92ad849ac7e177c4001ea61055f1238d4c”
},
“startingLine”: 1,
“endingLine”: 26,
“age”: 2
}
]
}
}
}
}
}
}

Hi @dimiterbak, thank you for being here! As far as I know the only fields available are the ones you’ve already used on your query: startingLine, endingLine, author and age.

2 Likes

Hello @dimiterbak! In addition to what @andreagriffiths11 mentioned :sparkles: , I’d like to clarify that there isn’t a specific field (or field within an existing field) that would give you the line content beyond what’s available in a blame’s blame range object:

Also, there’s not a specific REST API endpoint that exposes the same information. I hope this helps!

2 Likes