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

[#222] Ignore comments from .gitignore file #235

Merged
merged 1 commit into from
Jan 19, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion bin/pdd
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ https://github.com/cqfn/pdd/blob/master/README.md"

if opts['skip-gitignore'] && File.exist?('.gitignore')
cfg = File.new('.gitignore')
body = File.read(cfg)
body = ''
File.foreach(cfg) { |line| body << line unless line.start_with?('#') }
extra = body.split(/\s+/).map(&:strip)
opts['skip-gitignore'] = extra
PDD.log.info "Found #{body.split("\n").length} lines in #{File.absolute_path(cfg)}"
Expand Down
51 changes: 46 additions & 5 deletions features/cli.feature
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,67 @@ Feature: Command Line Processing
Then Exit code is zero
And XML file "out.xml" matches "/puzzles[count(puzzle)=0]"

Scenario: Excluding unnecessary files from gitignore
Given this step says to skip
And I have a "a/b/c/test.txt" file with content:
Scenario: Excluding unnecessary files from .gitignore
Given I have a "a/b/c/test.txt" file with content:
"""
~~ @todo #44 some puzzle to be excluded
"""
And I have a "f/g/h/hello.md" file with content:
"""
~~ @todo #44 some puzzle to be excluded as well
~~ @todo #45 some puzzle to be excluded as well
"""
And I have a ".gitignore" file with content:
"""
# This is the list of patterns
a/**/*
!/f
"""
When I run bin/pdd with "> out.xml"
When I run bin/pdd with "--skip-gitignore > out.xml"
Then Exit code is zero
And XML file "out.xml" matches "/puzzles/puzzle[./ticket='45']"
And XML file "out.xml" matches "/puzzles[count(puzzle)=1]"

Scenario: Excluding unnecessary files from .gitignore and ignore comments
Given I have a "a/b/c/test.txt" file with content:
"""
~~ @todo #44 some puzzle to be excluded
"""
And I have a "f/g/h/hello.md" file with content:
"""
~~ @todo #45 some puzzle to be excluded as well
"""
And I have a ".gitignore" file with content:
"""
# This is the list of patterns
# a/**/*
f/**/*
"""
When I run bin/pdd with "--skip-gitignore > out.xml"
Then Exit code is zero
And XML file "out.xml" matches "/puzzles/puzzle[./ticket='44']"
And XML file "out.xml" matches "/puzzles[count(puzzle)=1]"

Scenario: Files from .gitignore is not excluded by default
Given I have a "a/b/c/test.txt" file with content:
"""
~~ @todo #44 some puzzle to be excluded
"""
And I have a "f/g/h/hello.md" file with content:
"""
~~ @todo #45 some puzzle to be excluded as well
"""
And I have a ".gitignore" file with content:
"""
# This is the list of patterns
a/**/*
!/f
"""
When I run bin/pdd with "> out.xml"
Then Exit code is zero
And XML file "out.xml" matches "/puzzles/puzzle[./ticket='44']"
And XML file "out.xml" matches "/puzzles/puzzle[./ticket='45']"
And XML file "out.xml" matches "/puzzles[count(puzzle)=2]"

Scenario: Rejects unknown options
Given I have a "test.txt" file with content:
"""
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
FileUtils.rm_rf(@dir)
end

Given(/skip/) do
Given(/skip test/) do
skip_this_scenario
end

Expand Down