mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-27 03:09:14 -06:00
Detect repeated calls to simpleCommitMetaGenerator.Next
This shouldn't be possible, the check is a precaution to prevent infinite loops.
This commit is contained in:
@@ -173,12 +173,17 @@ type CommitMetaGenerator interface {
|
||||
|
||||
// The default implementation of CommitMetaGenerator, which generates a single commit which is always acceptable.
|
||||
type simpleCommitMetaGenerator struct {
|
||||
name, email string
|
||||
timestamp time.Time
|
||||
message string
|
||||
name, email string
|
||||
timestamp time.Time
|
||||
message string
|
||||
alreadyGenerated bool
|
||||
}
|
||||
|
||||
func (g simpleCommitMetaGenerator) Next() (*CommitMeta, error) {
|
||||
if g.alreadyGenerated {
|
||||
return nil, fmt.Errorf("Called simpleCommitMetaGenerator.Next twice. This should never happen.")
|
||||
}
|
||||
g.alreadyGenerated = true
|
||||
return NewCommitMetaWithUserTS(g.name, g.email, g.message, g.timestamp)
|
||||
}
|
||||
|
||||
@@ -187,5 +192,5 @@ func (simpleCommitMetaGenerator) IsGoodCommit(*Commit) bool {
|
||||
}
|
||||
|
||||
func MakeCommitMetaGenerator(name, email string, timestamp time.Time) CommitMetaGenerator {
|
||||
return simpleCommitMetaGenerator{name: name, email: email, timestamp: timestamp, message: defaultInitialCommitMessage}
|
||||
return simpleCommitMetaGenerator{name: name, email: email, timestamp: timestamp, message: defaultInitialCommitMessage, alreadyGenerated: false}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user