mirror of
https://github.com/go-gitea/gitea
synced 2024-12-21 15:47:55 +01:00
Move PushUpdateOptions from models to repofiles (#9124)
This commit is contained in:
parent
54dab5aed9
commit
e151674cfa
@ -53,17 +53,6 @@ func ListToPushCommits(l *list.List) *PushCommits {
|
|||||||
return &PushCommits{l.Len(), commits, "", make(map[string]string), make(map[string]*User)}
|
return &PushCommits{l.Len(), commits, "", make(map[string]string), make(map[string]*User)}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PushUpdateOptions defines the push update options
|
|
||||||
type PushUpdateOptions struct {
|
|
||||||
PusherID int64
|
|
||||||
PusherName string
|
|
||||||
RepoUserName string
|
|
||||||
RepoName string
|
|
||||||
RefFullName string
|
|
||||||
OldCommitID string
|
|
||||||
NewCommitID string
|
|
||||||
}
|
|
||||||
|
|
||||||
// PushUpdateDeleteTag must be called for any push actions to delete tag
|
// PushUpdateDeleteTag must be called for any push actions to delete tag
|
||||||
func PushUpdateDeleteTag(repo *Repository, tagName string) error {
|
func PushUpdateDeleteTag(repo *Repository, tagName string) error {
|
||||||
rel, err := GetRelease(repo.ID, tagName)
|
rel, err := GetRelease(repo.ID, tagName)
|
||||||
|
@ -410,9 +410,20 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
|
|||||||
return file, nil
|
return file, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PushUpdateOptions defines the push update options
|
||||||
|
type PushUpdateOptions struct {
|
||||||
|
PusherID int64
|
||||||
|
PusherName string
|
||||||
|
RepoUserName string
|
||||||
|
RepoName string
|
||||||
|
RefFullName string
|
||||||
|
OldCommitID string
|
||||||
|
NewCommitID string
|
||||||
|
}
|
||||||
|
|
||||||
// PushUpdate must be called for any push actions in order to
|
// PushUpdate must be called for any push actions in order to
|
||||||
// generates necessary push action history feeds and other operations
|
// generates necessary push action history feeds and other operations
|
||||||
func PushUpdate(repo *models.Repository, branch string, opts models.PushUpdateOptions) error {
|
func PushUpdate(repo *models.Repository, branch string, opts PushUpdateOptions) error {
|
||||||
isNewRef := opts.OldCommitID == git.EmptySHA
|
isNewRef := opts.OldCommitID == git.EmptySHA
|
||||||
isDelRef := opts.NewCommitID == git.EmptySHA
|
isDelRef := opts.NewCommitID == git.EmptySHA
|
||||||
if isNewRef && isDelRef {
|
if isNewRef && isDelRef {
|
||||||
|
@ -159,7 +159,7 @@ func HookPostReceive(ctx *macaron.Context) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := repofiles.PushUpdate(repo, branch, models.PushUpdateOptions{
|
if err := repofiles.PushUpdate(repo, branch, repofiles.PushUpdateOptions{
|
||||||
RefFullName: refFullName,
|
RefFullName: refFullName,
|
||||||
OldCommitID: oldCommitID,
|
OldCommitID: oldCommitID,
|
||||||
NewCommitID: newCommitID,
|
NewCommitID: newCommitID,
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
|
|
||||||
// PushUpdate update public key updates
|
// PushUpdate update public key updates
|
||||||
func PushUpdate(ctx *macaron.Context) {
|
func PushUpdate(ctx *macaron.Context) {
|
||||||
var opt models.PushUpdateOptions
|
var opt repofiles.PushUpdateOptions
|
||||||
if err := json.NewDecoder(ctx.Req.Request.Body).Decode(&opt); err != nil {
|
if err := json.NewDecoder(ctx.Req.Request.Body).Decode(&opt); err != nil {
|
||||||
ctx.JSON(500, map[string]interface{}{
|
ctx.JSON(500, map[string]interface{}{
|
||||||
"err": err.Error(),
|
"err": err.Error(),
|
||||||
|
@ -137,7 +137,7 @@ func deleteBranch(ctx *context.Context, branchName string) error {
|
|||||||
if err := repofiles.PushUpdate(
|
if err := repofiles.PushUpdate(
|
||||||
ctx.Repo.Repository,
|
ctx.Repo.Repository,
|
||||||
branchName,
|
branchName,
|
||||||
models.PushUpdateOptions{
|
repofiles.PushUpdateOptions{
|
||||||
RefFullName: git.BranchPrefix + branchName,
|
RefFullName: git.BranchPrefix + branchName,
|
||||||
OldCommitID: commit.ID.String(),
|
OldCommitID: commit.ID.String(),
|
||||||
NewCommitID: git.EmptySHA,
|
NewCommitID: git.EmptySHA,
|
||||||
|
Loading…
Reference in New Issue
Block a user