// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.

package tangled

// schema: sh.tangled.git.temp2.getBlame

import (
	"context"

	"github.com/bluesky-social/indigo/lex/util"
)

const (
	GitTemp2GetBlameNSID = "sh.tangled.git.temp2.getBlame"
)

// GitTemp2GetBlame_Commit is a "commit" in the sh.tangled.git.temp2.getBlame schema.
type GitTemp2GetBlame_Commit struct {
	Author *GitDefs_Signature `json:"author" cborgen:"author"`
	// message: Full commit message
	Message string `json:"message" cborgen:"message"`
	Oid     string `json:"oid" cborgen:"oid"`
}

// GitTemp2GetBlame_Output is the output of a sh.tangled.git.temp2.getBlame call.
type GitTemp2GetBlame_Output struct {
	// commit: The resolved git commit object id
	Commit string `json:"commit" cborgen:"commit"`
	// commits: Unique commits referenced by blame runs
	Commits []*GitTemp2GetBlame_Commit `json:"commits" cborgen:"commits"`
	// runs: Complete, gap-free one-based line ranges sorted by start
	Runs []*GitTemp2GetBlame_Run `json:"runs" cborgen:"runs"`
}

// GitTemp2GetBlame_Run is a "run" in the sh.tangled.git.temp2.getBlame schema.
type GitTemp2GetBlame_Run struct {
	// commit: oid of a commit in the output commits array
	Commit string `json:"commit" cborgen:"commit"`
	// count: Number of consecutive lines in this run
	Count int64 `json:"count" cborgen:"count"`
	// start: First one-based line in this run
	Start int64 `json:"start" cborgen:"start"`
}

// GitTemp2GetBlame calls the XRPC method "sh.tangled.git.temp2.getBlame".
//
// path: Path to the file within the repository
// ref: Revspec to blame at: a branch, tag, or commit sha
// repo: DID of the repository
func GitTemp2GetBlame(ctx context.Context, c util.LexClient, path string, ref string, repo string) (*GitTemp2GetBlame_Output, error) {
	var out GitTemp2GetBlame_Output

	params := map[string]interface{}{}
	params["path"] = path
	params["ref"] = ref
	params["repo"] = repo
	if err := c.LexDo(ctx, util.Query, "", "sh.tangled.git.temp2.getBlame", params, nil, &out); err != nil {
		return nil, err
	}

	return &out, nil
}
