ソースを参照

[vendor] removed gin-dex from venrdoring

cgars 7 年 前
コミット
74f3a7d367

+ 0 - 12
vendor/github.com/G-Node/gin-dex/Dockerfile

@@ -1,12 +0,0 @@
-FROM golang:1.8
-
-WORKDIR /go/src/github.com/G-Node/gin-dex
-COPY . .
-
-RUN  go get ./...
-RUN go build
-
-EXPOSE 8099
-VOLUME /repos
-
-ENTRYPOINT  ./gin-dex --debug

+ 0 - 29
vendor/github.com/G-Node/gin-dex/LICENSE

@@ -1,29 +0,0 @@
-BSD 3-Clause License
-
-Copyright (c) 2017, German Neuroinformatics Node
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright notice, this
-  list of conditions and the following disclaimer.
-
-* Redistributions in binary form must reproduce the above copyright notice,
-  this list of conditions and the following disclaimer in the documentation
-  and/or other materials provided with the distribution.
-
-* Neither the name of the copyright holder nor the names of its
-  contributors may be used to endorse or promote products derived from
-  this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 0 - 2
vendor/github.com/G-Node/gin-dex/README.md

@@ -1,2 +0,0 @@
-# gin-dex
-Indexing Service for gin

BIN
vendor/github.com/G-Node/gin-dex/gin-dex


+ 0 - 54
vendor/github.com/G-Node/gin-dex/gindex/determine.go

@@ -1,54 +0,0 @@
-package gindex
-
-import (
-	"bufio"
-
-	"net/http"
-	"strings"
-
-	"github.com/G-Node/gogs/pkg/tool"
-	"github.com/Sirupsen/logrus"
-)
-
-const (
-	UKKNOWN = iota
-	ANNEX
-	ODML_XML
-	TEXT
-)
-
-func DetermineFileType(peekData []byte) (int64, error) {
-	if tool.IsAnnexedFile(peekData){
-		logrus.Debugf("Found an annex file")
-		return ANNEX,nil
-	}
-	typeStr := http.DetectContentType(peekData)
-	if strings.Contains(typeStr, "text") {
-		if strings.Contains(string(peekData), "ODML") {
-			return ODML_XML, nil
-		}
-		logrus.Debugf("Found a text file")
-		return TEXT, nil
-	}
-	return UKKNOWN, nil
-
-}
-func BlobFileType(blob *IndexBlob) (int64, *bufio.Reader, error) {
-	blobBuffer := bufio.NewReader(blob.Blob)
-	if blob.Size() > 1024 {
-		peekData, err := blobBuffer.Peek(1024)
-		if err != nil {
-			return UKKNOWN,nil, err
-		}
-		fType, err := DetermineFileType(peekData)
-		return fType, blobBuffer, err
-	} else {
-		peekData, err := blobBuffer.Peek(int(blob.Size())) // conversion should be fine(<1024)
-		if err != nil {
-			return UKKNOWN, nil, err
-		}
-		fType, err := DetermineFileType(peekData)
-		return fType, blobBuffer, err
-	}
-
-}

+ 0 - 184
vendor/github.com/G-Node/gin-dex/gindex/elastic.go

