MCPcopy
hub / github.com/go-git/go-git / addCommit

Method addCommit

remote.go:727–762  ·  view source on GitHub ↗
(rs config.RefSpec,
	remoteRefs storer.ReferenceStorer, localCommit plumbing.Hash,
	req *packp.ReferenceUpdateRequest)

Source from the content-addressed store, hash-verified

725}
726
727func (r *Remote) addCommit(rs config.RefSpec,
728 remoteRefs storer.ReferenceStorer, localCommit plumbing.Hash,
729 req *packp.ReferenceUpdateRequest) error {
730
731 if rs.IsWildcard() {
732 return errors.New("can't use wildcard together with hash refspecs")
733 }
734
735 cmd := &packp.Command{
736 Name: rs.Dst(""),
737 Old: plumbing.ZeroHash,
738 New: localCommit,
739 }
740 remoteRef, err := remoteRefs.Reference(cmd.Name)
741 if err == nil {
742 if remoteRef.Type() != plumbing.HashReference {
743 // TODO: check actual git behavior here
744 return nil
745 }
746
747 cmd.Old = remoteRef.Hash()
748 } else if err != plumbing.ErrReferenceNotFound {
749 return err
750 }
751 if cmd.Old == cmd.New {
752 return nil
753 }
754 if !rs.IsForceUpdate() {
755 if err := checkFastForwardUpdate(r.s, remoteRefs, cmd); err != nil {
756 return err
757 }
758 }
759
760 req.Commands = append(req.Commands, cmd)
761 return nil
762}
763
764func (r *Remote) addReferenceIfRefSpecMatches(rs config.RefSpec,
765 remoteRefs storer.ReferenceStorer, localRef *plumbing.Reference,

Callers 1

addOrUpdateReferencesMethod · 0.95

Calls 7

checkFastForwardUpdateFunction · 0.85
IsWildcardMethod · 0.80
DstMethod · 0.80
IsForceUpdateMethod · 0.80
ReferenceMethod · 0.65
TypeMethod · 0.65
HashMethod · 0.65

Tested by

no test coverage detected