aboutsummaryrefslogtreecommitdiff
path: root/models/migrations/v15.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-02-15 05:45:15 -0500
committerUnknwon <u@gogs.io>2017-02-15 05:45:15 -0500
commita4f9e5031ff28780ae68a80e76fcc4a8f0cdbeb0 (patch)
tree5d1bb5df7b8260f3bcbb4bb93907425325837224 /models/migrations/v15.go
parent4da325a45c453c8f895b0a215f548ce4d73d8462 (diff)
migration.v15: don't generate hook file if wiki not exist (#1623)
Diffstat (limited to 'models/migrations/v15.go')
-rw-r--r--models/migrations/v15.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/models/migrations/v15.go b/models/migrations/v15.go
index 0343241f..5d907582 100644
--- a/models/migrations/v15.go
+++ b/models/migrations/v15.go
@@ -64,11 +64,12 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
repoBase := filepath.Join(setting.RepoRootPath, strings.ToLower(user.Name), strings.ToLower(repo.Name))
repoPath := repoBase + ".git"
+ wikiPath := repoBase + ".wiki.git"
log.Trace("[%04d]: %s", idx, repoPath)
hookDir := filepath.Join(repoPath, "hooks")
customHookDir := filepath.Join(repoPath, "custom_hooks")
- wikiHookDir := filepath.Join(repoBase+".wiki.git", "hooks")
+ wikiHookDir := filepath.Join(wikiPath, "hooks")
for i, hookName := range hookNames {
oldHookPath := filepath.Join(hookDir, hookName)
@@ -88,10 +89,12 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
return fmt.Errorf("write hook file '%s': %v", oldHookPath, err)
}
- os.MkdirAll(wikiHookDir, os.ModePerm)
- wikiHookPath := filepath.Join(wikiHookDir, hookName)
- if err = ioutil.WriteFile(wikiHookPath, []byte(hookTpls[i]), os.ModePerm); err != nil {
- return fmt.Errorf("write wiki hook file '%s': %v", wikiHookPath, err)
+ if com.IsDir(wikiPath) {
+ os.MkdirAll(wikiHookDir, os.ModePerm)
+ wikiHookPath := filepath.Join(wikiHookDir, hookName)
+ if err = ioutil.WriteFile(wikiHookPath, []byte(hookTpls[i]), os.ModePerm); err != nil {
+ return fmt.Errorf("write wiki hook file '%s': %v", wikiHookPath, err)
+ }
}
}
return nil