@@ -1,184 +0,0 @@
-package gindex
-
-import (
-	"bytes"
-	"fmt"
-	"net/http"
-
-	"encoding/json"
-
-	"io/ioutil"
-
-	"github.com/G-Node/gig"
-	log "github.com/Sirupsen/logrus"
-)
-
-type ElServer struct {
-	adress   string
-	uname    *string
-	password *string
-}
-
-const (
-	BLOB_INDEX   = "blobs"
-	COMMIT_INDEX = "commits"
-)
-
-func NewElServer(adress string, uname, password *string) *ElServer {
-	return &ElServer{adress: adress, uname: uname, password: password}
-}
-
-func (el *ElServer) Index(index, doctype string, data []byte, id gig.SHA1) (*http.Response, error) {
-	adrr := fmt.Sprintf("%s/%s/%s/%s", el.adress, index, doctype, id.String())
-	req, err := http.NewRequest("POST", adrr, bytes.NewReader(data))
-	if err != nil {
-		return nil, err
-	}
-	return el.elasticRequest(req)
-}
-
-func (el *ElServer) elasticRequest(req *http.Request) (*http.Response, error) {
-	if el.uname != nil {
-		req.SetBasicAuth(*el.uname, *el.password)
-	}
-	req.Header.Set("Content-Type", "application/json")
-	cl := http.Client{}
-	return cl.Do(req)
-}
-
-func (el *ElServer) HasCommit(index string, commitId gig.SHA1) (bool, error) {
-	adrr := fmt.Sprintf("%s/commits/commit/%s", el.adress, commitId)
-	return el.Has(adrr)
-}
-
-func (el *ElServer) HasBlob(index string, blobId gig.SHA1) (bool, error) {
-	adrr := fmt.Sprintf("%s/blobs/blob/%s", el.adress, blobId)
-	return el.Has(adrr)
-}
-
-func (el *ElServer) Has(adr string) (bool, error) {
-	req, err := http.NewRequest("GET", adr, nil)
-	if err != nil {
-		return false, err
-	}
-	resp, err := el.elasticRequest(req)
-	if err != nil {
-		return false, err
-	}
-	bdy, err := ioutil.ReadAll(resp.Body)
-	resp.Body.Close()
-	var res struct{ Found bool }
-	err = json.Unmarshal(bdy, &res)
-	if err != nil {
-		log.WithError(err)
-		return false, err
-	}
-	return res.Found, nil
-}
-
-func (el *ElServer) search(querry, adrr string) (*http.Response, error) {
-	req, err := http.NewRequest("POST", adrr, bytes.NewReader([]byte(querry)))
-	if err != nil {
-		log.Errorf("Could not form search query:%+v", err)
-		log.Errorf("Formatted query was:%s", querry)
-		return nil, err
-	}
-	return el.elasticRequest(req)
-}
-
-func (el *ElServer) SearchBlobs(querry string, okRepos []string) (*http.Response, error) {
-	//implement the passing of the repo ids
-	repos, err := json.Marshal(okRepos)
-	if err != nil {
-		log.Errorf("Could not marshal okRepos: %+v", err)
-		return nil, err
-	}
-	formatted_querry := fmt.Sprintf(BLOB_QUERRY, querry, string(repos))
-	adrr := fmt.Sprintf("%s/%s/_search", el.adress, BLOB_INDEX)
-	return el.search(formatted_querry, adrr)
-}
-
-func (el *ElServer) SearchCommits(querry string, okRepos []string) (*http.Response, error) {
-	//implement the passing of the repo ids
-	repos, err := json.Marshal(okRepos)
-	if err != nil {
-		log.Errorf("Could not marshal okRepos: %+v", err)
-		return nil, err
-	}
-	formatted_querry := fmt.Sprintf(COMMIT_QUERRY, querry, string(repos))
-	adrr := fmt.Sprintf("%s/%s/_search", el.adress, COMMIT_INDEX)
-	return el.search(formatted_querry, adrr)
-}
-
-var BLOB_QUERRY = `{
-	"from" : 0, "size" : 20,
-	  "_source": ["Oid","GinRepoName","FirstCommit","Path"],
-	  "query": {
-		"bool": {
-		  "must": {
-			"match": {
-			  "_all": "%s"
-			}
-		  },
-		  "filter": {
-			"terms": {
-			  "GinRepoId" : %s
-			}
-		  }
-		}
-	},
-	"highlight" : {
-		"fields" : [
-			{"Content" : {
-				"fragment_size" : 100,
-				"number_of_fragments" : 10,
-				"fragmenter": "span",
-				"require_field_match":false,
-				"pre_tags" : ["<b>"],
-				"post_tags" : ["</b>"]
-				}
-			}
-		]
-	}
-}`
-
-var COMMIT_QUERRY = `{
-	"from" : 0, "size" : 20,
-	  "_source": ["Oid","GinRepoName","FirstCommit","Path"],
-	  "query": {
-		"bool": {
-		  "must": {
-			"match": {
-			  "_all": "%s"
-			}
-		  },
-		  "filter": {
-			"terms": {
-			  "GinRepoId" : %s
-			}
-		  }
-		}
-	},
-	"highlight" : {
-		"fields" : [
-			{"Message" : {
-				"fragment_size" : 50,
-				"number_of_fragments" : 3,
-				"fragmenter": "span",
-				"require_field_match":false,
-				"pre_tags" : ["<b>"],
-				"post_tags" : ["</b>"]
-				}
-			},
-			{"GinRepoName" : {
-				"fragment_size" : 50,
-				"number_of_fragments" : 3,
-				"fragmenter": "span",
-				"require_field_match":false,
-				"pre_tags" : ["<b>"],
-				"post_tags" : ["</b>"]
-				}
-			}
-		]
-	}
-}`

