Parcourir la source

Merge pull request #109 from vmarkovtsev/master

Dirs -> prefixes
Vadim Markovtsev il y a 6 ans
Parent
commit
ac5241ffea
4 fichiers modifiés avec 32 ajouts et 12 suppressions
  1. 1 1
      .travis.yml
  2. 11 0
      README.md
  3. 18 9
      internal/plumbing/tree_diff.go
  4. 2 2
      internal/plumbing/tree_diff_test.go

+ 1 - 1
.travis.yml

@@ -75,7 +75,7 @@ script:
   - (cd contrib/_plugin_example && make)
   - $GOPATH/bin/hercules --burndown --burndown-files --burndown-people --couples --quiet https://github.com/src-d/hercules | python3 labours.py -m all -o out --backend Agg --disable-projector
   - $GOPATH/bin/hercules --burndown --burndown-files --burndown-people --couples --quiet --pb https://github.com/src-d/hercules | python3 labours.py -f pb -m all -o out --backend Agg --disable-projector
-  - $GOPATH/bin/hercules --sentiment --quiet --languages Python https://github.com/src-d/hercules
+  - $GOPATH/bin/hercules --sentiment --quiet --languages Python https://github.com/src-d/hercules > /dev/null
   - set +e
   - if [[ $TRAVIS_GO_VERSION = 1.10.* ]]; then bash <(curl -s https://codecov.io/bash); fi
 

+ 11 - 0
README.md

@@ -48,6 +48,15 @@ Replace `$GOPATH` with `%GOPATH%` on Windows.
 [Apache 2.0](LICENSE.md)
 
 ### Usage
+
+The most useful and reliably up-to-date command line reference:
+
+```
+hercules --help
+```
+
+Some examples:
+
 ```
 # Use "memory" go-git backend and display the burndown plot. "memory" is the fastest but the repository's git data must fit into RAM.
 hercules --burndown https://github.com/src-d/go-git | python3 labours.py -m project --resample month
@@ -307,6 +316,8 @@ contain `"type"` which reflects the plot kind.
 
 ### Caveats
 
+1. Processing all the commits may fail in some rare cases. If you get an error similar to https://github.com/src-d/hercules/issues/106
+please report there and specify `--first-parent` as a workaround.
 1. Currently, go-git's file system storage backend is considerably slower than the in-memory one,
 so you should clone repos instead of reading them from disk whenever possible. Please note that the
 in-memory storage may require much RAM, for example, the Linux kernel takes over 200GB in 2017.

+ 18 - 9
internal/plumbing/tree_diff.go

@@ -33,9 +33,10 @@ const (
 	// ConfigTreeDiffEnableBlacklist is the name of the configuration option
 	// (TreeDiff.Configure()) which allows to skip blacklisted directories.
 	ConfigTreeDiffEnableBlacklist = "TreeDiff.EnableBlacklist"
-	// ConfigTreeDiffBlacklistedDirs s the name of the configuration option
-	// (TreeDiff.Configure()) which allows to set blacklisted directories.
-	ConfigTreeDiffBlacklistedDirs = "TreeDiff.BlacklistedDirs"
+	// ConfigTreeDiffBlacklistedPrefixes s the name of the configuration option
+	// (TreeDiff.Configure()) which allows to set blacklisted path prefixes -
+	// directories or complete file names.
+	ConfigTreeDiffBlacklistedPrefixes = "TreeDiff.BlacklistedPrefixes"
 	// ConfigTreeDiffLanguages is the name of the configuration option (TreeDiff.Configure())
 	// which sets the list of programming languages to analyze. Language names are at
 	// https://doc.bblf.sh/languages.html Names are joined with a comma ",".
@@ -45,7 +46,13 @@ const (
 	allLanguages = "all"
 )
 
-var defaultBlacklistedDirs = []string{"vendor/", "vendors/", "node_modules/", "package-lock.json"}
+// defaultBlacklistedPrefixes is the list of file path prefixes which should be skipped by default.
+var defaultBlacklistedPrefixes = []string{
+	"vendor/",
+	"vendors/",
+	"node_modules/",
+	"package-lock.json",
+}
 
 // Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.
 func (treediff *TreeDiff) Name() string {
@@ -75,11 +82,13 @@ func (treediff *TreeDiff) ListConfigurationOptions() []core.ConfigurationOption
 		Flag:        "skip-blacklist",
 		Type:        core.BoolConfigurationOption,
 		Default:     false}, {
-		Name:        ConfigTreeDiffBlacklistedDirs,
-		Description: "List of blacklisted directories. Separated by comma \",\".",
-		Flag:        "blacklisted-dirs",
+		Name:        ConfigTreeDiffBlacklistedPrefixes,
+		Description: "List of blacklisted path prefixes (e.g. directories or specific files). " +
+			"Values are in the UNIX format (\"path/to/x\"). Values should *not* start with \"/\". " +
+			"Separated with commas \",\".",
+		Flag:        "blacklisted-prefixes",
 		Type:        core.StringsConfigurationOption,
-		Default:     defaultBlacklistedDirs}, {
+		Default:     defaultBlacklistedPrefixes}, {
 		Name:        ConfigTreeDiffLanguages,
 		Description: fmt.Sprintf(
 			"List of programming languages to analyze. Separated by comma \",\". " +
@@ -95,7 +104,7 @@ func (treediff *TreeDiff) ListConfigurationOptions() []core.ConfigurationOption
 // Configure sets the properties previously published by ListConfigurationOptions().
 func (treediff *TreeDiff) Configure(facts map[string]interface{}) {
 	if val, exist := facts[ConfigTreeDiffEnableBlacklist]; exist && val.(bool) {
-		treediff.SkipDirs = facts[ConfigTreeDiffBlacklistedDirs].([]string)
+		treediff.SkipDirs = facts[ConfigTreeDiffBlacklistedPrefixes].([]string)
 	}
 	if val, exists := facts[ConfigTreeDiffLanguages].(string); exists {
 		treediff.Languages = map[string]bool{}

+ 2 - 2
internal/plumbing/tree_diff_test.go

@@ -133,8 +133,8 @@ func TestTreeDiffConsumeSkip(t *testing.T) {
 	td = fixtureTreeDiff()
 	td.previousTree, _ = prevCommit.Tree()
 	td.Configure(map[string]interface{}{
-		ConfigTreeDiffEnableBlacklist: true,
-		ConfigTreeDiffBlacklistedDirs: []string{"vendor/"},
+		ConfigTreeDiffEnableBlacklist:     true,
+		ConfigTreeDiffBlacklistedPrefixes: []string{"vendor/"},
 	})
 	res, err = td.Consume(deps)
 	assert.Nil(t, err)