mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-01 05:36:19 +01:00
Add directory level commit message
This commit is contained in:
parent
3164354255
commit
b8368f98ff
6 changed files with 32 additions and 11 deletions
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.5.4.0925 Beta"
|
const APP_VER = "0.5.4.0926 Beta"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -521,8 +521,17 @@ type UserCommit struct {
|
||||||
*git.Commit
|
*git.Commit
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidCommitsWithEmails checks if authors' e-mails of commits are correcponding to users.
|
// ValidateCommitWithEmail chceck if author's e-mail of commit is corresponsind to a user.
|
||||||
func ValidCommitsWithEmails(oldCommits *list.List) *list.List {
|
func ValidateCommitWithEmail(c *git.Commit) (uname string) {
|
||||||
|
u, err := GetUserByEmail(c.Author.Email)
|
||||||
|
if err == nil {
|
||||||
|
uname = u.Name
|
||||||
|
}
|
||||||
|
return uname
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidateCommitsWithEmails checks if authors' e-mails of commits are corresponding to users.
|
||||||
|
func ValidateCommitsWithEmails(oldCommits *list.List) *list.List {
|
||||||
emails := map[string]string{}
|
emails := map[string]string{}
|
||||||
newCommits := list.New()
|
newCommits := list.New()
|
||||||
e := oldCommits.Front()
|
e := oldCommits.Front()
|
||||||
|
|
|
@ -61,7 +61,7 @@ func Commits(ctx *middleware.Context) {
|
||||||
ctx.Handle(500, "CommitsByRange", err)
|
ctx.Handle(500, "CommitsByRange", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
commits = models.ValidCommitsWithEmails(commits)
|
commits = models.ValidateCommitsWithEmails(commits)
|
||||||
|
|
||||||
ctx.Data["Commits"] = commits
|
ctx.Data["Commits"] = commits
|
||||||
ctx.Data["Username"] = userName
|
ctx.Data["Username"] = userName
|
||||||
|
@ -99,7 +99,7 @@ func SearchCommits(ctx *middleware.Context) {
|
||||||
ctx.Handle(500, "SearchCommits", err)
|
ctx.Handle(500, "SearchCommits", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
commits = models.ValidCommitsWithEmails(commits)
|
commits = models.ValidateCommitsWithEmails(commits)
|
||||||
|
|
||||||
ctx.Data["Keyword"] = keyword
|
ctx.Data["Keyword"] = keyword
|
||||||
ctx.Data["Username"] = userName
|
ctx.Data["Username"] = userName
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/git"
|
"github.com/gogits/gogs/modules/git"
|
||||||
"github.com/gogits/gogs/modules/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
|
@ -130,20 +131,20 @@ func Home(ctx *middleware.Context) {
|
||||||
if te.Type != git.COMMIT {
|
if te.Type != git.COMMIT {
|
||||||
c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name()))
|
c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(404, "GetCommitOfRelPath", err)
|
ctx.Handle(500, "GetCommitOfRelPath", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
files = append(files, []interface{}{te, c})
|
files = append(files, []interface{}{te, c})
|
||||||
} else {
|
} else {
|
||||||
sm, err := ctx.Repo.Commit.GetSubModule(path.Join(treename, te.Name()))
|
sm, err := ctx.Repo.Commit.GetSubModule(path.Join(treename, te.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(404, "GetSubModule", err)
|
ctx.Handle(500, "GetSubModule", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name()))
|
c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(404, "GetCommitOfRelPath", err)
|
ctx.Handle(500, "GetCommitOfRelPath", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
files = append(files, []interface{}{te, git.NewSubModuleFile(c, sm.Url, te.Id.String())})
|
files = append(files, []interface{}{te, git.NewSubModuleFile(c, sm.Url, te.Id.String())})
|
||||||
|
@ -195,6 +196,18 @@ func Home(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastCommit := ctx.Repo.Commit
|
||||||
|
if len(treePath) > 0 {
|
||||||
|
c, err := ctx.Repo.Commit.GetCommitOfRelPath(treePath)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Handle(500, "GetCommitOfRelPath", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
lastCommit = c
|
||||||
|
}
|
||||||
|
ctx.Data["LastCommit"] = lastCommit
|
||||||
|
ctx.Data["LastCommitUser"] = models.ValidateCommitWithEmail(lastCommit)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["Username"] = userName
|
ctx.Data["Username"] = userName
|
||||||
|
@ -215,7 +228,6 @@ func Home(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["LastCommit"] = ctx.Repo.Commit
|
|
||||||
ctx.Data["Paths"] = Paths
|
ctx.Data["Paths"] = Paths
|
||||||
ctx.Data["TreeName"] = treename
|
ctx.Data["TreeName"] = treename
|
||||||
ctx.Data["Treenames"] = treenames
|
ctx.Data["Treenames"] = treenames
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.5.4.0925 Beta
|
0.5.4.0926 Beta
|
|
@ -4,7 +4,7 @@
|
||||||
<th colspan="4" class="clear">
|
<th colspan="4" class="clear">
|
||||||
<span class="author left">
|
<span class="author left">
|
||||||
<img class="avatar-24 radius" src="{{AvatarLink .LastCommit.Author.Email}}" />
|
<img class="avatar-24 radius" src="{{AvatarLink .LastCommit.Author.Email}}" />
|
||||||
<a href="{{AppSubUrl}}/user/email2user?email={{.LastCommit.Author.Email}}"><strong>{{.LastCommit.Author.Name}}</strong>:</a>
|
{{if .LastCommitUser}}<a href="{{AppSubUrl}}/{{.LastCommitUser}}">{{end}}<strong>{{.LastCommit.Author.Name}}</strong>:{{if .LastCommitUser}}</a>{{end}}
|
||||||
</span>
|
</span>
|
||||||
<span class="last-commit"><a href="{{.RepoLink}}/commit/{{.LastCommit.Id}}" rel="nofollow">
|
<span class="last-commit"><a href="{{.RepoLink}}/commit/{{.LastCommit.Id}}" rel="nofollow">
|
||||||
<strong>{{ShortSha .LastCommit.Id.String}}</strong></a>
|
<strong>{{ShortSha .LastCommit.Id.String}}</strong></a>
|
||||||
|
|
Loading…
Reference in a new issue