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

Fix the way to compute the target path relative to the symlink #245

Merged
merged 2 commits into from
Nov 20, 2020
Merged

Conversation

k-ye
Copy link
Contributor

@k-ye k-ye commented Nov 20, 2020

I believe what I did in #229 was wrong when handling the symlink target.

  1. When we construct the SymlinkNode, Target should be relative to the directory of the symlink. Support symlinks when constructing a Merkle tree. #229 computed the path relative to execRoot instead. This is problematic when the target is an absolute path in the filesystem.
  2. When we recursively call loadFiles() on the target, this time path should still be the part of target relative to execRoot.

@google-cla google-cla bot added the cla: yes The author signed a CLA label Nov 20, 2020
Copy link
Contributor

@ola-rozenfeld ola-rozenfeld left a comment

Choose a reason for hiding this comment

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

Right, good catch! I'm surprised no tests in tree_test were changed. In general, I'd much rather test the public function there than the small private function.

@k-ye
Copy link
Contributor Author

k-ye commented Nov 20, 2020

#245 (review)

One sec, let me add some test..

@k-ye
Copy link
Contributor Author

k-ye commented Nov 20, 2020

One sec, let me add some test..

Done

@@ -692,28 +697,27 @@ func TestComputeMerkleTree(t *testing.T) {
input: []*inputPath{
{path: "foobarDir/foo", fileContents: fooBlob, isExecutable: true},
{path: "foobarDir/bar", fileContents: barBlob},
{path: "foobarSymDir", isSymlink: true, isAbsolute: true, symlinkTarget: "foobarDir"},
{path: "base/foobarSymDir", isSymlink: true, isAbsolute: true, symlinkTarget: "foobarDir"},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This might seem like it should be ../foobarDir, but because isAbsolute is true, the actual target it generates is "${execRoot}/foobarDir".

@k-ye k-ye requested a review from ola-rozenfeld November 20, 2020 06:35
@ola-rozenfeld ola-rozenfeld merged commit 8f976b9 into bazelbuild:master Nov 20, 2020
@k-ye k-ye deleted the fix branch November 21, 2020 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes The author signed a CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants