Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improving get_latest_remote_tag() in git module #600

Merged
merged 2 commits into from
Nov 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions jumpscale/tools/git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,18 @@ def find_git_path(path, die=True):

def get_latest_remote_tag(repo_path):
"""
Get the latest tag of a remote repository
retrive the latest tag of a remote upstream repository

Args:
repo_path (str): path to the local git repository

Returns:
str: the latest tag of the remote repository
"""
try:
_, out, _ = j.sals.process.execute(
"git ls-remote --tags --refs --sort='v:refname' | tail -n1 | sed 's/.*\///'", cwd=repo_path
)
latest_remote_tag = out.rstrip("\n")
except Exception as e:
raise j.exceptions.Runtime(f"Failed to fetch remote releases. {str(e)}")
rc, out, err = j.sals.process.execute(
"git ls-remote --tags --refs | sort -t '/' -k 3 -V | tail -n1 | sed 's/.*\///'", cwd=repo_path
)
if rc != 0:
raise j.exceptions.Runtime(f"Failed to fetch latest remote release. {err}")
latest_remote_tag = out.rstrip("\n")
return latest_remote_tag