+ 0 - 42
vendor/github.com/G-Node/gin-dex/gindex/gindex.go

@@ -1,42 +0,0 @@
-package gindex
-
-type SearchRequest struct {
-	Token  string
-	CsrfT  string
-	UserID int64
-	Querry string
-	SType  int64
-}
-
-type IndexRequest struct {
-	UserID   int
-	RepoPath string
-	RepoID   string
-}
-
-type ReIndexRequest struct {
-	*IndexRequest
-	Token string
-	CsrfT string
-}
-type GinServer struct {
-	URL     string
-	GetRepo string
-}
-
-type BlobSResult struct {
-	Source    *IndexBlob  `json:"_source"`
-	Score     float64     `json:"_score"`
-	Highlight interface{} `json:"highlight"`
-}
-
-type CommitSResult struct {
-	Source    *IndexCommit `json:"_source"`
-	Score     float64      `json:"_score"`
-	Highlight interface{}  `json:"highlight"`
-}
-
-type SearchResults struct {
-	Blobs   []BlobSResult
-	Commits []CommitSResult
-}

+ 0 - 179
vendor/github.com/G-Node/gin-dex/gindex/handler.go

@@ -1,179 +0,0 @@
-package gindex
-
-import (
-	"net/http"
-	"fmt"
-	log "github.com/Sirupsen/logrus"
-	"github.com/gogits/go-gogs-client"
-
-	"encoding/json"
-	"bytes"
-	"net/http/httptest"
-	"strings"
-)
-
-// Handler for Index requests
-func IndexH(w http.ResponseWriter, r *http.Request, els *ElServer, rpath *string) {
-	rbd := IndexRequest{}
-	err := getParsedBody(r, &rbd)
-	log.Debugf("got a indexing request:%+v", rbd)
-	if err != nil {
-		w.WriteHeader(http.StatusBadRequest)
-		return
-	}
-	err = IndexRepoWithPath(fmt.Sprintf("%s/%s", *rpath, strings.ToLower(rbd.RepoPath)+".git"),
-		"master", els, rbd.RepoID, rbd.RepoPath)
-	if err != nil {
-		w.WriteHeader(http.StatusInternalServerError)
-		return
-	}
-	w.WriteHeader(http.StatusOK)
-	return
-}
-
-// Handler for SearchBlobs requests
-func SearchH(w http.ResponseWriter, r *http.Request, els *ElServer, gins *GinServer) {
-	rbd := SearchRequest{}
-	err := getParsedBody(r, &rbd)
-	log.Debugf("got a search request:%+v", rbd)
-	if err != nil {
-		w.WriteHeader(http.StatusBadRequest)
-		return
-	}
-	// Get repo ids from the gin server to which the user has access
-	// we need to limit results to those
-	repos := []gogs.Repository{}
-	err = getParsedHttpCall(http.MethodGet, fmt.Sprintf("%s/api/v1/user/repos", gins.URL),
-		nil, rbd.Token, rbd.CsrfT, &repos)
-	if err != nil {
-		log.Errorf("could not querry repos: %+v", err)
-		w.WriteHeader(http.StatusUnauthorized)
-		return
-	}
-	// Get repos ids for public repos
-	prepos := struct{ Data []gogs.Repository }{}
-	err = getParsedHttpCall(http.MethodGet, fmt.Sprintf("%s/api/v1/repos/search/?limit=10000", gins.URL),
-		nil, rbd.Token, rbd.CsrfT, &prepos)
-	if err != nil {
-		log.Errorf("could not querry public repos: %+v", err)
-		w.WriteHeader(http.StatusUnauthorized)
-		return
-	}
-	repos = append(repos, prepos.Data...)
-
-	repids := make([]string, len(repos))
-	for c, repo := range repos {
-		repids[c] = fmt.Sprintf("%d", repo.ID)
-	}
-	log.Debugf("Repod to search in:%+v", repids)
-	// Lets search now
-	rBlobs := [] BlobSResult{}
-	err = searchBlobs(rbd.Querry, repids, els, &rBlobs)
-	if err != nil {
-		log.Warnf("could not search blobs:%+v", err)
-	}
-	rCommits := [] CommitSResult{}
-	err = searchCommits(rbd.Querry, repids, els, &rCommits)
-	if err != nil {
-		log.Warnf("could not search commits:%+v", err)
-	}
-	data, err := json.Marshal(SearchResults{Blobs: rBlobs, Commits: rCommits})
-	if err != nil {
-		log.Debugf("Could not Masrschal search results")
-		w.WriteHeader(http.StatusInternalServerError)
-		return
-	}
-	w.WriteHeader(http.StatusOK)
-	w.Write(data)
-}
-
-// Handler for Index requests
-func ReIndexRepo(w http.ResponseWriter, r *http.Request, els *ElServer, rpath *string) {
-	rbd := IndexRequest{}
-	err := getParsedBody(r, &rbd)
-	log.Debugf("got a indexing request:%+v", rbd)
-	if err != nil {
-		w.WriteHeader(http.StatusBadRequest)
-		return
-	}
-	err = ReIndexRepoWithPath(fmt.Sprintf("%s/%s", *rpath, strings.ToLower(rbd.RepoPath)+".git"),
-		"master", els, rbd.RepoID, rbd.RepoPath)
-	if err != nil {
-		w.WriteHeader(http.StatusInternalServerError)
-		return
-	}
-	w.WriteHeader(http.StatusOK)
-	return
-}
-func ReindexH(w http.ResponseWriter, r *http.Request, els *ElServer, gins *GinServer, rpath *string) {
-	rbd := ReIndexRequest{}
-	getParsedBody(r, &rbd)
-	log.Debugf("got a reindex request:%+v", rbd)
-	repos, err := findRepos(*rpath, &rbd, gins)
-	if err != nil {
-		log.Debugf("failed listing repositories: %+v", err)
-		w.WriteHeader(http.StatusInternalServerError)
-		return
-	}
-	if err != nil {
-		w.WriteHeader(http.StatusBadRequest)
-		return
-	}
-
-	for _, repo := range repos {
-		rec := httptest.NewRecorder()
-		ireq := IndexRequest{rbd.UserID, repo.FullName,
-			fmt.Sprintf("%d", repo.ID)}
-		data, _ := json.Marshal(ireq)
-		req, _ := http.NewRequest(http.MethodPost, "/index", bytes.NewReader(data))
-		ReIndexRepo(rec, req, els, rpath)
-		if rec.Code != http.StatusOK {
-			log.Debugf("Could not index %s,%d", repo.FullName, rec.Code)
-		}
-	}
-	w.WriteHeader(http.StatusOK)
-}
-
-func searchCommits(querry string, okRepids []string, els *ElServer,
-	result interface{}) error {
-	commS, err := els.SearchCommits(querry, okRepids)
-	if err != nil {
-		return err
-	}
-	err = parseElResult(commS, &result)
-	commS.Body.Close()
-	if err != nil {
-		return err
-	}
-	return nil
-}
-
-func searchBlobs(querry string, okRepids []string, els *ElServer,
-	result interface{}) error {
-	blobS, err := els.SearchBlobs(querry, okRepids)
-	if err != nil {
-		return err
-	}
-	err = parseElResult(blobS, &result)
-	blobS.Body.Close()
-	if err != nil {
-		return err
-	}
-	return nil
-}
-
-func parseElResult(comS *http.Response, pRes interface{}) error {
-	var res interface{}
-	err := getParsedResponse(comS, &res)
-	if err != nil {
-		return err
-	}
-	// extract the somewhat nested search rersult
-	if x, ok := res.(map[string](interface{})); ok {
-		if y, ok := x["hits"].(map[string](interface{})); ok {
-			err = map2struct(y["hits"], &pRes)
-			return err
-		}
-	}
-	return fmt.Errorf("could not extract elastic result")
-}

