Allow to get Blame information for a whole file (#60877)

This allows to get blame for the entire file without specifying `1` and `100000` as the range.

## Test plan

Verified manually in my local instance.
This commit is contained in:
Erik Seliger 2024-03-06 23:58:21 +01:00 committed by GitHub
parent b052655eae
commit 46d83e8172
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 7 deletions

View File

@ -10,8 +10,8 @@ import (
)
type GitTreeEntryBlameArgs struct {
StartLine int32
EndLine int32
StartLine *int32
EndLine *int32
IgnoreWhitespace bool
}
@ -19,10 +19,17 @@ func (r *GitTreeEntryResolver) Blame(ctx context.Context, args *GitTreeEntryBlam
opts := &gitserver.BlameOptions{
NewestCommit: api.CommitID(r.commit.OID()),
IgnoreWhitespace: args.IgnoreWhitespace,
Range: &gitserver.BlameRange{
StartLine: int(args.StartLine),
EndLine: int(args.EndLine),
},
}
if (args.StartLine == nil) != (args.EndLine == nil) {
return nil, errors.New("both startLine and endLine must be specified or neither")
}
if args.StartLine != nil && args.EndLine != nil {
opts.Range = &gitserver.BlameRange{
StartLine: int(*args.StartLine),
EndLine: int(*args.EndLine),
}
}
hr, err := r.gitserverClient.StreamBlameFile(ctx, r.commit.repoResolver.RepoName(), r.Path(), opts)

View File

@ -6063,7 +6063,7 @@ type GitBlob implements TreeEntry & File2 {
"""
Blame the blob.
"""
blame(startLine: Int!, endLine: Int!, ignoreWhitespace: Boolean = false): [Hunk!]!
blame(startLine: Int, endLine: Int, ignoreWhitespace: Boolean = false): [Hunk!]!
"""
Highlight the blob contents.
"""