]> source.dussan.org Git - gitea.git/commitdiff
Move PushUpdateOptions from models to repofiles (#9124)
authorLunny Xiao <xiaolunwen@gmail.com>
Fri, 29 Nov 2019 02:21:05 +0000 (10:21 +0800)
committerGitHub <noreply@github.com>
Fri, 29 Nov 2019 02:21:05 +0000 (10:21 +0800)
models/update.go
modules/repofiles/update.go
routers/private/hook.go
routers/private/push_update.go
routers/repo/branch.go

index 5e941c22c465cbc5493590fb32f301e92feabc94..deac91b6dcfaea3cb2b0df641db39ac6c8a4eed9 100644 (file)
@@ -53,17 +53,6 @@ func ListToPushCommits(l *list.List) *PushCommits {
        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
 func PushUpdateDeleteTag(repo *Repository, tagName string) error {
        rel, err := GetRelease(repo.ID, tagName)
index ef56609f4d05a32686bc2781179d316060cfa38b..c1eae530993e147e17daabbef03295efa6c11b68 100644 (file)
@@ -410,9 +410,20 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
        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
 // 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
        isDelRef := opts.NewCommitID == git.EmptySHA
        if isNewRef && isDelRef {
index 074e3aef1919b4dd1d4742fa8590548557819940..c9065bceb3d36c1187d3332398c0c1c8ed3b3b78 100644 (file)
@@ -159,7 +159,7 @@ func HookPostReceive(ctx *macaron.Context) {
                        })
                        return
                }
-               if err := repofiles.PushUpdate(repo, branch, models.PushUpdateOptions{
+               if err := repofiles.PushUpdate(repo, branch, repofiles.PushUpdateOptions{
                        RefFullName:  refFullName,
                        OldCommitID:  oldCommitID,
                        NewCommitID:  newCommitID,
index 42eda3178bdfc9f33daf05c4e4cfa647f70445c5..d8102cbfbed233ccd39bb1fd31d8672ac495a3d5 100644 (file)
@@ -18,7 +18,7 @@ import (
 
 // PushUpdate update public key updates
 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 {
                ctx.JSON(500, map[string]interface{}{
                        "err": err.Error(),
index 0c06de3ea6317e9afab32fee7784a525e40a517e..306deca36e653a834a10e4a454051cd73bc2a7ea 100644 (file)
@@ -137,7 +137,7 @@ func deleteBranch(ctx *context.Context, branchName string) error {
        if err := repofiles.PushUpdate(
                ctx.Repo.Repository,
                branchName,
-               models.PushUpdateOptions{
+               repofiles.PushUpdateOptions{
                        RefFullName:  git.BranchPrefix + branchName,
                        OldCommitID:  commit.ID.String(),
                        NewCommitID:  git.EmptySHA,