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)
| 40 | // In the case of deleting a branch, no attempts to push Git LFS objects will be |
| 41 | // made. |
| 42 | func 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 | // |
nothing calls this directly
no test coverage detected