Skip to content

Commit

Permalink
Merge pull request #97 from openSUSE/set_version_detect
Browse files Browse the repository at this point in the history
Move revision detection into _revision_detect
  • Loading branch information
dirkmueller authored Jun 18, 2024
2 parents 9bfad97 + 287a015 commit 8c93696
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions set_version
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,22 @@ def _version_detect(args, files_local):


def _revision_detect(args):
revdetect = RevisionDetector()
revision = revdetect.autodetect()
logging.debug("Found revision '%s'", revision)
revision = args['revision']
if revision:
return revision

if not revision:
try:
revdetect = RevisionDetector()
revision = revdetect.autodetect()
logging.debug("Found revision '%s'", revision)
except Exception as e:
print("Revision detection failed with error: \"", e, "\".")
revision = '0'

if not revision:
print("unable to detect the revision")
sys.exit(-1)

return revision

Expand Down Expand Up @@ -475,17 +488,6 @@ if __name__ == '__main__':
print("unable to detect the version")
sys.exit(-1)

if not revision:
try:
revision = _revision_detect(args)
except Exception as e:
print("Revision detection failed with error: \"", e, "\".")
revision = '0'

if not revision:
print("unable to detect the revision")
sys.exit(-1)

# if no files explicitly specified process whole directory
files = args['file'] or files_local

Expand Down Expand Up @@ -546,4 +548,4 @@ if __name__ == '__main__':
_replace_tag(filename, "md5sums", "('SKIP')")
_replace_tag(filename, "sha256sums", "('SKIP')")
_replace_tag(filename, "pkgver", version)
_replace_tag(filename, "pkgrel", revision)
_replace_tag(filename, "pkgrel", _revision_detect(args))

0 comments on commit 8c93696

Please sign in to comment.