summaryrefslogtreecommitdiffstats
path: root/modules/repofiles
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-06-10 19:35:13 +0800
committerGitHub <noreply@github.com>2019-06-10 19:35:13 +0800
commitd93e6232e829a1ade1f9540a701061967aa7d61d (patch)
treedc55b077a6bcf70e85b7032e66da88bc88594e54 /modules/repofiles
parentb1be6fd31f6f9f1512de16cd93d30775319b3c75 (diff)
downloadgitea-d93e6232e829a1ade1f9540a701061967aa7d61d.tar.gz
gitea-d93e6232e829a1ade1f9540a701061967aa7d61d.zip
Move PushUpdate dependency from models to repofiles (#6763)
* remove push_update * move models.PushUpdate to repofiles.PushUpdate
Diffstat (limited to 'modules/repofiles')
-rw-r--r--modules/repofiles/delete.go5
-rw-r--r--modules/repofiles/update.go18
-rw-r--r--modules/repofiles/upload.go4
3 files changed, 20 insertions, 7 deletions
diff --git a/modules/repofiles/delete.go b/modules/repofiles/delete.go
index ccf90f43b3..09a4dbb44c 100644
--- a/modules/repofiles/delete.go
+++ b/modules/repofiles/delete.go
@@ -183,7 +183,8 @@ func DeleteRepoFile(repo *models.Repository, doer *models.User, opts *DeleteRepo
if err = repo.GetOwner(); err != nil {
return nil, fmt.Errorf("GetOwner: %v", err)
}
- err = models.PushUpdate(
+ err = PushUpdate(
+ repo,
opts.NewBranch,
models.PushUpdateOptions{
PusherID: doer.ID,
@@ -199,8 +200,6 @@ func DeleteRepoFile(repo *models.Repository, doer *models.User, opts *DeleteRepo
return nil, fmt.Errorf("PushUpdate: %v", err)
}
- // FIXME: Should we UpdateRepoIndexer(repo) here?
-
file, err := GetFileResponseFromCommit(repo, commit, opts.NewBranch, treePath)
if err != nil {
return nil, err
diff --git a/modules/repofiles/update.go b/modules/repofiles/update.go
index 66e3f2babc..569c89ac51 100644
--- a/modules/repofiles/update.go
+++ b/modules/repofiles/update.go
@@ -394,7 +394,8 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
if err = repo.GetOwner(); err != nil {
return nil, fmt.Errorf("GetOwner: %v", err)
}
- err = models.PushUpdate(
+ err = PushUpdate(
+ repo,
opts.NewBranch,
models.PushUpdateOptions{
PusherID: doer.ID,
@@ -409,7 +410,6 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
if err != nil {
return nil, fmt.Errorf("PushUpdate: %v", err)
}
- models.UpdateRepoIndexer(repo)
commit, err = t.GetCommit(commitHash)
if err != nil {
@@ -422,3 +422,17 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
}
return file, nil
}
+
+// 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 {
+ err := models.PushUpdate(branch, opts)
+ if err != nil {
+ return fmt.Errorf("PushUpdate: %v", err)
+ }
+
+ if opts.RefFullName == git.BranchPrefix+repo.DefaultBranch {
+ models.UpdateRepoIndexer(repo)
+ }
+ return nil
+}
diff --git a/modules/repofiles/upload.go b/modules/repofiles/upload.go
index ed6a9438c7..5f428c3139 100644
--- a/modules/repofiles/upload.go
+++ b/modules/repofiles/upload.go
@@ -188,7 +188,8 @@ func UploadRepoFiles(repo *models.Repository, doer *models.User, opts *UploadRep
if err = repo.GetOwner(); err != nil {
return fmt.Errorf("GetOwner: %v", err)
}
- err = models.PushUpdate(
+ err = PushUpdate(
+ repo,
opts.NewBranch,
models.PushUpdateOptions{
PusherID: doer.ID,
@@ -203,7 +204,6 @@ func UploadRepoFiles(repo *models.Repository, doer *models.User, opts *UploadRep
if err != nil {
return fmt.Errorf("PushUpdate: %v", err)
}
- // FIXME: Should we models.UpdateRepoIndexer(repo) here?
return models.DeleteUploads(uploads...)
}