Skip to content

fix: cutpath for ../ paths#2498

Merged
ritazh merged 3 commits into
open-policy-agent:masterfrom
acpana:acpana/fix-gator-paths
Jan 6, 2023
Merged

fix: cutpath for ../ paths#2498
ritazh merged 3 commits into
open-policy-agent:masterfrom
acpana:acpana/fix-gator-paths

Conversation

@acpana
Copy link
Copy Markdown
Contributor

@acpana acpana commented Jan 6, 2023

Signed-off-by: Alex Pana 8968914+acpana@users.noreply.github.com

I missed specifying the prev dir relatively in my original cut trick: #2443 and this was raised in #2495. Fixes #2495 .

The issue was the cut didn't work w paths prefixed w ../. Added tests for that now.

Also, if you want to see it in action now for these kinds of paths:

# prev dir relative
$ gator verify ../gatekeeper/test/gator/verify/suite.yaml
ok      ../gatekeeper/test/gator/verify/suite.yaml      0.011s
PASS

# prev dir relative specified explicitly
$ gator verify ./../gatekeeper/test/gator/verify/suite.yaml
ok      ./../gatekeeper/test/gator/verify/suite.yaml      0.011s
PASS

# prev dir relative, recurse
$ gator verify ../gatekeeper/test/gator/verify/...
ok      ../gatekeeper/test/gator/verify/more_suites/suite copy.yaml     0.011s
ok      ../gatekeeper/test/gator/verify/more_suites/suite.yaml  0.007s
ok      ../gatekeeper/test/gator/verify/suite.yaml      0.009s
PASS

Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
// contained in the file var.
cutPath := strings.TrimPrefix(originalPath, "/")
cutPath = strings.TrimPrefix(cutPath, "./")
for strings.HasPrefix(cutPath, "../") {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i'm not too concerned about an infinite loop here since specifying an arbitrarily large number of prev directories has to happen for that

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.38%. Comparing base (7bdb64f) to head (c6790df).
Report is 714 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2498      +/-   ##
==========================================
+ Coverage   53.35%   53.38%   +0.02%     
==========================================
  Files         116      116              
  Lines       10270    10272       +2     
==========================================
+ Hits         5480     5484       +4     
+ Misses       4370     4368       -2     
  Partials      420      420              
Flag Coverage Δ
unittests 53.38% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@ritazh ritazh left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

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

LGTM

@ritazh ritazh merged commit 923a183 into open-policy-agent:master Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gator CLI can't doesn't resolve relative paths

5 participants