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

Function postMergeCommand

commands/command_post_merge.go:15–47  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
15func 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
49func init() {
50 RegisterCommand("post-merge", postMergeCommand, nil)

Callers

nothing calls this directly

Calls 8

PrintFunction · 0.85
requireGitVersionFunction · 0.85
newLockClientFunction · 0.85
LoggedErrorFunction · 0.85
GetLockablePatternsMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected