Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/fix builder paths #75

Merged
merged 3 commits into from
Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builders/maven.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (builder *MavenBuilder) DiscoverModules(dir string) ([]config.ModuleConfig,
_, err := os.Stat(filepath.Join(dir, "pom.xml"))
if err == nil {
// Root pom found; parse and return
artifactName := filepath.Dir(dir)
artifactName := filepath.Base(filepath.Dir(dir))
var rootPom POMFile
if err := parseLoggedWithUnmarshaller(mavenLogger, filepath.Join(dir, "pom.xml"), &rootPom, xml.Unmarshal); err == nil {
if rootPom.Name != "" {
Expand Down
1 change: 1 addition & 0 deletions builders/nodejs.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func (builder *NodeJSBuilder) DiscoverModules(dir string) ([]config.ModuleConfig
}

nodejsLogger.Debugf("Found NodeJS package: %s (%s)", path, moduleName)
path, _ = filepath.Rel(dir, path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if you didn't mutate path, and instead gave this a different name (e.g. manifestPath).

moduleConfigs = append(moduleConfigs, config.ModuleConfig{
Name: moduleName,
Path: path,
Expand Down
3 changes: 2 additions & 1 deletion builders/ruby.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (builder *RubyBuilder) DiscoverModules(dir string) ([]config.ModuleConfig,
}
moduleConfigs := make([]config.ModuleConfig, len(gemFilePaths))
for i, path := range gemFilePaths {
gemName := filepath.Dir(path)
gemName := filepath.Base(filepath.Dir(path))
// infer title from *.gemspec in directory if exists
gemSpecs, err := doublestar.Glob(filepath.Join(filepath.Dir(path), "*.gemspec"))
if err == nil && len(gemSpecs) > 0 {
Expand All @@ -175,6 +175,7 @@ func (builder *RubyBuilder) DiscoverModules(dir string) ([]config.ModuleConfig,
}
}
}
path, _ = filepath.Rel(dir, path)
moduleConfigs[i] = config.ModuleConfig{
Name: gemName,
Path: path,
Expand Down
2 changes: 1 addition & 1 deletion cmd/fossa/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func doInit(conf *config.CLIConfig, overwrite bool, includeAll bool) error {
// Filter suspicious modules
var filteredModuleConfigs []config.ModuleConfig
for _, c := range conf.Modules {
if matched, err := regexp.MatchString("(docs?/|test|example|vendor/)", c.Path); err != nil || matched != true {
if matched, err := regexp.MatchString("(docs?/|test|example|vendor/|node_modules/|.srclib-cache/|spec/|Godeps/|.git/|bower_components/)", c.Path); err != nil || matched != true {
filteredModuleConfigs = append(filteredModuleConfigs, c)
} else {
initLogger.Warningf("Filtering out suspicious module: %s (%s)", c.Name, c.Path)
Expand Down