+ 0 - 136
vendor/github.com/G-Node/gin-dex/gindex/indexObjects.go

@@ -1,136 +0,0 @@
-package gindex
-
-import (
-	"encoding/json"
-	"io/ioutil"
-	"time"
-
-	"github.com/G-Node/gig"
-	log "github.com/Sirupsen/logrus"
-	"github.com/G-Node/go-annex"
-	"fmt"
-)
-
-type IndexBlob struct {
-	*gig.Blob
-	GinRepoName  string
-	GinRepoId    string
-	FirstCommit  string
-	Id           int64
-	Oid          gig.SHA1
-	IndexingTime time.Time
-	Content      string
-	Path         string
-}
-
-func NewCommitFromGig(gCommit *gig.Commit, repoid string, reponame string, oid gig.SHA1) *IndexCommit {
-	commit := &IndexCommit{gCommit, repoid, oid,
-		reponame, time.Now()}
-	return commit
-}
-
-func NewBlobFromGig(gBlob *gig.Blob, repoid string, oid gig.SHA1, commit string, path string, reponame string) *IndexBlob {
-	// Remember keeping the id
-	blob := IndexBlob{Blob: gBlob, GinRepoId: repoid, Oid: oid, FirstCommit: commit, Path: path, GinRepoName: reponame}
-	return &blob
-}
-
-type IndexCommit struct {
-	*gig.Commit
-	GinRepoId    string
-	Oid          gig.SHA1
-	GinRepoName  string
-	IndexingTime time.Time
-}
-
-func BlobFromJson(data []byte) (*IndexBlob, error) {
-	bl := &IndexBlob{}
-	err := json.Unmarshal(data, bl)
-	return bl, err
-}
-
-func (c *IndexCommit) ToJson() ([]byte, error) {
-	return json.Marshal(c)
-}
-
-func (c *IndexCommit) AddToIndex(server *ElServer, index string, id gig.SHA1) error {
-	data, err := c.ToJson()
-	if err != nil {
-		return err
-	}
-	indexid := GetIndexCommitId(id.String(), c.GinRepoId)
-	err = AddToIndex(data, server, index, "commit", indexid)
-	return err
-}
-
-func (bl *IndexBlob) ToJson() ([]byte, error) {
-	return json.Marshal(bl)
-}
-
-func (bl *IndexBlob) AddToIndex(server *ElServer, index, repopath string, id gig.SHA1) error {
-	indexid := GetIndexCommitId(id.String(), bl.GinRepoId)
-	if bl.Size() > gannex.MEGABYTE*10 {
-		return fmt.Errorf("File to big")
-	}
-	f_type, blobBuffer, err := BlobFileType(bl)
-	if err != nil {
-		log.Errorf("Could not determine file type: %+v", err)
-		return nil
-	}
-	switch f_type {
-	case ANNEX:
-		fallthrough // deactivated fort the time being
-		/*		APFileC, err := ioutil.ReadAll(blobBuffer)
-				log.Debugf("Annex file:%s", APFileC)
-				if err != nil {
-					log.Errorf("Could not open annex pointer file: %+v", err)
-					return err
-				}
-				Afile, err := gannex.NewAFile(repopath, "", "", APFileC)
-				if err != nil {
-					log.Errorf("Could not get annex file%+v", err)
-					return err
-				}
-				fp, err := Afile.Open()
-				if err != nil {
-					log.Errorf("Could not open annex file: %+v", err)
-					return err
-				}
-				defer fp.Close()
-				bl.Blob = gig.MakeAnnexBlob(fp, Afile.Info.Size())
-				return bl.AddToIndex(server, index, repopath, id)*/
-
-	case TEXT:
-		ct, err := ioutil.ReadAll(blobBuffer)
-		if err != nil {
-			log.Errorf("Could not read text file content:%+v", err)
-			return err
-		}
-		bl.Content = string(ct)
-	case ODML_XML:
-		ct, err := ioutil.ReadAll(blobBuffer)
-		if err != nil {
-			return err
-		}
-		bl.Content = string(ct)
-	}
-	data, err := bl.ToJson()
-	if err != nil {
-		return err
-	}
-	err = AddToIndex(data, server, index, "blob", indexid)
-	return err
-}
-
-func (bl *IndexBlob) IsInIndex() (bool, error) {
-	return false, nil
-}
-
-func AddToIndex(data []byte, server *ElServer, index, doctype string, id gig.SHA1) error {
-	resp, err := server.Index(index, doctype, data, id)
-	if err != nil {
-		return err
-	}
-	resp.Body.Close()
-	return err
-}

