Build error occurred; commits with "" break build commands. - #269
Conversation
… on the main GitHub page because my commit contained "" marks. These two adjustments to CMakeLists.txt resolve this by escaping "" marks in commit messages.
|
Deleted my fork locally, recloned, ran build again to confirm I'm not an idiot, it did build successfully. Very minor change, just telling it to ignore "" marks in commit messages when building, but I'm a mess with Git so apologies for the quick confusion there! |
|
Escaped with \" | """ → " | ❌ sometimes | Works only if the message doesn’t break syntax Circling back, my original pull request . . . it did build (hence why I made a pull request) but when I tried it a second time, everything broke. Asking ChatGPT to investigate why it worked ONCE, this is what it returned. tl;dr I was sort've right in my original pull request, but when I built a second time the newest commit message didn't have "" marks and it broke again. this latest pull request should mean you can build with any commit message, "" marks or not, and it should succeed. |
vaxerski
left a comment
There was a problem hiding this comment.
just replace it with a space
|
Doing some testing with the code I've pushed. This is a very specific edge-case that I'm dealing with. Prior to this code, if you commit the following: This pull request fixes this. ❯ git commit -m "testing again [backslash]" with [backslash]" marks" Of course, what matters most is: In short, I created a problem when I committed with "" marks in my commit message. That being said, as long as we just commit with plain text, it will always build. |
|
tl;dr if you just change the most recent commit msg to not include quotes, the issue self-resolves without needing to adjust any code. then you just don't accept commits that contain " marks >.> |
|
Currently adjusting, I've changed it to just replace with a space. I'm going to run a few tests with different commit messages like I did above. |
|
Accidentally pushed two additional commits, was just me adding a test.txt & then removing it. Anyway, I replaced it to be a space like you mentioned, now all three scenarios I tested: ❯ git commit -m "this has always worked and still works" Unlike before, all of these commit messages still allowed CMake to build, no errors occurring. My only gripe is I ended on that last commit (yes it still works!) but I should've ended on a commit that had ZERO QUOTES just to avoid complications. tl;dr I believe replacing with a space has made it so no matter how someone commits, whether they use " or [backslash]" in their message, it should build. :) Thank you for your patience. |
Using these build commands found on the main page of the repo:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build
cmake --build ./build --config Release --target hyprpaper -jnproc 2>/dev/null || getconf _NPROCESSORS_CONF
I caused this error when building:
/home/blake-sama/Developer/hyprpaper/src/main.cpp: In function ‘int main(int, char**, char**)’:
: error: unable to find string literal operator ‘operator""source’ with ‘const char [19]’, ‘long unsigned int’ arguments
/home/blake-sama/Developer/hyprpaper/src/main.cpp:6:90: note: in expansion of macro ‘GIT_COMMIT_MESSAGE’
6 | Debug::log(LOG, "Welcome to hyprpaper!\nbuilt from commit {} ({})", GIT_COMMIT_HASH, GIT_COMMIT_MESSAGE);
| ^~~~~~~~~~~~~~~~~~
make[3]: *** [CMakeFiles/hyprpaper.dir/build.make:205: CMakeFiles/hyprpaper.dir/src/main.cpp.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/Makefile2:87: CMakeFiles/hyprpaper.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:94: CMakeFiles/hyprpaper.dir/rule] Error 2
make: *** [Makefile:189: hyprpaper] Error 2
After ChatGPT'ing the error, when the build tried to compile, it detected a bad commit message. Well, that's because the most recent commit to the project was mine which had "source=" in the commit message. It failed to read the "" marks in my commit message correctly, breaking the compiler's ability to build hyprpaper.
I'm also not very great at explaining so here's ChatGPT expressing what this fix does:
"The fix I added ensures that any " characters in the commit message are escaped ("), so that when the macro is expanded into C++, it stays within the bounds of a valid string literal. This prevents the preprocessor from misinterpreting the contents of commit messages."
tl;dr I'm sorry I broke the build with a bad commit message, lesson learned . . . don't use "" marks in commits.
As for why the prior pull request failed, in typical fashion of how tf do I create a pull request, I copied a line incorrectly:
string(REPLACE """ "3 \ marks here when there should have been 5" GIT_COMMIT_MESSAGE_ESCAPED "${GIT_COMMIT_MESSAGE}")
Basically I missed two \ marks in the prior pull request, which error'd out. I have updated my fork, commit & push, ran the build commands:
[100%] Built target hyprpaper
Success!