openSUSE / osc

The Command Line Interface to work with an Open Build Service
http://openbuildservice.org/
GNU General Public License v2.0
170 stars 181 forks source link

checkin command does not interpret newline characters #801

Closed glaubitz closed 4 years ago

glaubitz commented 4 years ago

It is possible to add multi-line changelog entries with osc vc using:

# osc vc -m "Initial build\n  + Version 1.2.3"

results in:

-------------------------------------------------------------------
Wed Jun  3 12:48:40 UTC 2020 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>

- Initial build
  + Version 1.2.3

The same unfortunately does not work with osc checkin:

# osc checkin -m "Initial build\n  + Version 1.2.3"

as this results in:

----------------------------------------------------------------------------
r2 | glaubitz | 2020-06-03 12:42:19 | 401d8eff06984b98c4db9fc3b6e33cbc | unknown | 

- Initial build\n  + Version 1.2.3
lethliel commented 4 years ago

Hi,

this is not possible. osc just transfers the string "Initial build\n + Version 1.2.3".

For osc vc -m it transfers it to build/vc build/vc echoes the string with echo -e into the changes file From the man page of echo:

-e     enable interpretation of backslash escapes

For osc checkin -m the string is given as a query parameter to the API and the API does not interpret newline characters here.

glaubitz commented 4 years ago

The API does support multi-line commit messages though. So I'm not sure why it shouldn't accept multiline commit messages on the command line.

lethliel commented 4 years ago

Huh? Then I will further investigate. My last information that it does not interpret newline characters

lethliel commented 4 years ago

Ah,. It is the backend that does not interpret the newlines

coolo commented 2 years ago

Note that the change was reverted. The proper way to have multiline commit logs is using new line characters:

coolo@localhost#product-builder>python3.10 ~/prod/osc/osc-wrapper.py ci -m "Hallo^MIhr"
Sending    product-builder.changes
Transmitting file data .
Committed revision 10.
coolo@localhost#product-builder>osc log | head
----------------------------------------------------------------------------
r10 | coolo | 2022-07-08 08:02:06 | 9d6d9d5e097192374b7b4ff3500ab931 | unknown | 

Hallo
Ihr

Your assumption that \n in command line arguments is creating new lines is just wrong:

coolo@localhost#product-builder>echo "Hallo\nIhr"
Hallo\nIhr

osc vc is just strange.

glaubitz commented 2 years ago

Why revert it when this little change could have just been implented?

If improvements from the community are later reverted anyway, you’re not really encouraging community members to make contributions in the future. At least I am a little less motivated now to submit patches.

I made this change because osc’s behavior is inconsistent. It should accept message files for all commands and not just some.

¯_(ツ)_/¯

coolo commented 2 years ago

Message files is a different topic - we're talking about \n in -m arguments. And it wasn't reverted for fun but because the fix broke all of unicode