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

package org_tangled

// schema: org.tangled.git.listCommits

import (
	"context"

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

const (
	GitListCommitsNSID = "org.tangled.git.listCommits"
)

// GitListCommits_Output is the output of a org.tangled.git.listCommits call.
type GitListCommits_Output struct {
	Commits []*GitDefs_Commit `json:"commits" cborgen:"commits"`
	// cursor: Cursor for the next page, absent when the last page is reached
	Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
}

// GitListCommits calls the XRPC method "org.tangled.git.listCommits".
//
// cursor: Commit Object ID of the last commit in the previous page
// limit: Maximum number of commits to return in this page
// path: Only list commits touching this path
// ref: Git revision (branch, tag, commit Object ID, or full ref name)
// repo: DID of the repository
func GitListCommits(ctx context.Context, c util.LexClient, cursor string, limit int64, path string, ref string, repo string) (*GitListCommits_Output, error) {
	var out GitListCommits_Output

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

	return &out, nil
}