+ 0 - 88
vendor/github.com/G-Node/gin-dex/gindex/repo.go

@@ -1,88 +0,0 @@
-package gindex
-
-import (
-	"github.com/G-Node/gig"
-	log "github.com/Sirupsen/logrus"
-)
-
-func IndexRepoWithPath(path, ref string, serv *ElServer, repoid string, reponame string) error {
-	log.Info("Start indexing repository with path: %s", path)
-	rep, err := gig.OpenRepository(path)
-	if err != nil {
-		log.Errorf("Could not open repository: %+v", err)
-		return err
-	}
-	log.Debugf("Opened repository")
-	commits, err := rep.WalkRef(ref,
-		func(comitID gig.SHA1) bool {
-			res, err := serv.HasCommit("commits", GetIndexCommitId(comitID.String(), repoid))
-			if err != nil {
-				log.Errorf("Could not querry commit index: %v", err)
-				return false
-			}
-			return !res
-		})
-	log.Infof("Found %d commits", len(commits))
-
-	for commitid, commit := range commits {
-		err = indexCommit(commit, repoid, commitid, rep, path, reponame, serv, serv.HasBlob)
-	}
-	return nil
-}
-
-func ReIndexRepoWithPath(path, ref string, serv *ElServer, repoid string, reponame string) error {
-	log.Info("Start indexing repository with path: %s", path)
-	rep, err := gig.OpenRepository(path)
-	if err != nil {
-		log.Errorf("Could not open repository: %+v", err)
-		return err
-	}
-	log.Debugf("Opened repository")
-	commits, err := rep.WalkRef(ref,
-		func(comitID gig.SHA1) bool {
-			return true
-		})
-	log.Infof("Found %d commits", len(commits))
-
-	blobs := make(map[gig.SHA1]bool)
-	for commitid, commit := range commits {
-		err = indexCommit(commit, repoid, commitid, rep, path, reponame, serv,
-			func(indexName string, id gig.SHA1) (bool, error) {
-				if !blobs[id] {
-					blobs[id] = true
-					return false, nil
-				}
-				return true, nil
-			})
-	}
-	return nil
-}
-
-func indexCommit(commit *gig.Commit, repoid string, commitid gig.SHA1, rep *gig.Repository,
-	path string, reponame string, serv *ElServer,
-	indexBlob func(string, gig.SHA1) (bool, error)) error {
-	err := NewCommitFromGig(commit, repoid, reponame, commitid).AddToIndex(serv, "commits", commitid)
-	if err != nil {
-		log.Printf("Indexing commit failed:%+v", err)
-	}
-	blobs := make(map[gig.SHA1]*gig.Blob)
-	rep.GetBlobsForCommit(commit, blobs)
-	for blid, blob := range blobs {
-		log.Debugf("Blob %s has Size:%d", blid, blob.Size())
-		hasBlob, err := indexBlob("blobs", GetIndexBlobId(blid.String(), repoid))
-		if err != nil {
-			log.Errorf("Could not querry for blob: %+v", err)
-			return err
-		}
-		if !hasBlob {
-			bpath, _ := GetBlobPath(blid.String(), commitid.String(), path)
-			err = NewBlobFromGig(blob, repoid, blid, commitid.String(), bpath, reponame).AddToIndex(serv, "blobs", path, blid)
-			if err != nil {
-				log.Debugf("Indexing blob failed: %+v", err)
-			}
-		} else {
-			log.Debugf("Blob there :%s", blid)
-		}
-	}
-	return nil
-}

