MCPcopy
hub / github.com/git-lfs/git-lfs / prePushRefs

Function prePushRefs

commands/command_pre_push.go:74–96  ·  view source on GitHub ↗

prePushRefs parses commit information that the pre-push git hook receives: Each line describes a proposed update of the remote ref at the remote sha to the local sha. Multiple updates can be received on multiple lines (such as from 'git push --a

(r io.Reader)

Source from the content-addressed store, hash-verified

72// the local sha. Multiple updates can be received on multiple lines (such as
73// from 'git push --all'). These updates are typically received over STDIN.
74func prePushRefs(r io.Reader) []*git.RefUpdate {
75 scanner := bufio.NewScanner(r)
76 refs := make([]*git.RefUpdate, 0, 1)
77
78 // We can be passed multiple lines of refs
79 for scanner.Scan() {
80 line := strings.TrimSpace(scanner.Text())
81 if len(line) == 0 {
82 continue
83 }
84
85 tracerx.Printf("pre-push: %s", line)
86
87 localRef, remoteRef := decodeRefs(line)
88 if git.IsZeroObjectID(localRef.Sha) {
89 continue
90 }
91
92 refs = append(refs, git.NewRefUpdate(cfg.Git, cfg.PushRemote(), localRef, remoteRef))
93 }
94
95 return refs
96}
97
98// decodeRefs pulls the sha1s out of the line read from the pre-push
99// hook's stdin.

Callers 1

prePushCommandFunction · 0.85

Calls 5

IsZeroObjectIDFunction · 0.92
NewRefUpdateFunction · 0.92
decodeRefsFunction · 0.85
PushRemoteMethod · 0.80
ScanMethod · 0.65

Tested by

no test coverage detected