osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ci/+/34669?usp=email )
Change subject: obs: srcpkg: support having no git tags ...................................................................... obs: srcpkg: support having no git tags Instead of failing when a project has no git-version-gen script, and no git tags, use 0.0.0 as version. This is needed for the new osmo-epdg project, which doesn't have tags yet. Change-Id: I2f0f409feb96611095dfa511a33ea730e5bbf3e4 --- M scripts/obs/lib/srcpkg.py 1 file changed, 28 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/69/34669/1 diff --git a/scripts/obs/lib/srcpkg.py b/scripts/obs/lib/srcpkg.py index 324bc66..9476d82 100644 --- a/scripts/obs/lib/srcpkg.py +++ b/scripts/obs/lib/srcpkg.py @@ -42,11 +42,24 @@ pattern = lib.git.get_latest_tag_pattern(project) pattern = pattern.replace("^", "", 1) pattern = pattern.replace("$", "", -1) - ret = lib.run_cmd(["git", "describe", + result = lib.run_cmd(["git", "describe", "--abbrev=4", "--tags", f"--match={pattern}", - "HEAD"], cwd=repo_path).output.rstrip() + "HEAD"], cwd=repo_path, check=False) + + if result.returncode == 128: + print(f"{project}: has no git tags, using 0.0.0 as version") + commit = lib.run_cmd(["git", "rev-parse", "HEAD"], + cwd=repo_path).output[0:4] + count = lib.run_cmd(["git", "rev-list", "--count", "HEAD"], + cwd=repo_path).output.rstrip() + return f"0.0.0.{count}-{commit}" + + if result.returncode != 0: + lib.exit_error_cmd(result, "command failed unexpectedly") + + ret = result.output.rstrip() # Like git-version-gen: # * Change the first '-' to '.' -- To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/34669?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ci Gerrit-Branch: master Gerrit-Change-Id: I2f0f409feb96611095dfa511a33ea730e5bbf3e4 Gerrit-Change-Number: 34669 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osm...@sysmocom.de> Gerrit-MessageType: newchange