Merge branch 'master' of https://github.com/gogits/gogs
This commit is contained in:
commit
035facc564
2
conf/mysql.sql
Normal file
2
conf/mysql.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
DROP DATABASE gogs;
|
||||||
|
CREATE DATABASE IF NOT EXISTS gogs CHARACTER SET utf8 COLLATE utf8_general_ci;
|
2
gogs.go
2
gogs.go
|
@ -19,7 +19,7 @@ import (
|
||||||
// Test that go1.2 tag above is included in builds. main.go refers to this definition.
|
// Test that go1.2 tag above is included in builds. main.go refers to this definition.
|
||||||
const go12tag = true
|
const go12tag = true
|
||||||
|
|
||||||
const APP_VER = "0.1.9.0328 Alpha"
|
const APP_VER = "0.1.9.0329 Alpha"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
base.AppVer = APP_VER
|
base.AppVer = APP_VER
|
||||||
|
|
|
@ -31,6 +31,7 @@ type Action struct {
|
||||||
OpType int // Operations: CREATE DELETE STAR ...
|
OpType int // Operations: CREATE DELETE STAR ...
|
||||||
ActUserId int64 // Action user id.
|
ActUserId int64 // Action user id.
|
||||||
ActUserName string // Action user name.
|
ActUserName string // Action user name.
|
||||||
|
ActEmail string
|
||||||
RepoId int64
|
RepoId int64
|
||||||
RepoName string
|
RepoName string
|
||||||
RefName string
|
RefName string
|
||||||
|
@ -46,6 +47,10 @@ func (a Action) GetActUserName() string {
|
||||||
return a.ActUserName
|
return a.ActUserName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a Action) GetActEmail() string {
|
||||||
|
return a.ActEmail
|
||||||
|
}
|
||||||
|
|
||||||
func (a Action) GetRepoName() string {
|
func (a Action) GetRepoName() string {
|
||||||
return a.RepoName
|
return a.RepoName
|
||||||
}
|
}
|
||||||
|
@ -59,7 +64,7 @@ func (a Action) GetContent() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitRepoAction adds new action for committing repository.
|
// CommitRepoAction adds new action for committing repository.
|
||||||
func CommitRepoAction(userId int64, userName string,
|
func CommitRepoAction(userId int64, userName, actEmail string,
|
||||||
repoId int64, repoName string, refName string, commit *base.PushCommits) error {
|
repoId int64, repoName string, refName string, commit *base.PushCommits) error {
|
||||||
log.Trace("action.CommitRepoAction(start): %d/%s", userId, repoName)
|
log.Trace("action.CommitRepoAction(start): %d/%s", userId, repoName)
|
||||||
|
|
||||||
|
@ -69,8 +74,8 @@ func CommitRepoAction(userId int64, userName string,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = NotifyWatchers(&Action{ActUserId: userId, ActUserName: userName, OpType: OP_COMMIT_REPO,
|
if err = NotifyWatchers(&Action{ActUserId: userId, ActUserName: userName, ActEmail: actEmail,
|
||||||
Content: string(bs), RepoId: repoId, RepoName: repoName, RefName: refName}); err != nil {
|
OpType: OP_COMMIT_REPO, Content: string(bs), RepoId: repoId, RepoName: repoName, RefName: refName}); err != nil {
|
||||||
log.Error("action.CommitRepoAction(notify watchers): %d/%s", userId, repoName)
|
log.Error("action.CommitRepoAction(notify watchers): %d/%s", userId, repoName)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -93,8 +98,8 @@ func CommitRepoAction(userId int64, userName string,
|
||||||
|
|
||||||
// NewRepoAction adds new action for creating repository.
|
// NewRepoAction adds new action for creating repository.
|
||||||
func NewRepoAction(user *User, repo *Repository) (err error) {
|
func NewRepoAction(user *User, repo *Repository) (err error) {
|
||||||
if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, OpType: OP_CREATE_REPO,
|
if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, ActEmail: user.Email,
|
||||||
RepoId: repo.Id, RepoName: repo.Name}); err != nil {
|
OpType: OP_CREATE_REPO, RepoId: repo.Id, RepoName: repo.Name}); err != nil {
|
||||||
log.Error("action.NewRepoAction(notify watchers): %d/%s", user.Id, repo.Name)
|
log.Error("action.NewRepoAction(notify watchers): %d/%s", user.Id, repo.Name)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -478,6 +478,7 @@ func (a argInt) Get(i int, args ...int) (r int) {
|
||||||
type Actioner interface {
|
type Actioner interface {
|
||||||
GetOpType() int
|
GetOpType() int
|
||||||
GetActUserName() string
|
GetActUserName() string
|
||||||
|
GetActEmail() string
|
||||||
GetRepoName() string
|
GetRepoName() string
|
||||||
GetBranch() string
|
GetBranch() string
|
||||||
GetContent() string
|
GetContent() string
|
||||||
|
@ -506,15 +507,23 @@ const (
|
||||||
<div><img src="%s?s=16" alt="user-avatar"/> %s</div>`
|
<div><img src="%s?s=16" alt="user-avatar"/> %s</div>`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type PushCommit struct {
|
||||||
|
Sha1 string
|
||||||
|
Message string
|
||||||
|
AuthorEmail string
|
||||||
|
AuthorName string
|
||||||
|
}
|
||||||
|
|
||||||
type PushCommits struct {
|
type PushCommits struct {
|
||||||
Len int
|
Len int
|
||||||
Commits [][]string
|
Commits []*PushCommit
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionDesc accepts int that represents action operation type
|
// ActionDesc accepts int that represents action operation type
|
||||||
// and returns the description.
|
// and returns the description.
|
||||||
func ActionDesc(act Actioner, avatarLink string) string {
|
func ActionDesc(act Actioner) string {
|
||||||
actUserName := act.GetActUserName()
|
actUserName := act.GetActUserName()
|
||||||
|
email := act.GetActEmail()
|
||||||
repoName := act.GetRepoName()
|
repoName := act.GetRepoName()
|
||||||
repoLink := actUserName + "/" + repoName
|
repoLink := actUserName + "/" + repoName
|
||||||
branch := act.GetBranch()
|
branch := act.GetBranch()
|
||||||
|
@ -529,7 +538,7 @@ func ActionDesc(act Actioner, avatarLink string) string {
|
||||||
}
|
}
|
||||||
buf := bytes.NewBuffer([]byte("\n"))
|
buf := bytes.NewBuffer([]byte("\n"))
|
||||||
for _, commit := range push.Commits {
|
for _, commit := range push.Commits {
|
||||||
buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, avatarLink, repoLink, commit[0], commit[0][:7], commit[1]) + "\n")
|
buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, AvatarLink(commit.AuthorEmail), repoLink, commit.Sha1, commit.Sha1[:7], commit.Message) + "\n")
|
||||||
}
|
}
|
||||||
if push.Len > 3 {
|
if push.Len > 3 {
|
||||||
buf.WriteString(fmt.Sprintf(`<div><a href="/%s/%s/commits/%s">%d other commits >></a></div>`, actUserName, repoName, branch, push.Len))
|
buf.WriteString(fmt.Sprintf(`<div><a href="/%s/%s/commits/%s">%d other commits >></a></div>`, actUserName, repoName, branch, push.Len))
|
||||||
|
@ -539,7 +548,7 @@ func ActionDesc(act Actioner, avatarLink string) string {
|
||||||
case 6: // Create issue.
|
case 6: // Create issue.
|
||||||
infos := strings.SplitN(content, "|", 2)
|
infos := strings.SplitN(content, "|", 2)
|
||||||
return fmt.Sprintf(TPL_CREATE_Issue, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0],
|
return fmt.Sprintf(TPL_CREATE_Issue, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0],
|
||||||
avatarLink, infos[1])
|
AvatarLink(email), infos[1])
|
||||||
default:
|
default:
|
||||||
return "invalid type"
|
return "invalid type"
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify watchers.
|
// Notify watchers.
|
||||||
if err = models.NotifyWatchers(&models.Action{ActUserId: ctx.User.Id, ActUserName: ctx.User.Name,
|
if err = models.NotifyWatchers(&models.Action{ActUserId: ctx.User.Id, ActUserName: ctx.User.Name, ActEmail: ctx.User.Email,
|
||||||
OpType: models.OP_CREATE_ISSUE, Content: fmt.Sprintf("%d|%s", issue.Index, issue.Name),
|
OpType: models.OP_CREATE_ISSUE, Content: fmt.Sprintf("%d|%s", issue.Index, issue.Name),
|
||||||
RepoId: ctx.Repo.Repository.Id, RepoName: ctx.Repo.Repository.Name, RefName: ""}); err != nil {
|
RepoId: ctx.Repo.Repository.Id, RepoName: ctx.Repo.Repository.Name, RefName: ""}); err != nil {
|
||||||
ctx.Handle(200, "issue.CreateIssue", err)
|
ctx.Handle(200, "issue.CreateIssue", err)
|
||||||
|
@ -221,6 +221,7 @@ func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
|
||||||
}
|
}
|
||||||
|
|
||||||
func Comment(ctx *middleware.Context, params martini.Params) {
|
func Comment(ctx *middleware.Context, params martini.Params) {
|
||||||
|
fmt.Println(ctx.Query("change_status"))
|
||||||
if !ctx.Repo.IsValid {
|
if !ctx.Repo.IsValid {
|
||||||
ctx.Handle(404, "issue.Comment(invalid repo):", nil)
|
ctx.Handle(404, "issue.Comment(invalid repo):", nil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,11 +276,9 @@ func Http(ctx *middleware.Context, params martini.Params) {
|
||||||
}
|
}
|
||||||
|
|
||||||
prefix := path.Join("/", username, params["reponame"])
|
prefix := path.Join("/", username, params["reponame"])
|
||||||
server := &webdav.Server{
|
server := webdav.NewServer(
|
||||||
Fs: webdav.Dir(models.RepoPath(username, reponame)),
|
models.RepoPath(username, reponame),
|
||||||
TrimPrefix: prefix,
|
prefix, true)
|
||||||
Listings: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
server.ServeHTTP(ctx.ResponseWriter, ctx.Req)
|
server.ServeHTTP(ctx.ResponseWriter, ctx.Req)
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) {
|
||||||
feeds := make([]string, len(actions))
|
feeds := make([]string, len(actions))
|
||||||
for i := range actions {
|
for i := range actions {
|
||||||
feeds[i] = fmt.Sprintf(TPL_FEED, base.ActionIcon(actions[i].OpType),
|
feeds[i] = fmt.Sprintf(TPL_FEED, base.ActionIcon(actions[i].OpType),
|
||||||
base.TimeSince(actions[i].Created), base.ActionDesc(actions[i], ctx.User.AvatarLink()))
|
base.TimeSince(actions[i].Created), base.ActionDesc(actions[i]))
|
||||||
}
|
}
|
||||||
ctx.JSON(200, &feeds)
|
ctx.JSON(200, &feeds)
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,11 +32,10 @@
|
||||||
{{if eq .TabName "activity"}}
|
{{if eq .TabName "activity"}}
|
||||||
<div class="tab-pane active">
|
<div class="tab-pane active">
|
||||||
<ul class="list-unstyled activity-list">
|
<ul class="list-unstyled activity-list">
|
||||||
{{$avatarLink := .Owner.AvatarLink}}
|
|
||||||
{{range .Feeds}}
|
{{range .Feeds}}
|
||||||
<li>
|
<li>
|
||||||
<i class="icon fa fa-{{ActionIcon .OpType}}"></i>
|
<i class="icon fa fa-{{ActionIcon .OpType}}"></i>
|
||||||
<div class="info"><span class="meta">{{TimeSince .Created}}</span><br>{{ActionDesc . $avatarLink | str2html}}</div>
|
<div class="info"><span class="meta">{{TimeSince .Created}}</span><br>{{ActionDesc . | str2html}}</div>
|
||||||
<span class="clearfix"></span>
|
<span class="clearfix"></span>
|
||||||
</li>
|
</li>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
14
update.go
14
update.go
|
@ -130,18 +130,26 @@ func runUpdate(c *cli.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
commits := make([][]string, 0)
|
commits := make([]*base.PushCommit, 0)
|
||||||
var maxCommits = 3
|
var maxCommits = 3
|
||||||
|
var actEmail string
|
||||||
for e := l.Front(); e != nil; e = e.Next() {
|
for e := l.Front(); e != nil; e = e.Next() {
|
||||||
commit := e.Value.(*git.Commit)
|
commit := e.Value.(*git.Commit)
|
||||||
commits = append(commits, []string{commit.Id().String(), commit.Message()})
|
if actEmail == "" {
|
||||||
|
actEmail = commit.Committer.Email
|
||||||
|
}
|
||||||
|
commits = append(commits,
|
||||||
|
&base.PushCommit{commit.Id().String(),
|
||||||
|
commit.Message(),
|
||||||
|
commit.Author.Email,
|
||||||
|
commit.Author.Name})
|
||||||
if len(commits) >= maxCommits {
|
if len(commits) >= maxCommits {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()})
|
//commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()})
|
||||||
if err = models.CommitRepoAction(int64(sUserId), userName,
|
if err = models.CommitRepoAction(int64(sUserId), userName, actEmail,
|
||||||
repos.Id, repoName, git.BranchName(refName), &base.PushCommits{l.Len(), commits}); err != nil {
|
repos.Id, repoName, git.BranchName(refName), &base.PushCommits{l.Len(), commits}); err != nil {
|
||||||
log.Error("runUpdate.models.CommitRepoAction: %v", err)
|
log.Error("runUpdate.models.CommitRepoAction: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue