@@ -106,15 +106,18 @@ done
106106 return hookNames , hookTpls , giteaHookTpls
107107}
108108
109- // CreateDelegateHooks creates all the hooks scripts for the repo
110- func CreateDelegateHooks (ctx context.Context , repo Repository , isWiki bool ) (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 ) {
111120 hookNames , hookTpls , giteaHookTpls := getHookTemplates ()
112- var hookDir string
113- if isWiki {
114- hookDir = filepath .Join (wikiPath (repo ), "hooks" )
115- } else {
116- hookDir = filepath .Join (repoPath (repo ), "hooks" )
117- }
118121
119122 for i , hookName := range hookNames {
120123 oldHookPath := filepath .Join (hookDir , hookName )
@@ -175,16 +178,19 @@ func ensureExecutable(filename string) error {
175178 return os .Chmod (filename , mode )
176179}
177180
178- // CheckDelegateHooks checks the hooks scripts for the repo
179- func CheckDelegateHooks (ctx context.Context , repo Repository , isWiki bool ) ([]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 ) {
180192 hookNames , hookTpls , giteaHookTpls := getHookTemplates ()
181193
182- var hookDir string
183- if isWiki {
184- hookDir = filepath .Join (wikiPath (repo ), "hooks" )
185- } else {
186- hookDir = filepath .Join (repoPath (repo ), "hooks" )
187- }
188194 results := make ([]string , 0 , 10 )
189195
190196 for i , hookName := range hookNames {
0 commit comments