summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorlunnyxiao <xiaolunwen@gmail.com>2014-09-22 10:43:16 +0800
committerlunnyxiao <xiaolunwen@gmail.com>2014-09-22 10:43:16 +0800
commit150eef93b2340f665c070158ade1863339829e05 (patch)
tree6c44b11cfcd4d74cec98c25b734608296020cc75 /routers
parent7ba9257a7ff659417501baf7358216555cebcd86 (diff)
downloadgitea-150eef93b2340f665c070158ade1863339829e05.tar.gz
gitea-150eef93b2340f665c070158ade1863339829e05.zip
add submodule basic support & buf fixed #478
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/http.go5
-rw-r--r--routers/repo/view.go40
2 files changed, 39 insertions, 6 deletions
diff --git a/routers/repo/http.go b/routers/repo/http.go
index 56c85bf59a..a98478c9f5 100644
--- a/routers/repo/http.go
+++ b/routers/repo/http.go
@@ -103,6 +103,7 @@ func Http(ctx *middleware.Context) {
// check access
if askAuth {
baHead := ctx.Req.Header.Get("Authorization")
+ fmt.Println("auth:", baHead)
if baHead == "" {
authRequired(ctx)
return
@@ -121,6 +122,8 @@ func Http(ctx *middleware.Context) {
return
}
+ fmt.Println("auth2:", authUsername, passwd)
+
authUser, err = models.GetUserByName(authUsername)
if err != nil {
ctx.Handle(401, "no basic auth and digit auth", nil)
@@ -134,6 +137,8 @@ func Http(ctx *middleware.Context) {
return
}
+ fmt.Println("passwd is right")
+
if !isPublicPull {
var tp = models.WRITABLE
if isPull {
diff --git a/routers/repo/view.go b/routers/repo/view.go
index e42894ae73..41fdaba08c 100644
--- a/routers/repo/view.go
+++ b/routers/repo/view.go
@@ -10,6 +10,7 @@ import (
"path"
"path/filepath"
"strings"
+ "time"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/git"
@@ -21,6 +22,15 @@ const (
HOME base.TplName = "repo/home"
)
+type fakeCommit struct {
+ Id string
+ Summary string
+ Url string
+ Committer struct {
+ When time.Time
+ }
+}
+
func Home(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Repo.Repository.Name
@@ -127,13 +137,31 @@ func Home(ctx *middleware.Context) {
files := make([][]interface{}, 0, len(entries))
for _, te := range entries {
- c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name()))
- if err != nil {
- ctx.Handle(404, "GetCommitOfRelPath", err)
- return
- }
+ if te.Type != git.COMMIT {
+ c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name()))
+ if err != nil {
+ ctx.Handle(404, "GetCommitOfRelPath", err)
+ return
+ }
+ files = append(files, []interface{}{te, c})
+ } else {
+ sm, err := ctx.Repo.Commit.GetSubModule(path.Join(treename, te.Name()))
+ if err != nil {
+ ctx.Handle(404, "GetSubModule", err)
+ return
+ }
- files = append(files, []interface{}{te, c})
+ commit := git.Commit{
+ Tree: *tree,
+ Id: te.Id,
+ Committer: &git.Signature{
+ When: time.Now(),
+ },
+ CommitMessage: sm.Url,
+ }
+
+ files = append(files, []interface{}{te, &commit})
+ }
}
ctx.Data["Files"] = files