mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 16:51:55 +00:00
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:
parent
b052655eae
commit
46d83e8172
@ -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)
|
||||
|
||||
@ -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.
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user