+ 0 - 8
vendor/github.com/G-Node/gin-dex/gindex/search.go

@@ -1,8 +0,0 @@
-package gindex
-
-type Result struct {
-}
-
-func Search(querry string, repos []int64) ([]Result, error) {
-	return nil, nil
-}

+ 0 - 128
vendor/github.com/G-Node/gin-dex/gindex/util.go

@@ -1,128 +0,0 @@
-package gindex
-
-import (
-	"net/http"
-	"io/ioutil"
-	"encoding/json"
-	"io"
-	"fmt"
-	log "github.com/Sirupsen/logrus"
-	"github.com/gogits/go-gogs-client"
-	"github.com/G-Node/gig"
-	"os"
-	"path/filepath"
-	"strings"
-	"crypto/sha1"
-	"regexp"
-	"github.com/G-Node/git-module"
-)
-
-func getParsedBody(r *http.Request, obj interface{}) error {
-	data, err := ioutil.ReadAll(r.Body)
-	r.Body.Close()
-	if err != nil {
-		log.Debugf("Could not read request body: %+v", err)
-		return err
-	}
-	err = json.Unmarshal(data, obj)
-	if err != nil {
-		log.Debugf("Could not unmarshal request: %+v, %s", err, string(data))
-		return err
-	}
-	return nil
-}
-
-func getParsedResponse(resp *http.Response, obj interface{}) error {
-	data, err := ioutil.ReadAll(resp.Body)
-	if err != nil {
-		return err
-	}
-	return json.Unmarshal(data, obj)
-}
-
-func getParsedHttpCall(method, path string, body io.Reader, token, csrfT string, obj interface{}) error {
-	client := &http.Client{}
-	req, _ := http.NewRequest(method, path, body)
-	req.Header.Set("Cookie", fmt.Sprintf("i_like_gogits=%s; _csrf=%s", token, csrfT))
-	resp, err := client.Do(req)
-	if err != nil {
-		return err
-	}
-	defer resp.Body.Close()
-	if (resp.StatusCode != http.StatusOK) {
-		return fmt.Errorf("%s: %d, %s", resp.Status, resp.StatusCode, req.URL)
-	}
-	return getParsedResponse(resp, obj)
-}
-
-// Encodes a given map into a struct.
-// Lazyly Uses json package instead of reflecting directly
-func map2struct(in interface{}, out interface{}) error {
-	data, err := json.Marshal(in)
-	if err != nil {
-		return err
-	}
-	return json.Unmarshal(data, out)
-}
-
-// Find gin repos under a certain directory, to which the authenticated user has access
-func findRepos(rpath string, rbd *ReIndexRequest, gins *GinServer) ([]*gogs.Repository, error) {
-	var repos [] *gogs.Repository
-	err := filepath.Walk(rpath, func(path string, info os.FileInfo, err error) error {
-		if ! info.IsDir() {
-			return nil
-		}
-		repo, err := gig.OpenRepository(path)
-		if err != nil {
-			return nil
-		}
-		gRepo, err := hasRepoAccess(repo, rbd, gins)
-		if err != nil {
-			log.Debugf("no acces to repo:%+v", err)
-			return filepath.SkipDir
-		}
-		repos = append(repos, gRepo)
-		return filepath.SkipDir
-	})
-	return repos, err
-}
-
-func hasRepoAccess(repository *gig.Repository, rbd *ReIndexRequest, gins *GinServer) (*gogs.Repository, error) {
-	splPath := strings.Split(repository.Path, string(filepath.Separator))
-	if ! (len(splPath) > 2) {
-		return nil, fmt.Errorf("not a repo path %s", repository.Path)
-	}
-	owner := splPath[len(splPath)-2]
-	name := strings.TrimSuffix(splPath[len(splPath)-1], ".git")
-	gRepo := gogs.Repository{}
-	err := getParsedHttpCall(http.MethodGet, fmt.Sprintf("%s/api/v1/repos/%s/%s",
-		gins.URL, owner, name), nil, rbd.Token, rbd.CsrfT, &gRepo)
-	if err != nil {
-		return nil, err
-	}
-	return &gRepo, nil
-}
-
-func GetIndexCommitId(id, repoid string) gig.SHA1 {
-	return sha1.Sum([]byte(repoid + id))
-}
-
-func GetIndexBlobId(id, repoid string) gig.SHA1 {
-	return sha1.Sum([]byte(repoid + id))
-}
-
-func GetBlobPath(blid, cid, path string) (string, error) {
-	cmd := git.NewCommand("ls-tree", "-r", cid)
-	res, err := cmd.RunInDirBytes(path)
-	if err != nil {
-		return "", err
-	}
-	pattern := fmt.Sprintf("%s\\s+(.+)", blid)
-	re := regexp.MustCompile(pattern)
-	line_match := re.FindStringSubmatch(string(res))
-	if len(line_match) > 1 {
-		return line_match[1], nil
-	} else {
-		return "", fmt.Errorf("Not found")
-	}
-}

