-
Notifications
You must be signed in to change notification settings - Fork 914
fix: preProcessedFileSubstitution replacing to "" #11464
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
base: master
Are you sure you want to change the base?
Conversation
|
Thanks for opening this pull request! Things that will help get your PR across the finish line:
|
d1fc372 to
220bf2a
Compare
|
Hmmm, it seems that the CI here does exactly the opposite... |
This comment was marked as outdated.
This comment was marked as outdated.
|
Seems very sensible to me. Placeholder key have no value in template output. |
|
Updated the top post I figured it out, what the test did was for(file in files){
orig = file.subsitute(variables)
recon = Poco::replaceInPlace(....,vaiables["SOME_KEY"])
test_same(orig,recon)
}if you unroll this loop you would get: // iter 0 all fine
orig = file1.subsitute(vars);
recon = Poco::replaceInPlace(read(file1),vars["SOME_KEY"]); // <- this sets vars["SOME_KEY"]=""
test_same(orig,recon);
// iter 1 -> problem,s
orig = file2.subsitute(vars); // <- this vars is different, as it is no longer empty but {"SOME_KEY"→""}
recon = Poco::replaceInPlace(read(file2),vars["SOME_KEY"]);
test_same(orig,recon);Because the order of the iterations (files reported by the file system) on my machine was different than those in CI
My files may have been in a different order because I was using nix and/or because my poco version was different. |
|
force-pushed a typo fix and adding |
Head branch was pushed to by a user without write access
cf3366f to
94adc8a
Compare
|
Rebased |
|
@Ashod , just quickly checking my PRs. If there's anything else I can |
df5c8cb to
a5fa043
Compare
|
Rebased |
|
Any change to get this merged? |
preProcessedFileSubstitution did not work correctly if an empty map was given. In this case `variables["ACCESS_TOKEN"]` would be read as `""` as that key was not present in the map, addtionally, it would be added. Poco::replaceInPlace would in turn replace the `%ACCESS_TOKEN%` with `""`, while it should just keep the not specified parts as is. On top op that, now variables is modified so in the next iteration of the loop the test is no longer the same. I chose to add a function rather than ifs in the body to prevent future mistakes from happening. This does however make the code more complex I also made variables a const argument Change-Id: 8d84961da571686c39effa6d5b43918151da1be4 Signed-off-by: Robbert Gurdeep Singh <[email protected]>
|
Hi @Ashod and maintainers — I've rebased the branch onto master to keep it up to date. I ran make check (via nix) and did a manual verification, (including a run with Nextcloud) — everything looked good locally. It would be nice if this could get merged. |
Summary
preProcessedFileSubstitution did not work correctly if an empty map was given. In this case
variables["ACCESS_TOKEN"]would be read as""as that key was not present in the map.Poco::replaceInPlace would in turn replace the
%ACCESS_TOKEN%with"", while it should just keep the not specified parts as is.I chose to add a function rather than ifs in the body to prevent future mistakes from happening.
Before this change I got an error when running the unittests from nix (see NixOS/nixpkgs#393618 (comment)
):
Checklist
make prettier-writeand formatted the code.make check-> ran through nixmake runand manually verified that everything looks okay -> even ran it through nextcloud