MCPcopy Create free account
hub / github.com/go-git/go-git / Validate

Method Validate

options.go:422–438  ·  view source on GitHub ↗

Validate validates the fields and sets the default values.

(r *Repository)

Source from the content-addressed store, hash-verified

420
421// Validate validates the fields and sets the default values.
422func (o *ResetOptions) Validate(r *Repository) error {
423 if o.Commit == plumbing.ZeroHash {
424 ref, err := r.Head()
425 if err != nil {
426 return err
427 }
428
429 o.Commit = ref.Hash()
430 } else {
431 _, err := r.CommitObject(o.Commit)
432 if err != nil {
433 return fmt.Errorf("invalid reset option: %w", err)
434 }
435 }
436
437 return nil
438}
439
440type LogOrder int8
441

Callers 1

Calls 3

HeadMethod · 0.80
CommitObjectMethod · 0.80
HashMethod · 0.65

Tested by 1