|
1 | 1 | // Copyright 2020 The Gitea Authors. All rights reserved. |
2 | 2 | // SPDX-License-Identifier: MIT |
3 | 3 |
|
4 | | -package repository |
| 4 | +package gitrepo |
5 | 5 |
|
6 | 6 | import ( |
| 7 | + "context" |
7 | 8 | "fmt" |
8 | 9 | "os" |
9 | 10 | "path/filepath" |
@@ -105,10 +106,18 @@ done |
105 | 106 | return hookNames, hookTpls, giteaHookTpls |
106 | 107 | } |
107 | 108 |
|
108 | | -// CreateDelegateHooks creates all the hooks scripts for the repo |
109 | | -func CreateDelegateHooks(repoPath string) (err error) { |
| 109 | +// CreateDelegateHooksForRepo creates all the hooks scripts for the repo |
| 110 | +func CreateDelegateHooksForRepo(_ context.Context, repo Repository) (err error) { |
| 111 | + return createDelegateHooks(filepath.Join(repoPath(repo), "hooks")) |
| 112 | +} |
| 113 | + |
| 114 | +// CreateDelegateHooksForWiki creates all the hooks scripts for the wiki repo |
| 115 | +func CreateDelegateHooksForWiki(_ context.Context, repo Repository) (err error) { |
| 116 | + return createDelegateHooks(filepath.Join(wikiPath(repo), "hooks")) |
| 117 | +} |
| 118 | + |
| 119 | +func createDelegateHooks(hookDir string) (err error) { |
110 | 120 | hookNames, hookTpls, giteaHookTpls := getHookTemplates() |
111 | | - hookDir := filepath.Join(repoPath, "hooks") |
112 | 121 |
|
113 | 122 | for i, hookName := range hookNames { |
114 | 123 | oldHookPath := filepath.Join(hookDir, hookName) |
@@ -169,11 +178,19 @@ func ensureExecutable(filename string) error { |
169 | 178 | return os.Chmod(filename, mode) |
170 | 179 | } |
171 | 180 |
|
172 | | -// CheckDelegateHooks checks the hooks scripts for the repo |
173 | | -func CheckDelegateHooks(repoPath string) ([]string, error) { |
| 181 | +// CheckDelegateHooksForRepo checks the hooks scripts for the repo |
| 182 | +func CheckDelegateHooksForRepo(_ context.Context, repo Repository) ([]string, error) { |
| 183 | + return checkDelegateHooks(filepath.Join(repoPath(repo), "hooks")) |
| 184 | +} |
| 185 | + |
| 186 | +// CheckDelegateHooksForWiki checks the hooks scripts for the repo |
| 187 | +func CheckDelegateHooksForWiki(_ context.Context, repo Repository) ([]string, error) { |
| 188 | + return checkDelegateHooks(filepath.Join(wikiPath(repo), "hooks")) |
| 189 | +} |
| 190 | + |
| 191 | +func checkDelegateHooks(hookDir string) ([]string, error) { |
174 | 192 | hookNames, hookTpls, giteaHookTpls := getHookTemplates() |
175 | 193 |
|
176 | | - hookDir := filepath.Join(repoPath, "hooks") |
177 | 194 | results := make([]string, 0, 10) |
178 | 195 |
|
179 | 196 | for i, hookName := range hookNames { |
|
0 commit comments