General code quality improvement
This commit is contained in:
parent
6f9a95f830
commit
a00c932bbc
17 changed files with 180 additions and 171 deletions
|
@ -332,7 +332,12 @@ func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
|
|||
return
|
||||
}
|
||||
|
||||
if err := ctx.Repo.Repository.DeleteRepoFile(ctx.User, ctx.Repo.CommitID, branchName, treeName, form.CommitSummary); err != nil {
|
||||
if err := ctx.Repo.Repository.DeleteRepoFile(ctx.User, models.DeleteRepoFileOptions{
|
||||
LastCommitID: ctx.Repo.CommitID,
|
||||
Branch: branchName,
|
||||
TreePath: treeName,
|
||||
Message: form.CommitSummary,
|
||||
}); err != nil {
|
||||
ctx.Handle(500, "DeleteRepoFile", err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -195,11 +195,11 @@ func HTTP(ctx *context.Context) {
|
|||
if len(fields) >= 3 {
|
||||
oldCommitId := fields[0][4:]
|
||||
newCommitId := fields[1]
|
||||
refName := fields[2]
|
||||
refFullName := fields[2]
|
||||
|
||||
// FIXME: handle error.
|
||||
if err = models.PushUpdate(models.PushUpdateOptions{
|
||||
RefName: refName,
|
||||
RefFullName: refFullName,
|
||||
OldCommitID: oldCommitId,
|
||||
NewCommitID: newCommitId,
|
||||
PusherID: authUser.ID,
|
||||
|
@ -207,8 +207,7 @@ func HTTP(ctx *context.Context) {
|
|||
RepoUserName: username,
|
||||
RepoName: reponame,
|
||||
}); err == nil {
|
||||
go models.HookQueue.Add(repo.ID)
|
||||
go models.AddTestPullRequestTask(authUser, repo.ID, strings.TrimPrefix(refName, git.BRANCH_PREFIX), true)
|
||||
go models.AddTestPullRequestTask(authUser, repo.ID, strings.TrimPrefix(refFullName, git.BRANCH_PREFIX), true)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,17 +5,19 @@
|
|||
package repo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"fmt"
|
||||
git "github.com/gogits/git-module"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
"net/http"
|
||||
"path"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -162,12 +164,17 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
|
|||
if branchName != oldBranchName {
|
||||
oldCommitID = "0000000000000000000000000000000000000000" // New Branch so we use all 0s
|
||||
}
|
||||
if err := models.CommitRepoAction(ctx.User.ID, ctx.Repo.Owner.ID, ctx.User.LowerName, ctx.Repo.Owner.Email,
|
||||
ctx.Repo.Repository.ID, ctx.Repo.Owner.LowerName, ctx.Repo.Repository.Name, "refs/heads/"+branchName, pc,
|
||||
oldCommitID, newCommitID); err != nil {
|
||||
if err := models.CommitRepoAction(models.CommitRepoActionOptions{
|
||||
PusherName: ctx.User.Name,
|
||||
RepoOwnerID: ctx.Repo.Owner.ID,
|
||||
RepoName: ctx.Repo.Owner.Name,
|
||||
RefFullName: git.BRANCH_PREFIX + branchName,
|
||||
OldCommitID: oldCommitID,
|
||||
NewCommitID: newCommitID,
|
||||
Commits: pc,
|
||||
}); err != nil {
|
||||
log.Error(4, "models.CommitRepoAction(branch = %s): %v", branchName, err)
|
||||
}
|
||||
models.HookQueue.Add(ctx.Repo.Repository.ID)
|
||||
}
|
||||
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName + "/" + treeName)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue