Просмотр исходного кода

Fix plugins

Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
Vadim Markovtsev 7 лет назад
Родитель
Сommit
4d64c344cd
3 измененных файлов с 51 добавлено и 10 удалено
  1. 2 4
      .travis.yml
  2. 43 0
      core.go
  3. 6 6
      internal/plumbing/identity/identity.go

+ 2 - 4
.travis.yml

@@ -41,7 +41,6 @@ before_install:
   - wget -O protoc.zip https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip
   - unzip -d ~/.local protoc.zip && rm protoc.zip
   - go get -v github.com/golang/lint/golint
-  - go get -v github.com/haya14busa/goverage
   - git clone --depth 1 https://github.com/src-d/go-git $GOPATH/src/gopkg.in/src-d/go-git.v4
   - wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py --user && rm get-pip.py
   - export PATH=~/usr/bin:$PATH
@@ -58,9 +57,8 @@ script:
   - set -e
   - go vet -tags tensorflow ./...
   - golint -set_exit_status ./...
-  - printf '#!/bin/sh\nshift\ngo test -tags tensorflow $@\n' > gotag
-  - chmod +x gotag
-  - goverage -go-binary=$(pwd)/gotag -v -cpu=1,2 -coverprofile=coverage.txt -covermode=count gopkg.in/src-d/hercules.v4/...
+  - if [[ $TRAVIS_GO_VERSION != 1.9.* ]]; then go test -coverpkg=all -v -cpu=1,2 -coverprofile=coverage.txt -covermode=count gopkg.in/src-d/hercules.v4/...; fi
+  - if [[ $TRAVIS_GO_VERSION = 1.9.* ]]; then go test -v -cpu=1,2 gopkg.in/src-d/hercules.v4/...; fi
   - $GOPATH/bin/hercules version
   - $GOPATH/bin/hercules --burndown --couples --quiet --pb https://github.com/src-d/hercules > 1.pb
   - cp 1.pb 2.pb

+ 43 - 0
core.go

@@ -4,6 +4,9 @@ import (
 	git "gopkg.in/src-d/go-git.v4"
 	"gopkg.in/src-d/go-git.v4/plumbing/object"
 	"gopkg.in/src-d/hercules.v4/internal/core"
+	"gopkg.in/src-d/hercules.v4/internal/plumbing"
+	"gopkg.in/src-d/hercules.v4/internal/plumbing/identity"
+	"gopkg.in/src-d/hercules.v4/internal/plumbing/uast"
 	"gopkg.in/src-d/hercules.v4/leaves"
 )
 
@@ -81,6 +84,46 @@ type PipelineItemRegistry = core.PipelineItemRegistry
 // Registry contains all known pipeline item types.
 var Registry = core.Registry
 
+const (
+	// DependencyAuthor is the name of the dependency provided by identity.Detector.
+	DependencyAuthor = identity.DependencyAuthor
+	// DependencyBlobCache identifies the dependency provided by BlobCache.
+	DependencyBlobCache = plumbing.DependencyBlobCache
+	// DependencyDay is the name of the dependency which DaysSinceStart provides - the number
+	// of days since the first commit in the analysed sequence.
+	DependencyDay = plumbing.DependencyDay
+	// DependencyFileDiff is the name of the dependency provided by FileDiff.
+	DependencyFileDiff = plumbing.DependencyFileDiff
+	// DependencyTreeChanges is the name of the dependency provided by TreeDiff.
+	DependencyTreeChanges = plumbing.DependencyTreeChanges
+	// DependencyUastChanges is the name of the dependency provided by Changes.
+	DependencyUastChanges = uast.DependencyUastChanges
+	// DependencyUasts is the name of the dependency provided by Extractor.
+	DependencyUasts = uast.DependencyUasts
+	// FactCommitsByDay contains the mapping between day indices and the corresponding commits.
+	FactCommitsByDay = plumbing.FactCommitsByDay
+	// FactIdentityDetectorPeopleCount is the name of the fact which is inserted in
+	// identity.Detector.Configure(). It is equal to the overall number of unique authors
+	// (the length of ReversedPeopleDict).
+	FactIdentityDetectorPeopleCount = identity.FactIdentityDetectorPeopleCount
+	// FactIdentityDetectorPeopleDict is the name of the fact which is inserted in
+	// identity.Detector.Configure(). It corresponds to identity.Detector.PeopleDict - the mapping
+	// from the signatures to the author indices.
+	FactIdentityDetectorPeopleDict = identity.FactIdentityDetectorPeopleDict
+	// FactIdentityDetectorReversedPeopleDict is the name of the fact which is inserted in
+	// identity.Detector.Configure(). It corresponds to identity.Detector.ReversedPeopleDict -
+	// the mapping from the author indices to the main signature.
+	FactIdentityDetectorReversedPeopleDict = identity.FactIdentityDetectorReversedPeopleDict
+)
+
+// FileDiffData is the type of the dependency provided by plumbing.FileDiff.
+type FileDiffData = plumbing.FileDiffData
+
+// CountLines returns the number of lines in a *object.Blob.
+func CountLines(file *object.Blob) (int, error) {
+	return plumbing.CountLines(file)
+}
+
 func init() {
 	// hack to link with .leaves
 	_ = leaves.BurndownAnalysis{}

+ 6 - 6
internal/plumbing/identity/identity.go

@@ -23,28 +23,28 @@ type Detector struct {
 
 const (
 	// AuthorMissing is the internal author index which denotes any unmatched identities
-	// (IdentityDetector.Consume()).
+	// (Detector.Consume()).
 	AuthorMissing = (1 << 18) - 1
 	// AuthorMissingName is the string name which corresponds to AuthorMissing.
 	AuthorMissingName = "<unmatched>"
 
 	// FactIdentityDetectorPeopleDict is the name of the fact which is inserted in
-	// IdentityDetector.Configure(). It corresponds to IdentityDetector.PeopleDict - the mapping
+	// Detector.Configure(). It corresponds to Detector.PeopleDict - the mapping
 	// from the signatures to the author indices.
 	FactIdentityDetectorPeopleDict = "IdentityDetector.PeopleDict"
 	// FactIdentityDetectorReversedPeopleDict is the name of the fact which is inserted in
-	// IdentityDetector.Configure(). It corresponds to IdentityDetector.ReversedPeopleDict -
+	// Detector.Configure(). It corresponds to Detector.ReversedPeopleDict -
 	// the mapping from the author indices to the main signature.
 	FactIdentityDetectorReversedPeopleDict = "IdentityDetector.ReversedPeopleDict"
 	// ConfigIdentityDetectorPeopleDictPath is the name of the configuration option
-	// (IdentityDetector.Configure()) which allows to set the external PeopleDict mapping from a file.
+	// (Detector.Configure()) which allows to set the external PeopleDict mapping from a file.
 	ConfigIdentityDetectorPeopleDictPath = "IdentityDetector.PeopleDictPath"
 	// FactIdentityDetectorPeopleCount is the name of the fact which is inserted in
-	// IdentityDetector.Configure(). It is equal to the overall number of unique authors
+	// Detector.Configure(). It is equal to the overall number of unique authors
 	// (the length of ReversedPeopleDict).
 	FactIdentityDetectorPeopleCount = "IdentityDetector.PeopleCount"
 
-	// DependencyAuthor is the name of the dependency provided by IdentityDetector.
+	// DependencyAuthor is the name of the dependency provided by Detector.
 	DependencyAuthor = "author"
 )