Skip to content

Commit

Permalink
improving get_latest_remote_tag() in git module (#600)
Browse files Browse the repository at this point in the history
* removing the usage of git --sort option

removing the usage of git built-in --sort option as it is not available in git < 2.18 and sort Linux command was used instead.
ATM the git version used in our VDC deployer is 2.17

* Update __init__.py
  • Loading branch information
sameh-farouk authored Nov 17, 2021
1 parent 29b4855 commit 7f53b47
Showing 1 changed file with 7 additions and 8 deletions.
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

0 comments on commit 7f53b47

Please sign in to comment.