PBR

sem-ver in git log as no effect on version

Bug #1738685 reported by cmcginty
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PBR
Incomplete
Undecided
Unassigned

Bug Description

It seems like the "sem-ver:" feature that looks at git logs is not working. I can't be 100% sure because the documentation is ambigious on how it is actually supposed to work. I assume created a "sem-ver: api-break" string in my log will bump the version but it does not work.

Please investigate and if you could do a better job in the docs to present this feature to the users, that would be very helpful.

I took a look at the code and this line seems very suspicious:

 header_len = len(' sem-ver:')
    commands = [line[header_len:].strip() for line in changelog.split('\n')
                if line.lower().startswith(' sem-ver:')]

Why is there whitespace in the string check? I tried different sizes of white-space in my logs, but nothing is working. If there is a white-space requirement, can you please document it?

Thanks so much.

Revision history for this message
Clark Boylan (cboylan) wrote :

The whitespace is there because the `git log` output prefixes commit messages with whitespace to format them nicely. Reading the manpage for git log I am not immediately finding any way to prevent it from doing that. When writing the commit message you should left align your Sem-Ver: api-break entries.

Performing some local testing I've found that only the first 'Sem-Ver: api-break' in a commit message after a git tag will have any effect. This is because multiple api breaking changes can be rolled into a single major version release.

For example if we have a git log that looks something like:

C -> B -> A (1.0.0)

Then Sem-Ver: api-break on B will cause the autodetected version to be 2.0.0.dev1 but an api-break on C after B will still be 2.0.0.dev2 because you can tag C 2.0.0 and be correct.

If this behavior doesn't describe what you are observing can you provide more info about your git commits and tags? Maybe even include the git log output.

Revision history for this message
Ben Nemec (bnemec) wrote :

Marking incomplete per Clark's request for more details.

Changed in pbr:
status: New → Incomplete
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to pbr (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/554730

cmcginty (casey-mcginty)
summary: - sem-ver in git log as no effect on version
+ sem-ver in git log as no affect on version
summary: - sem-ver in git log as no affect on version
+ sem-ver in git log as no effect on version
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to pbr (master)

Reviewed: https://review.openstack.org/554730
Committed: https://git.openstack.org/cgit/openstack-dev/pbr/commit/?id=183b445c0f8eb84568df6e07cf34dcc3e1935cec
Submitter: Zuul
Branch: master

commit 183b445c0f8eb84568df6e07cf34dcc3e1935cec
Author: Clark Boylan <email address hidden>
Date: Tue Mar 20 16:12:20 2018 -0700

    Better Sem-Ver header handling

    This makes Sem-Ver header handling more reliable by ignoring any
    potential user configured git log output format. Instead PBR supplies
    its own format string that will output the commit message bodies in
    their entirety without wrapping and other whitespace formatting done for
    humans.

    Change-Id: I957a8c182585119534b4e02c34e7140a3e07d1d6
    Related-Bug: 1738685
    Fixes-Bug: 1704625

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.