summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2014-03-22 00:48:26 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2014-03-22 00:48:26 +0800
commitefdaf6ee1536f043d9e242dc16a096c99ec1bfda (patch)
treec2aac787780b7a8e1925e0b4536ae735f7d3680b /models
parent5cb2d3d2e233def07d6956af47dfc49acc45c7e6 (diff)
downloadgitea-efdaf6ee1536f043d9e242dc16a096c99ec1bfda.tar.gz
gitea-efdaf6ee1536f043d9e242dc16a096c99ec1bfda.zip
add http protocol clone support
Diffstat (limited to 'models')
-rw-r--r--models/repo.go11
-rw-r--r--models/user.go6
2 files changed, 13 insertions, 4 deletions
diff --git a/models/repo.go b/models/repo.go
index 4b6dedaf90..cf1e1df5c4 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -257,6 +257,17 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
return err
}
+ // hook/post-update
+ pu2, err := os.OpenFile(filepath.Join(repoPath, "hooks", "post-receive"), os.O_CREATE|os.O_WRONLY, 0777)
+ if err != nil {
+ return err
+ }
+ defer pu2.Close()
+ // TODO: Windows .bat
+ if _, err = pu2.WriteString("#!/usr/bin/env bash\ngit update-server-info\n"); err != nil {
+ return err
+ }
+
// Initialize repository according to user's choice.
fileName := map[string]string{}
if initReadme {
diff --git a/models/user.go b/models/user.go
index 76cf2d20ce..69608ec277 100644
--- a/models/user.go
+++ b/models/user.go
@@ -231,10 +231,8 @@ func UserPath(userName string) string {
func GetUserByKeyId(keyId int64) (*User, error) {
user := new(User)
- rawSql := "SELECT a.* FROM user AS a, public_key AS b WHERE a.id = b.owner_id AND b.id=?"
- if base.Cfg.MustValue("database", "DB_TYPE") == "postgres" {
- rawSql = "SELECT a.* FROM \"user\" AS a, public_key AS b WHERE a.id = b.owner_id AND b.id=?"
- }
+ rawSql := "SELECT a.* FROM `user` AS a, public_key AS b WHERE a.id = b.owner_id AND b.id=?"
+
has, err := orm.Sql(rawSql, keyId).Get(user)
if err != nil {
return nil, err