Skip to content

Commit

Permalink
Merge edce2e9 into 75cd5b2
Browse files Browse the repository at this point in the history
  • Loading branch information
rflaperuta committed Oct 11, 2019
2 parents 75cd5b2 + edce2e9 commit 3715846
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,14 @@ You can choose to ignore files by specifying the language scope for your project
scopeconfig:
- scope: go
- scope: node
- scope: idea
```

Talisman is configured to ignore certain files based on the specified scope. For example, mentioning the node scope in the scopeconfig will prevent talisman from scanning files such as the yarn.lock or package-lock.json.

You can specify multiple scopes.

Currently .talismanrc only supports scopeconfig support for go and node. Other scopes will be added shortly.
Currently .talismanrc has scopeconfig support for go, node and IntelliJ Idea. Other scopes will be added shortly.

<br/><i>
**Note**: The use of .talismanignore has been deprecated. File .talismanrc replaces it because:
Expand Down
13 changes: 8 additions & 5 deletions detector/ignores_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,26 @@ func TestIgnoreAdditionsByScope(t *testing.T) {
file3 := testAddition("java.lock")
file4 := testAddition("Gopkg.lock")
file5 := testAddition("vendors/abc")
additions := []gitrepo.Addition{file1, file2, file3, file4, file5}
file6 := testAddition(".idea/asd")
additions := []git_repo.Addition{file1, file2, file3, file4, file5, file6}

scopesToIgnore := []string{"node", "go"}
scopesToIgnore := []string{"node", "go", "idea"}
talismanRCIgnoreConfig := CreateTalismanRCIgnoreWithScopeIgnore(scopesToIgnore)

nodeIgnores := []string{"node.lock", "*yarn.lock"}
javaIgnores := []string{"java.lock"}
goIgnores := []string{"go.lock", "Gopkg.lock", "vendors/"}
scopesMap := map[string] []string {"node": nodeIgnores, "java":javaIgnores, "go": goIgnores}
ideaIgnores := []string{".idea/"}
scopesMap := map[string][]string{"node": nodeIgnores, "java": javaIgnores, "go": goIgnores, "idea": ideaIgnores}

filteredAdditions := IgnoreAdditionsByScope(additions, talismanRCIgnoreConfig, scopesMap);
filteredAdditions := IgnoreAdditionsByScope(additions, talismanRCIgnoreConfig, scopesMap)

assert.NotContains(t, filteredAdditions, file1)
assert.NotContains(t, filteredAdditions, file2)
assert.Contains(t, filteredAdditions, file3)
assert.NotContains(t, filteredAdditions, file4)
assert.NotContains(t, filteredAdditions, file5)
assert.NotContains(t, filteredAdditions, file6)
}

//Need to work on this test case as it deals with comments and talismanrc does not deal in comments
Expand Down Expand Up @@ -156,7 +159,7 @@ func CreateTalismanRCIgnoreWithScopeIgnore(scopesToIgnore []string) TalismanRCIg
scopeConfigs = append(scopeConfigs, scopeIgnoreConfig)
}

talismanRCIgnore := TalismanRCIgnore{ ScopeConfig: scopeConfigs}
talismanRCIgnore := TalismanRCIgnore{ScopeConfig: scopeConfigs}
return talismanRCIgnore
}

Expand Down
5 changes: 3 additions & 2 deletions runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ func (r *Runner) RunChecksumCalculator(fileNamePatterns []string) int {
func (r *Runner) doRun() {
rcConfigIgnores := detector.ReadConfigFromRCFile(readRepoFile())
scopeMap := getScopeConfig()
additionsToScan := detector.IgnoreAdditionsByScope(r.additions, rcConfigIgnores, scopeMap);
additionsToScan := detector.IgnoreAdditionsByScope(r.additions, rcConfigIgnores, scopeMap)
detector.DefaultChain().Test(additionsToScan, rcConfigIgnores, r.results)
}

func getScopeConfig() map[string][]string {
scopeConfig := map[string][]string{
"node": {"yarn.lock", "package-lock.json", "node_modules/"},
"go": {"makefile", "go.mod", "go.sum", "Gopkg.toml", "Gopkg.lock", "glide.yaml", "glide.lock", "vendor/"},
"go": {"makefile", "go.mod", "go.sum", "Gopkg.toml", "Gopkg.lock", "glide.yaml", "glide.lock", "vendor/"},
"idea": {".idea/"},
}
return scopeConfig
}
Expand Down

0 comments on commit 3715846

Please sign in to comment.