I have the following query:
{
repository(owner: "org", name: "name") {
name
object(expression: "master:package.json") {
... on Blob {
text
}
}
}
}
but as you can see I have to hardcode master
in the object expression. I'm wondering if there's a way to instead use the default branch in that query. Is that possible without having to do 2 queries (1 to get the default branch, then another to get the file content)?
There was a related question (with bounty too) on that, detailed in this thread... but it is the syntax you are using:
The argument passed to expression on the
object
field is actually a git revision expression suitable forgit rev-parse
, so I guess you can have fun with it to do advanced querying.
So any way to specify a revision should do, including HEAD, which would reference the default remote branch. But not the "current branch" though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With