Skip to content

Commit

Permalink
Calculate git version in shaka-player directory
Browse files Browse the repository at this point in the history
If the shaka-player directory doesn't have a '.git' file, we'll use the
npm version instead of finding the '.git' file in the whole repository.
This is to prevent grabbing version tag from a parent project, which
uses shaka-player as a dependency.

Test command:
python -c 'from build import shakaBuildHelpers; print
shakaBuildHelpers.calculate_version()'
If there's is a .git file, it shows the git version.
If not, it shows the npm version.

Closes #871

Change-Id: Iee3cd6868c46f327966fd6ce5071ca7b750174b6
  • Loading branch information
michellezhuogg authored and joeyparrish committed Jul 17, 2017
1 parent 142c5a1 commit a1d1cda
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions build/shakaBuildHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,17 @@ def cygwin_safe_path(path):

def git_version():
"""Gets the version of the library from git."""
try:
# Check git tags for a version number, noting if the sources are dirty.
cmd_line = ['git', '-C', get_source_base(), 'describe', '--tags', '--dirty']
return execute_get_output(cmd_line).strip()
except subprocess.CalledProcessError:
raise RuntimeError('Unable to determine library version!')
# Check if the shaka-player source base directory has '.git' file.
git_path = os.path.join(get_source_base(), '.git')
if not os.path.exists(git_path):
raise RuntimeError('no .git file is in the shaka-player repository.')
else:
try:
# Check git tags for a version number, noting if the sources are dirty.
cmd_line = ['git', '-C', get_source_base(), 'describe', '--tags', '--dirty']
return execute_get_output(cmd_line).strip()
except subprocess.CalledProcessError:
raise RuntimeError('Unable to determine library version!')


def npm_version(is_dirty=False):
Expand Down

0 comments on commit a1d1cda

Please sign in to comment.