obs: meaningful error if debian/changelog is empty

If there's an empty debian/changelog, packaging needs to be fixed in the
git repository of the project. Print a meaningful error instead of:

    File "/obs/lib/srcpkg.py", line 68, in get_version_for_feed
      if ":" in ret:
  TypeError: argument of type 'NoneType' is not iterable

Change-Id: I294d844ccccfa12599b6ba1def087e4a32d289e7
This commit is contained in:
Oliver Smith 2022-08-17 11:30:14 +02:00 committed by osmith
parent a8536d8847
commit 65cc10c602
2 changed files with 6 additions and 8 deletions

View File

@ -73,14 +73,15 @@ def get_last_version_from_changelog(project):
repo_path = lib.git.get_repo_path(project)
changelog_path = f"{repo_path}/debian/changelog"
if not os.path.exists(changelog_path):
return None
assert os.path.exists(changelog_path), f"{project}: missing debian/changelog"
changelog = open(changelog_path).read()
if not changelog:
return None
assert changelog, f"{project}: debian/changelog is empty"
return changelog.split("(", 1)[1].split(")", 1)[0]
ret = changelog.split("(", 1)[1].split(")", 1)[0]
assert ret, f"{project}: couldn't find last version in debian/changelog"
return ret
def changelog_add_entry_if_needed(project, feed, version):

View File

@ -70,9 +70,6 @@ def get_version_for_feed(project, feed, conflict_version):
if ":" in ret:
ret = ret.split(":")[1]
if not ret:
ret = "0.0.0"
# Append the conflict_version to increase the version even if the commit
# did not change (OS#5135)
if conflict_version: