package models

import (
	"time"

	"github.com/bluesky-social/indigo/atproto/syntax"
)

type Pull2 struct {
	ID int64 // repo-specific PR id

	RepoDid   syntax.DID
	AuthorDid syntax.DID
	Rkey      syntax.RecordKey

	Title        string
	Body         string
	TargetBranch string
	Versions     []PullVersion
	Created      time.Time

	// optionally, populate this when querying for reverse mappings
	Repo *Repo
}

func (p *Pull2) LatestVersionId() int {
	return len(p.Versions) - 1
}

func (p *Pull2) LatestVersion() PullVersion {
	return p.Versions[p.LatestVersionId()]
}

type PullVersion struct {
	SourceRepo syntax.DID
	Head       string // head commit ID
	Base       string // base commit ID
	Created    time.Time
}
