summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-26 09:40:02 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-26 09:40:02 -0400
commit32e05ae2120e864d6e1bd85fb01ef87e23c3ae89 (patch)
tree9e8aa75d5508d8018799403c08d317bb09b52dc0 /models
parentbffa6979b015bd6f5980c700537bb7b5b363985c (diff)
downloadgitea-32e05ae2120e864d6e1bd85fb01ef87e23c3ae89.tar.gz
gitea-32e05ae2120e864d6e1bd85fb01ef87e23c3ae89.zip
Fix issue: update hook text busy
Diffstat (limited to 'models')
-rw-r--r--models/repo.go23
1 files changed, 15 insertions, 8 deletions
diff --git a/models/repo.go b/models/repo.go
index c80d2f2c2c..0ef049cc6e 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -235,6 +235,18 @@ func initRepoCommit(tmpPath string, sig *git.Signature) (err error) {
return nil
}
+func createHookUpdate(hookPath, content string) error {
+ pu, err := os.OpenFile(hookPath, os.O_CREATE|os.O_WRONLY, 0777)
+ if err != nil {
+ return err
+ }
+ defer pu.Close()
+ if _, err = pu.WriteString(content); err != nil {
+ return err
+ }
+ return nil
+}
+
// InitRepository initializes README and .gitignore if needed.
func initRepository(f string, user *User, repo *Repository, initReadme bool, repoLang, license string) error {
repoPath := RepoPath(user.Name, repo.Name)
@@ -245,14 +257,9 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
}
// hook/post-update
- pu, err := os.OpenFile(filepath.Join(repoPath, "hooks", "update"), os.O_CREATE|os.O_WRONLY, 0777)
- if err != nil {
- return err
- }
- defer pu.Close()
- // TODO: Windows .bat
- if _, err = pu.WriteString(fmt.Sprintf("#!/usr/bin/env bash\n%s update $1 $2 $3\n",
- strings.Replace(appPath, "\\", "/", -1))); err != nil {
+ if err := createHookUpdate(filepath.Join(repoPath, "hooks", "update"),
+ fmt.Sprintf("#!/usr/bin/env bash\n%s update $1 $2 $3\n",
+ strings.Replace(appPath, "\\", "/", -1))); err != nil {
return err
}