#234 fix: replace % with %% in changelogs to escape macros
Closed 2 years ago by nphilipp. Opened 2 years ago by ankursinha.
fedora-infra/ ankursinha/rpmautospec fix/double-percent-for-macros  into  main

file modified
+1 -1
@@ -363,7 +363,7 @@ 

                  )

  

              if not skip_for_changelog:

-                 commit_subject = commit.message.split("\n", 1)[0].strip()

+                 commit_subject = commit.message.split("\n", 1)[0].strip().replace("%", "%%")

                  if commit_subject.startswith("-"):

                      commit_subject = commit_subject[1:].lstrip()

                  if not commit_subject:

  • first replace all occurrences of mutliple % with one %
  • replace all single % with %%

(There must be a more straight forward way to do it with a single
substitution using regex, but this was simple enough also).

Fixes #224

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

1 new commit added

  • chore: format with black
2 years ago

Build succeeded.

So this is actually wrong. There is no reason to replace multiple percent symbols by a single one. All is needed is .replace('%', '%%').

For example:
commit message 1: "We need to always remember use doubled %% instead of single % in the spec"
commit message 2: "We need to also remember to use %%%% when we want a double %% in the spec"
should be rendered as
changelog entry 1: "- We need to always remember use doubled %%%% instead of single %% in the spec"
changelog entry 2: "We need to also remember to use %%%%%%%% when we want a double %%%% in the spec"

In other words, % has no special meaning in git commit messages and each of those needs to be replaced by %% so that it looks the same as the original string when rendered by rpm.

1 new commit added

  • fix: simply replace all % with %%
2 years ago

that's even simpler then, updated.

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

Could someone from the dev team please take a look to see if anything in the PR is causing the test failures, and if not, merge this? Cheers

Sorry, I fixed this differently in the 'long changelog entries' part of #244, which required refactoring how the changelog is generated substantially so this wouldn't apply.

Pull-Request has been closed by nphilipp

2 years ago
Metadata