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

Function prePushCommand

commands/command_pre_push.go:42–65  ·  view source on GitHub ↗

prePushCommand is run through Git's pre-push hook. The pre-push hook passes two arguments on the command line: 1. Name of the remote to which the push is being done 2. URL to which the push is being done The hook receives commit information on stdin in the form: <remote

(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

40// In the case of deleting a branch, no attempts to push Git LFS objects will be
41// made.
42func prePushCommand(cmd *cobra.Command, args []string) {
43 if len(args) == 0 {
44 Print(tr.Tr.Get("This should be run through Git's pre-push hook. Run `git lfs update` to install it."))
45 os.Exit(1)
46 }
47
48 if cfg.Os.Bool("GIT_LFS_SKIP_PUSH", false) {
49 return
50 }
51
52 requireGitVersion()
53
54 // Remote is first arg
55 remote, _ := git.MapRemoteURL(args[0], true)
56 if err := cfg.SetValidPushRemote(remote); err != nil {
57 Exit(tr.Tr.Get("Invalid remote name %q: %s", args[0], err))
58 }
59
60 ctx := newUploadContext(prePushDryRun)
61 updates := prePushRefs(os.Stdin)
62 if err := uploadForRefUpdates(ctx, updates, false); err != nil {
63 ExitWithError(err)
64 }
65}
66
67// prePushRefs parses commit information that the pre-push git hook receives:
68//

Callers

nothing calls this directly

Calls 11

MapRemoteURLFunction · 0.92
PrintFunction · 0.85
requireGitVersionFunction · 0.85
ExitFunction · 0.85
newUploadContextFunction · 0.85
prePushRefsFunction · 0.85
uploadForRefUpdatesFunction · 0.85
ExitWithErrorFunction · 0.85
SetValidPushRemoteMethod · 0.80
GetMethod · 0.65
BoolMethod · 0.65

Tested by

no test coverage detected