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

Use relative schema urls internally #59

Merged
merged 1 commit into from
Jun 15, 2017

Conversation

bkase
Copy link
Contributor

@bkase bkase commented Jun 15, 2017

As discussed in person, given that compilers should (if they have a
choice) produce bit-for-bit identical output, and a codegen tool like
plank is used in builds, it makes sense for --print_deps to output
dependencies via their relative paths.

Even if all things were equal and we didn't care about bit-for-bit identical output, this is still a nice change because:

  1. The print_deps output is more readable and fewer bytes since absolute
    paths are mostly repetitive and noisy
  2. The logic for decodeRef can be simplified

I verified that Pinterest still builds correctly with this plank and
that we are still able to load schemas located in a different directory
(I tested with ../../foo.json).

@bkase bkase requested a review from rahul-malik June 15, 2017 02:26
let lastPathComponentString = URL(string: ref)?.pathComponents.last
return URL(string:lastPathComponentString!, relativeTo:baseUrl)!
return URL(string:baseUrl.path + "/" + lastPathComponentString!)!
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe better here to use

return URL(string:baseUrl.path).URLByAppendingPathComponent(lastPathComponentString!)
// OR if baseUrl is an URL
return baseUrl.URLByAppendingPathComponent(lastPathComponentString!)

Connecting file paths via/ is not safe cross platforms.

As discussed in person, given that compilers should (if they have a
choice) produce bit-for-bit identical output, and a codegen tool like
plank is used in builds, it makes sense for `--print_deps` to output
dependencies via their relative paths.

Even if all things were equal and , this is still a nice change because:

1. The print_deps output is more readable and fewer bytes since absolute
paths are mostly repetitive and noisy
2. The logic for `decodeRef` can be simplified

I verified that Pinterest still builds correctly with this plank and
that we are still able to load schemas located in a different directory
(I tested with `../../foo.json`).
@bkase bkase force-pushed the use-relative-paths branch from cf45196 to f667483 Compare June 15, 2017 03:08
@ghost
Copy link

ghost commented Jun 15, 2017

1 Warning
⚠️ Any source code changes should have an entry in CHANGELOG.md or have #trivial in their title.

Generated by 🚫 Danger

Copy link
Collaborator

@rahul-malik rahul-malik left a comment

Choose a reason for hiding this comment

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

Looks like safe change to me. Thanks!

@rahul-malik rahul-malik merged commit 332af42 into pinterest:master Jun 15, 2017
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.

3 participants