Documentation ¶
Overview ¶
Package commit contains methods for constructing/saving/retrieving commits.
Index ¶
- Variables
- func Exists(ctx context.Context, k Key) (bool, error)
- func MustReadAllForTesting(ctx context.Context) map[Key]Commit
- func MustSetForTesting(ctx context.Context, cs ...Commit)
- func ShouldMatchCommits(commits []Commit) comparison.Func[map[Key]Commit]
- func ShouldMatchCommitsIn(commits ...Commit) comparison.Func[Commit]
- func ShouldMatchGitCommit(commit GitCommit) comparison.Func[GitCommit]
- func ShouldMatchKey(key Key) comparison.Func[Key]
- type Commit
- type GitCommit
- type Key
- type Position
- type ReadByPositionOpts
Constants ¶
This section is empty.
Variables ¶
var CommitSaveCols = []string{
"Host", "Repository", "CommitHash", "PositionRef", "PositionNumber", "LastUpdatedTime",
}
CommitSaveCols is the set of columns written to in a commit save. Allocated here once to avoid reallocating on every commit save.
var ( // key, but its value doesn't match expected format. ErrInvalidPositionFooter = errors.New("invalid position footer format") )
Functions ¶
func MustReadAllForTesting ¶
MustReadAllForTesting reads all commits for testing, e.g. to assert all expected commits were inserted.
Must be called in a spanner transactional context. Do not use in production, will not scale.
func MustSetForTesting ¶
MustSetForTesting replaces the set of stored commits to match the given set.
func ShouldMatchCommits ¶
func ShouldMatchCommits(commits []Commit) comparison.Func[map[Key]Commit]
ShouldMatchCommits returns a comparison.Func which checks if the expected commits matches the actual commits. The order of the commits does not matter.
func ShouldMatchCommitsIn ¶
func ShouldMatchCommitsIn(commits ...Commit) comparison.Func[Commit]
ShouldMatchCommitsIn returns a comparison.Func which checks if the actual actual commit matches any of the expected commits.
func ShouldMatchGitCommit ¶
func ShouldMatchGitCommit(commit GitCommit) comparison.Func[GitCommit]
ShouldMatchGitCommit returns a comparison.Func which checks if the expected GitCommit matches the actual GitCommit.
func ShouldMatchKey ¶
func ShouldMatchKey(key Key) comparison.Func[Key]
ShouldMatchKey returns a comparison.Func which checks if the expected commit key matches the actual commit key.
Types ¶
type Commit ¶
type Commit struct {
// contains filtered or unexported fields
}
Commit represents a row in the Commits table.
func NewFromGitCommit ¶
NewFromGitCommit creates a new Commit from a GitCommit.
N.B. if the GitCommit does not have a valid git commit position, the returned Commit will not have a commit position either.
func ReadByPosition ¶
func ReadByPosition(ctx context.Context, opts ReadByPositionOpts) (commits Commit, err error)
ReadByPosition retrieves a commit from the database given the commit position.
When there are multiple matches, only the first match (arbitrary order) is returned. If no commit is found, returns spanutil.ErrNotExists.
type GitCommit ¶
type GitCommit struct {
// contains filtered or unexported fields
}
func NewGitCommit ¶
NewGitCommit creates a new GitCommit.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key denotes the primary key for the Commits table.
type Position ¶
type Position struct { // Ref is the ref where the commit position is based on. Ref string // Number is the commit position number. Number int64 }
Position represents the position of a commit along a ref.
type ReadByPositionOpts ¶
type ReadByPositionOpts struct { // Required. Host is the gitiles host of the repository. Host string // Required. Repository is the Gitiles project of the commit. Repository string // Required. Position is the position of the commit along a ref. Position Position }
ReadByPositionOpts is the option to read by