Skip to content

Commit

Permalink
Add glob test and fix prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Carter committed Oct 15, 2020
1 parent 7d3559c commit 1438034
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ci/release_notes.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Empty - please add release notes here
## Bug Fix
- Fix `prepare` command
16 changes: 12 additions & 4 deletions src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ impl Workspace {
let head_patterns: Vec<_> = env.head_file_patterns().collect();
for file_buf in env.propagated_files() {
let file = file_buf.to_str().unwrap().to_string();
if !ignore_list.iter().any(|p| p.matches(&file))
&& !head_patterns.iter().any(|p| p.matches(&file))
if !ignore_list
.iter()
.any(|p| p.matches_with(&file, Self::match_options()))
&& !head_patterns
.iter()
.any(|p| p.matches_with(&file, Self::match_options()))
{
std::fs::remove_file(file_buf).expect("Couldn't remove file");
}
Expand All @@ -86,8 +90,12 @@ impl Workspace {
let patterns: Vec<_> = env.propagated_file_patterns().collect();
for (ident, state) in env_state.files.iter() {
let name = ident.name();
if patterns.iter().any(|p| p.matches(&name))
&& !head_patterns.iter().any(|p| p.matches(&name))
if patterns
.iter()
.any(|p| p.matches_with(&name, Self::match_options()))
&& !head_patterns
.iter()
.any(|p| p.matches_with(&name, Self::match_options()))
{
repo.checkout_file_from(&name, &state.from_commit)?;
}
Expand Down
16 changes: 16 additions & 0 deletions test/fixtures/glob/cepler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
environments:
subdir:
latest:
- test/fixtures/glob/**/*.yml
testflight:
latest:
- test/fixtures/glob/*.yml
- test/fixtures/glob/subdir/shared.yml
- test/fixtures/glob/subdir/testflight.yml
staging:
passed: testflight
propagated:
- test/fixtures/glob/*.yml
- test/fixtures/glob/subdir/shared.yml
latest:
- test/fixtures/glob/subdir/staging.yml
1 change: 1 addition & 0 deletions test/fixtures/glob/file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
file: {}
1 change: 1 addition & 0 deletions test/fixtures/glob/subdir/shared.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shared: {}
1 change: 1 addition & 0 deletions test/fixtures/glob/subdir/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
staging: {}
1 change: 1 addition & 0 deletions test/fixtures/glob/subdir/testflight.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
testflight: {}
30 changes: 30 additions & 0 deletions test/integration/glob.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bats

load "helpers"

setup_file() {
echo "Preparing 'glob'"
prepare_test "glob"
}

teardown_file() {
echo "Tearing down 'glob'"
reset_repo_state
}

@test "ls testflight finds 3 files" {
files="$(cmd ls -e testflight | wc -l)"
[ "${files}" -eq 4 ]
}

@test "ls subdir finds 4 files" {
files="$(cmd ls -e subdir | wc -l)"
[ "${files}" -eq 5 ]
}

@test "Prepare staging should render 3 files" {
cmd record -e testflight
cmd prepare -e staging --force-clean
files=$(find . -name '*.yml' | wc -l)
[ "${files}" -eq 4 ]
}

0 comments on commit 1438034

Please sign in to comment.