Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

doc: fix an error if the doc is not generated from github #598

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion doc/sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import subprocess
# import sys
# sys.path.insert(0, os.path.abspath('.'))

Expand All @@ -24,7 +25,16 @@
author = 'SiFive Inc.'

# The short X.Y version
version = os.environ['RELEASE_TAG']
# if github provides us a ref or tag
if 'RELEASE_TAG' in os.environ:
version = os.environ['RELEASE_TAG']
# if we are in a git repository
elif subprocess.call(["git", "branch"], stderr=subprocess.STDOUT, stdout=open(os.devnull, 'w')) == 0:
# set version to the current commit id
version = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip().decode('ascii')
else:
version = "n/a"

# The full version, including alpha/beta/rc tags
release = version

Expand Down