Skip to content

Commit

Permalink
Merge pull request #19 from philroche/feature/find-source-package-name
Browse files Browse the repository at this point in the history
fix: Find first source package name for a binary package with published sources
  • Loading branch information
toabctl authored Sep 16, 2023
2 parents 74d6846 + 31dd2a2 commit d4c586e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions ubuntu_package_changelog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def _lp_get_changelog_url(args, lp):
lp_series,
pocket)
if len(sources) == 0:
print(f'INFO: No published sources found for {args.package} in {args.series} {args.pocket}')
print('INFO: \tTrying to find a binary package with that name ...')
# unable to find published sources for args.package.
# Perhaps this is a binary package name so we can
# do a lookup to see if there exists a source package for
Expand All @@ -34,11 +36,19 @@ def _lp_get_changelog_url(args, lp):
if len(binaries):
# there were published binaries with this name.
# now get the source package name so we can get the changelog
source_package_name = binaries[0].source_package_name
sources = _get_published_sources(archive,
source_package_name,
lp_series,
pocket)
for binary in binaries:
source_package_name = binary.source_package_name
sources = _get_published_sources(archive,
source_package_name,
lp_series,
pocket)
if len(sources) > 0:
print(f'INFO: \tFound source package {source_package_name} for binary package '
f'{args.package} with published sources.')
print(f'INFO: \tChangelog for source package {source_package_name} will be parsed\n\n')
break
else:
print(f'INFO: \tNo published binaries found for {args.package} in {args.series} {args.pocket}\n\n')

if len(sources) == 1:
return sources[0].changelogUrl()
Expand Down Expand Up @@ -106,7 +116,8 @@ def main():

changelog_url = _lp_get_changelog_url(args, lp)
if not changelog_url:
print('no changelog found')
print('No changelog found for binary or source package "{}" in {} {}'.format(
args.package, args.series, args.pocket))
sys.exit(0)

url = lp._root_uri.append(urllib.parse.urlparse(changelog_url).path.lstrip('/'))
Expand Down

0 comments on commit d4c586e

Please sign in to comment.