(repo *repo.Repo, shimPath, quickhook, hook string, prompt bool)
| 111 | } |
| 112 | |
| 113 | func installShim(repo *repo.Repo, shimPath, quickhook, hook string, prompt bool) error { |
| 114 | command, err := shimCommandForHook(quickhook, hook) |
| 115 | if err != nil { |
| 116 | return err |
| 117 | } |
| 118 | |
| 119 | lines := []string{ |
| 120 | "#!/bin/sh", |
| 121 | command, |
| 122 | "", // So we get a trailing newline when we join |
| 123 | } |
| 124 | |
| 125 | file, err := os.Create(shimPath) |
| 126 | if err != nil { |
| 127 | return err |
| 128 | } |
| 129 | defer file.Close() |
| 130 | |
| 131 | err = os.Chmod(shimPath, 0755) |
| 132 | if err != nil { |
| 133 | return err |
| 134 | } |
| 135 | |
| 136 | file.WriteString(strings.Join(lines, "\n")) |
| 137 | |
| 138 | return nil |
| 139 | } |
| 140 | |
| 141 | func shimCommandForHook(quickhook, hook string) (string, error) { |
| 142 | var args string |
no test coverage detected