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

Add flag that allows you to easily search all subdirectories #210

Merged
merged 2 commits into from
Sep 26, 2019

Conversation

tduffield
Copy link
Contributor

@tduffield tduffield commented Sep 25, 2019

Description

There may be situations where it is undesirable or unreasonable to individually specify all the directories you want to scan. This change adds the --include-all-subdirectories flag which will tell license scout to also look for dependency manager files in nested subdirectories of the configured directory.

In practice, you could run the following command in the root of a project repository and feel pretty confident that you have identified all of the dependencies of all of the software in that project.

license_scout --include-sub-directories

Related Issue

Addresses #208

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

@tduffield tduffield requested a review from a team as a code owner September 25, 2019 18:15
@tduffield tduffield added the Expeditor: Bump Version Minor Used by github.minor_bump_labels to bump the Minor version number. label Sep 25, 2019
@nellshamrell
Copy link
Contributor

Just tested this out. Built the gem and installed it, then I did this:

git clone https://github.com/inspec/inspec
cd inspec
bundle install
mkdir some_sub_dir
mv ./habitat some_sub_dir
license_scout --include-sub-directories  

This is currently failing with this error:

nell@nell-ThinkPad-P1:~/inspec$ license_scout --include-sub-directories
WARN: [cli] Could not find /home/nell/inspec/.license_scout.yml -- skipping
INFO: [collector] Found Gemfile and Gemfile.lock files in /home/nell/inspec
INFO: [collector] Found habitat/plan.sh file in /home/nell/inspec/some_sub_dir
INFO: [collector] Found plan.sh file in /home/nell/inspec/some_sub_dir/habitat
INFO: [collector] Collecting licenses for ruby dependencies found in /home/nell/inspec/Gemfile and Gemfile.lock files
INFO: [collector] Collecting licenses for habitat dependencies found in /home/nell/inspec/some_sub_dir/habitat/plan.sh file
Traceback (most recent call last):
        11: from /home/nell/.rbenv/versions/2.6.4/bin/license_scout:23:in `<main>'
        10: from /home/nell/.rbenv/versions/2.6.4/bin/license_scout:23:in `load'
         9: from /home/nell/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/license_scout-2.4.5/bin/license_scout:23:in `<top (required)>'
         8: from /home/nell/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/license_scout-2.4.5/lib/license_scout/cli.rb:120:in `run'
         7: from /home/nell/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/license_scout-2.4.5/lib/license_scout/collector.rb:35:in `collect'
         6: from /home/nell/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/license_scout-2.4.5/lib/license_scout/collector.rb:35:in `each'
         5: from /home/nell/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/license_scout-2.4.5/lib/license_scout/collector.rb:35:in `block in collect'
         4: from /home/nell/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/license_scout-2.4.5/lib/license_scout/collector.rb:52:in `collect_licenses_from'
         3: from /home/nell/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/license_scout-2.4.5/lib/license_scout/dependency_manager/habitat.rb:47:in `dependencies'
         2: from /home/nell/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/license_scout-2.4.5/lib/license_scout/dependency_manager/habitat.rb:85:in `pkg_deps'
         1: from /home/nell/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/mixlib-shellout-2.4.4/lib/mixlib/shellout.rb:284:in `error!'
/home/nell/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/mixlib-shellout-2.4.4/lib/mixlib/shellout.rb:297:in `invalid!': Expected process to exit with [0], but received '1' (Mixlib::ShellOut::ShellCommandFailed)
---- Begin output of bash -ec 'export PLAN_CONTEXT="/home/nell/inspec/some_sub_dir/habitat"; source /home/nell/inspec/some_sub_dir/habitat/plan.sh; echo ${pkg_deps[*]}' ----
STDOUT: 
STDERR: cat: /home/nell/inspec/some_sub_dir/habitat/../VERSION: No such file or directory
---- End output of bash -ec 'export PLAN_CONTEXT="/home/nell/inspec/some_sub_dir/habitat"; source /home/nell/inspec/some_sub_dir/habitat/plan.sh; echo ${pkg_deps[*]}' ----
Ran bash -ec 'export PLAN_CONTEXT="/home/nell/inspec/some_sub_dir/habitat"; source /home/nell/inspec/some_sub_dir/habitat/plan.sh; echo ${pkg_deps[*]}' returned 1

Digging into it a bit, but is there anything that looks obvious to you from that error output?

@nellshamrell
Copy link
Contributor

Nevermind! some_sub_dir needed a VERSION file in it. This works!

@tduffield tduffield force-pushed the tduffield/include-subdirs branch from 2c50772 to fa872f6 Compare September 26, 2019 18:27
There may be situations where it is undesirable or unreasonable to
individually specify all the directories you want to scan. This change
adds the `--include-all-subdirectories` flag which will tell license
scout to also look for dependency manager files in nested
subdirectories of the configured directory.

In practice, you could run the following command in the root of a
project repository and feel pretty confident that you have indentified
all of the dependencies of all of the software in that project.

```
license_scout --include-sub-directories
```

Signed-off-by: Tom Duffield <[email protected]>
@tduffield tduffield force-pushed the tduffield/include-subdirs branch from fa872f6 to 520f71b Compare September 26, 2019 19:00
Copy link
Contributor

@IanMadd IanMadd left a comment

Choose a reason for hiding this comment

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

This should clean the readme text up a bit.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Clean up the documentation in the README

Co-Authored-By: Ian Maddaus <[email protected]>
Signed-off-by: Tom Duffield <[email protected]>
@tduffield tduffield force-pushed the tduffield/include-subdirs branch from 671133e to b88f82c Compare September 26, 2019 20:02
@tduffield tduffield merged commit d6b6151 into master Sep 26, 2019
@chef-expeditor chef-expeditor bot deleted the tduffield/include-subdirs branch September 26, 2019 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Expeditor: Bump Version Minor Used by github.minor_bump_labels to bump the Minor version number.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants