postMergeCommand is run through Git's post-merge hook. This hook checks that files which are lockable and not locked are made read-only, optimising that as best it can based on the available information.
(cmd *cobra.Command, args []string)
| 13 | // This hook checks that files which are lockable and not locked are made read-only, |
| 14 | // optimising that as best it can based on the available information. |
| 15 | func postMergeCommand(cmd *cobra.Command, args []string) { |
| 16 | if len(args) != 1 { |
| 17 | Print(tr.Tr.Get("This should be run through Git's post-merge hook. Run `git lfs update` to install it.")) |
| 18 | os.Exit(1) |
| 19 | } |
| 20 | |
| 21 | // Skip entire hook if lockable read only feature is disabled |
| 22 | if !cfg.SetLockableFilesReadOnly() { |
| 23 | os.Exit(0) |
| 24 | } |
| 25 | |
| 26 | requireGitVersion() |
| 27 | |
| 28 | lockClient := newLockClient() |
| 29 | |
| 30 | // Skip this hook if no lockable patterns have been configured |
| 31 | if len(lockClient.GetLockablePatterns()) == 0 { |
| 32 | os.Exit(0) |
| 33 | } |
| 34 | |
| 35 | // The only argument this hook receives is a flag indicating whether the |
| 36 | // merge was a squash merge; we don't know what files changed. |
| 37 | // Whether it's squash or not is irrelevant, either way it could have |
| 38 | // reset the read-only flag on files that got merged. |
| 39 | |
| 40 | tracerx.Printf("post-merge: checking write flags for all lockable files") |
| 41 | // Sadly we don't get any information about what files were checked out, |
| 42 | // so we have to check the entire repo |
| 43 | err := lockClient.FixAllLockableFileWriteFlags() |
| 44 | if err != nil { |
| 45 | LoggedError(err, tr.Tr.Get("Warning: post-merge locked file check failed: %v", err)) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func init() { |
| 50 | RegisterCommand("post-merge", postMergeCommand, nil) |
nothing calls this directly
no test coverage detected