Clean code
This commit is contained in:
parent
50df58a893
commit
c3e0554fd7
2
gogs.go
2
gogs.go
|
@ -20,7 +20,7 @@ import (
|
||||||
// Test that go1.1 tag above is included in builds. main.go refers to this definition.
|
// Test that go1.1 tag above is included in builds. main.go refers to this definition.
|
||||||
const go11tag = true
|
const go11tag = true
|
||||||
|
|
||||||
const APP_VER = "0.0.8.0315"
|
const APP_VER = "0.0.8.0316.1"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
base.AppVer = APP_VER
|
base.AppVer = APP_VER
|
||||||
|
|
|
@ -43,6 +43,7 @@ func (a Action) GetRepoName() string {
|
||||||
return a.RepoName
|
return a.RepoName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CommitRepoAction records action for commit repository.
|
||||||
func CommitRepoAction(userId int64, userName string,
|
func CommitRepoAction(userId int64, userName string,
|
||||||
repoId int64, repoName string, msg string) error {
|
repoId int64, repoName string, msg string) error {
|
||||||
_, err := orm.InsertOne(&Action{
|
_, err := orm.InsertOne(&Action{
|
||||||
|
@ -57,8 +58,7 @@ func CommitRepoAction(userId int64, userName string,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRepoAction inserts action for create repository.
|
// NewRepoAction records action for create repository.
|
||||||
|
|
||||||
func NewRepoAction(user *User, repo *Repository) error {
|
func NewRepoAction(user *User, repo *Repository) error {
|
||||||
_, err := orm.InsertOne(&Action{
|
_, err := orm.InsertOne(&Action{
|
||||||
UserId: user.Id,
|
UserId: user.Id,
|
||||||
|
|
27
update.go
27
update.go
|
@ -1,13 +1,19 @@
|
||||||
|
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
|
|
||||||
git "github.com/gogits/git"
|
git "github.com/gogits/git"
|
||||||
|
|
||||||
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/modules/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var CmdUpdate = cli.Command{
|
var CmdUpdate = cli.Command{
|
||||||
|
@ -41,11 +47,18 @@ func runUpdate(*cli.Context) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sUserId, _ := strconv.Atoi(userId)
|
sUserId, err := strconv.Atoi(userId)
|
||||||
sRepoId, _ := strconv.Atoi(repoId)
|
|
||||||
err = models.CommitRepoAction(int64(sUserId), userName,
|
|
||||||
int64(sRepoId), repoName, lastCommit.Message())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//TODO: log
|
log.Error("runUpdate.Parse userId: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
sRepoId, err := strconv.Atoi(repoId)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("runUpdate.Parse repoId: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = models.CommitRepoAction(int64(sUserId), userName,
|
||||||
|
int64(sRepoId), repoName, lastCommit.Message()); err != nil {
|
||||||
|
log.Error("runUpdate.models.CommitRepoAction: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue