Skip to content

Commit

Permalink
Merge branch 'fix_detachbranch' of https://github.com/adrianschroeter…
Browse files Browse the repository at this point in the history
…/osc

Fix/Workaround for "osc detachbranch" in case of a missing link target
(in this case, the _link file is removed; an alternative would be to
fall back to the last working rev). Also improve the Linkinfo.is_link
check.
  • Loading branch information
marcus-h committed Sep 16, 2021
2 parents 5fdcecf + f98083d commit db2e489
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2855,7 +2855,14 @@ def do_detachbranch(self, subcmd, opts, *args):
li = Linkinfo()
li.read(root.find('linkinfo'))
if li.islink() and li.haserror():
raise oscerr.LinkExpandError(project, package, li.error)
try:
show_package_meta(apiurl, li.project, li.package)
except HTTPError as e:
if e.code == 404:
print("Link target got removed, dropping link. WARNING: latest submissions in link target might be lost!")
delete_files(apiurl, project, package, ['_link'])
else:
raise oscerr.LinkExpandError(project, package, li.error)
elif not li.islink():
print('package \'%s/%s\' is no link' % (project, package), file=sys.stderr)
else:
Expand Down
2 changes: 1 addition & 1 deletion osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def read(self, linkinfo_node):

def islink(self):
"""returns True if the linkinfo is not empty, otherwise False"""
if self.xsrcmd5 or self.lsrcmd5:
if self.xsrcmd5 or self.lsrcmd5 or self.error is not None:
return True
return False

Expand Down

0 comments on commit db2e489

Please sign in to comment.