+ 0 - 54
vendor/github.com/G-Node/gin-dex/main.go

@@ -1,54 +0,0 @@
-package main
-
-import (
-	"github.com/docopt/docopt-go"
-	"os"
-	"github.com/G-Node/gin-dex/gindex"
-	"net/http"
-	log  "github.com/Sirupsen/logrus"
-)
-
-func main() {
-	usage := `gin-dex.
-Usage:
-  gin-dex [--eladress=<eladress> --eluser=<eluser> --elpw=<elpw> --rpath=<rpath> --gin=<gin> --port=<port> --debug ]
-
-Options:
-  --eladress=<eladress>           Adress of the elastic server [default: http://localhost:9200]
-  --eluser=<eluser>               Elastic user [default: elastic]
-  --elpw=<elpw>                   Elastic password [default: changeme]
-  --port=<port>                   Server port [default: 8099]
-  --gin=<gin>                     Gin Server Adress [default: https://gin.g-node.org]
-  --rpath=<rpath>                 Path to the repositories [default: /repos]
-  --debug                         Whether debug messages shall be printed
- `
-	args, err := docopt.Parse(usage, nil, true, "gin-dex0.1a", false)
-	if err != nil {
-		log.Printf("Error while parsing command line: %+v", err)
-		os.Exit(-1)
-	}
-	uname := args["--eluser"].(string)
-	pw := args["--elpw"].(string)
-	els := gindex.NewElServer(args["--eladress"].(string), &uname, &pw)
-	gin := &gindex.GinServer{URL: args["--gin"].(string)}
-	rpath := args["--rpath"].(string)
-
-	http.HandleFunc("/index", func(w http.ResponseWriter, r *http.Request) {
-		gindex.IndexH(w, r, els, &rpath)
-	})
-
-	http.HandleFunc("/search", func(w http.ResponseWriter, r *http.Request) {
-		gindex.SearchH(w, r, els, gin)
-	})
-
-	http.HandleFunc("/reindex", func(w http.ResponseWriter, r *http.Request) {
-		gindex.ReindexH(w, r, els, gin, &rpath)
-	})
-
-
-	if args["--debug"].(bool) {
-		log.SetLevel(log.DebugLevel)
-		log.SetFormatter(&log.TextFormatter{ForceColors: true})
-	}
-	log.Fatal(http.ListenAndServe(":"+args["--port"].(string), nil))
-}

+ 0 - 6
vendor/vendor.json

@@ -8,12 +8,6 @@
 			"revision": "6d784b40b534eb9a398247e27942e705de539b20",
 			"revisionTime": "2017-10-25T13:28:53Z"
 		},
-		{
-			"checksumSHA1": "LnRv1Ks+MlNEtH5YyfzN7YDwchY=",
-			"path": "github.com/G-Node/gin-dex",
-			"revision": "d4994f3bb1774be302aa9be2fdd4db28b454b01e",
-			"revisionTime": "2017-11-17T12:52:54Z"
-		},
 		{
 			"checksumSHA1": "/nx4C9e6SWnuATeRNXMyVaEOwFw=",
 			"path": "github.com/G-Node/gin-dex/gindex",