aboutsummaryrefslogtreecommitdiff
path: root/models
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2015-02-08 21:26:14 -0500
committerUnknwon <joe2010xtmf@163.com>2015-02-08 21:26:14 -0500
commitf15fa9167ade8262bed437451585d319f12d1182 (patch)
tree1f6e32e4377d0c09fd3a57a66caf5098e0c16c97 /models
parentcd0ee35b3f887cc4ab6ba16cc2d955bfae607678 (diff)
cmd: code fix for #905
- routers/admin: add rewrite update hook operation - conf/locale: update locale file due to ini behavior changes - cmd/cert_stub.go: remove useless code - cmd/fix.go: no longer need fix command(at least now)
Diffstat (limited to 'models')
-rw-r--r--models/action.go2
-rw-r--r--models/publickey.go2
-rw-r--r--models/repo.go29
3 files changed, 19 insertions, 14 deletions
diff --git a/models/action.go b/models/action.go
index a6c6cfbf..5cba2f51 100644
--- a/models/action.go
+++ b/models/action.go
@@ -98,7 +98,7 @@ func (a Action) GetRepoName() string {
}
func (a Action) GetRepoLink() string {
- return path.Join(a.RepoUserName, a.RepoName)
+ return path.Join(setting.AppSubUrl, a.RepoUserName, a.RepoName)
}
func (a Action) GetBranch() string {
diff --git a/models/publickey.go b/models/publickey.go
index 893ff5c9..b1c7b624 100644
--- a/models/publickey.go
+++ b/models/publickey.go
@@ -29,7 +29,7 @@ import (
const (
// "### autogenerated by gitgos, DO NOT EDIT\n"
- _TPL_PUBLICK_KEY = `command="%s serv --config=%s key-%d",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n"
+ _TPL_PUBLICK_KEY = `command="%s serv --config='%s' key-%d",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n"
)
var (
diff --git a/models/repo.go b/models/repo.go
index 5a40c5b9..f2f10baf 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -30,7 +30,7 @@ import (
)
const (
- TPL_UPDATE_HOOK = "#!/usr/bin/env %s\n%s update --config=%s $1 $2 $3\n"
+ _TPL_UPDATE_HOOK = "#!/usr/bin/env %s\n%s update --config='%s' $1 $2 $3\n"
)
var (
@@ -402,15 +402,9 @@ 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()
-
- _, err = pu.WriteString(content)
- return err
+func createHookUpdate(repoPath string) error {
+ return ioutil.WriteFile(path.Join(repoPath, "hooks/update"),
+ []byte(fmt.Sprintf(_TPL_UPDATE_HOOK, setting.ScriptType, "\""+appPath+"\"", setting.CustomConf)), 0777)
}
// InitRepository initializes README and .gitignore if needed.
@@ -423,8 +417,7 @@ func initRepository(f string, u *User, repo *Repository, initReadme bool, repoLa
}
// hook/post-update
- if err := createHookUpdate(filepath.Join(repoPath, "hooks", "update"),
- fmt.Sprintf(TPL_UPDATE_HOOK, setting.ScriptType, "\""+appPath+"\"", setting.CustomConf)); err != nil {
+ if err := createHookUpdate(repoPath); err != nil {
return err
}
@@ -1174,6 +1167,18 @@ func DeleteRepositoryArchives() error {
})
}
+// RewriteRepositoryUpdateHook rewrites all repositories' update hook.
+func RewriteRepositoryUpdateHook() error {
+ return x.Where("id > 0").Iterate(new(Repository),
+ func(idx int, bean interface{}) error {
+ repo := bean.(*Repository)
+ if err := repo.GetOwner(); err != nil {
+ return err
+ }
+ return createHookUpdate(RepoPath(repo.Owner.Name, repo.Name))
+ })
+}
+
var (
// Prevent duplicate tasks.
isMirrorUpdating = false