|
@ -39,7 +39,6 @@ import ( |
|
|
|
|
|
|
|
|
const ( |
|
|
const ( |
|
|
_TPL_UPDATE_HOOK = "#!/usr/bin/env %s\n%s update $1 $2 $3 --config='%s'\n" |
|
|
_TPL_UPDATE_HOOK = "#!/usr/bin/env %s\n%s update $1 $2 $3 --config='%s'\n" |
|
|
_TPL_POST_RECEIVE_HOOK = "#!/usr/bin/env %s\n%s pull --path \"$(pwd)\"\n" |
|
|
|
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
var ( |
|
|
var ( |
|
@ -597,11 +596,6 @@ func createUpdateHook(repoPath string) error { |
|
|
fmt.Sprintf(_TPL_UPDATE_HOOK, setting.ScriptType, "\""+setting.AppPath+"\"", setting.CustomConf)) |
|
|
fmt.Sprintf(_TPL_UPDATE_HOOK, setting.ScriptType, "\""+setting.AppPath+"\"", setting.CustomConf)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func createPostReceiveHook(repoPath string) error { |
|
|
|
|
|
return git.SetPostReceiveHook(repoPath, |
|
|
|
|
|
fmt.Sprintf(_TPL_POST_RECEIVE_HOOK, setting.ScriptType, "\""+setting.AppPath+"\"")) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type MigrateRepoOptions struct { |
|
|
type MigrateRepoOptions struct { |
|
|
Name string |
|
|
Name string |
|
|
Description string |
|
|
Description string |
|
@ -824,8 +818,6 @@ func initRepository(e Engine, repoPath string, u *User, repo *Repository, opts C |
|
|
return fmt.Errorf("InitRepository: %v", err) |
|
|
return fmt.Errorf("InitRepository: %v", err) |
|
|
} else if err = createUpdateHook(repoPath); err != nil { |
|
|
} else if err = createUpdateHook(repoPath); err != nil { |
|
|
return fmt.Errorf("createUpdateHook: %v", err) |
|
|
return fmt.Errorf("createUpdateHook: %v", err) |
|
|
} else if err = createPostReceiveHook(repoPath); err != nil { |
|
|
|
|
|
return fmt.Errorf("createPostReceiveHook: %v", err) |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
tmpDir := filepath.Join(os.TempDir(), "gogs-"+repo.Name+"-"+com.ToStr(time.Now().Nanosecond())) |
|
|
tmpDir := filepath.Join(os.TempDir(), "gogs-"+repo.Name+"-"+com.ToStr(time.Now().Nanosecond())) |
|
@ -1506,15 +1498,6 @@ func RewriteRepositoryUpdateHook() error { |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// RewriteRepositoryPostReceiveHook rewrites all repositories' update hook.
|
|
|
|
|
|
func RewriteRepositoryPostReceiveHook() error { |
|
|
|
|
|
return x.Where("id > 0").Iterate(new(Repository), |
|
|
|
|
|
func(idx int, bean interface{}) error { |
|
|
|
|
|
repo := bean.(*Repository) |
|
|
|
|
|
return createPostReceiveHook(repo.RepoPath()) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// statusPool represents a pool of status with true/false.
|
|
|
// statusPool represents a pool of status with true/false.
|
|
|
type statusPool struct { |
|
|
type statusPool struct { |
|
|
lock sync.RWMutex |
|
|
lock sync.RWMutex |
|
@ -2062,8 +2045,6 @@ func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Reposit |
|
|
|
|
|
|
|
|
if err = createUpdateHook(repoPath); err != nil { |
|
|
if err = createUpdateHook(repoPath); err != nil { |
|
|
return nil, fmt.Errorf("createUpdateHook: %v", err) |
|
|
return nil, fmt.Errorf("createUpdateHook: %v", err) |
|
|
} else if err = createPostReceiveHook(repoPath); err != nil { |
|
|
|
|
|
return nil, fmt.Errorf("createPostReceiveHook: %v", err) |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return repo, sess.Commit() |
|
|
return repo, sess.Commit() |
|
|