Bladeren bron

[models/repo_editor] Minimising upstream file diff

Moved StartIndexing() function to repo_editor_gin.go
Achilleas Koutsou 6 jaren geleden
bovenliggende
commit
206f6624f3
2 gewijzigde bestanden met toevoegingen van 31 en 22 verwijderingen
  1. 0 22
      models/repo_editor.go
  2. 31 0
      models/repo_editor_gin.go

+ 0 - 22
models/repo_editor.go

@@ -22,10 +22,6 @@ import (
 
 	git "github.com/G-Node/git-module"
 
-	"bytes"
-	"encoding/json"
-	"net/http"
-
 	gannex "github.com/G-Node/go-annex"
 	"github.com/G-Node/gogs/models/errors"
 	"github.com/G-Node/gogs/pkg/process"
@@ -574,21 +570,3 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions)
 	RemoveAllWithNotice("Cleaning out after upload", localPath)
 	return DeleteUploads(uploads...)
 }
-
-func StartIndexing(user, owner *User, repo *Repository) {
-	var ireq struct{ RepoID, RepoPath string }
-	ireq.RepoID = fmt.Sprintf("%d", repo.ID)
-	ireq.RepoPath = repo.FullName()
-	data, err := json.Marshal(ireq)
-	if err != nil {
-		log.Trace("could not marshal index request :%+v", err)
-		return
-	}
-	req, _ := http.NewRequest(http.MethodPost, setting.Search.IndexUrl, bytes.NewReader(data))
-	client := http.Client{}
-	resp, err := client.Do(req)
-	if err != nil || resp.StatusCode != http.StatusOK {
-		log.Trace("Error doing index request:%+v", err)
-		return
-	}
-}

+ 31 - 0
models/repo_editor_gin.go

@@ -0,0 +1,31 @@
+package models
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"net/http"
+
+	"github.com/G-Node/gogs/pkg/setting"
+	log "gopkg.in/clog.v1"
+)
+
+// StartIndexing sends an indexing request to the configured indexing service
+// for a repository.
+func StartIndexing(user, owner *User, repo *Repository) {
+	var ireq struct{ RepoID, RepoPath string }
+	ireq.RepoID = fmt.Sprintf("%d", repo.ID)
+	ireq.RepoPath = repo.FullName()
+	data, err := json.Marshal(ireq)
+	if err != nil {
+		log.Trace("could not marshal index request :%+v", err)
+		return
+	}
+	req, _ := http.NewRequest(http.MethodPost, setting.Search.IndexUrl, bytes.NewReader(data))
+	client := http.Client{}
+	resp, err := client.Do(req)
+	if err != nil || resp.StatusCode != http.StatusOK {
+		log.Trace("Error doing index request:%+v", err)
+		return
+	}
+}