MCPcopy
hub / github.com/github/github-mcp-server / decodeBlameCursor

Function decodeBlameCursor

pkg/github/repositories.go:2278–2299  ·  view source on GitHub ↗
(cursor string)

Source from the content-addressed store, hash-verified

2276}
2277
2278func decodeBlameCursor(cursor string) (int, error) {
2279 if cursor == "" {
2280 return 0, nil
2281 }
2282
2283 decoded, err := base64.RawURLEncoding.DecodeString(cursor)
2284 if err != nil {
2285 return 0, fmt.Errorf("after cursor is invalid")
2286 }
2287
2288 value := string(decoded)
2289 if !strings.HasPrefix(value, blameCursorPrefix) {
2290 return 0, fmt.Errorf("after cursor is invalid")
2291 }
2292
2293 offset, err := strconv.Atoi(strings.TrimPrefix(value, blameCursorPrefix))
2294 if err != nil || offset < 0 {
2295 return 0, fmt.Errorf("after cursor is invalid")
2296 }
2297
2298 return offset, nil
2299}
2300
2301// BlameAuthor describes the author of a commit referenced by a BlameRange.
2302type BlameAuthor struct {

Callers 1

GetFileBlameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected