mirror of
https://github.com/EDCD/EDDN.git
synced 2025-06-19 16:23:56 +03:00
setup.py: Detect if not using live
branch in live
directory
This commit is contained in:
parent
495e27861e
commit
35c4f89c68
28
setup.py
28
setup.py
@ -2,6 +2,8 @@ import glob
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
# TODO: Enforce only using the `live` branch if `live` is in cwd, or
|
# TODO: Enforce only using the `live` branch if `live` is in cwd, or
|
||||||
@ -12,6 +14,32 @@ from setuptools import setup, find_packages
|
|||||||
# `master` which may have changes merged some time before they become
|
# `master` which may have changes merged some time before they become
|
||||||
# live.
|
# live.
|
||||||
|
|
||||||
|
cwd = os.getcwd()
|
||||||
|
# e.g. /home/eddn/live/EDDN.git
|
||||||
|
if '/live/' in cwd:
|
||||||
|
|
||||||
|
try:
|
||||||
|
git_cmd = subprocess.Popen(
|
||||||
|
'git symbolic-ref -q --short HEAD'.split(),
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT
|
||||||
|
)
|
||||||
|
out, err = git_cmd.communicate()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print("Couldn't run git command to check branch: %s" % (e))
|
||||||
|
|
||||||
|
else:
|
||||||
|
branch = out.decode().rstrip('\n')
|
||||||
|
# - For any other branch checked out at its head this will be a
|
||||||
|
# different name.
|
||||||
|
# - For any 'detached HEAD' (i.e. specific commit ID) it will be
|
||||||
|
# empty. That includes checking out a tag.
|
||||||
|
if branch != 'live':
|
||||||
|
print("CWD is '%s', but branch is '%s', aborting!" % (cwd, branch))
|
||||||
|
sys.exit(-1)
|
||||||
|
|
||||||
|
|
||||||
VERSIONFILE = "src/eddn/conf/Version.py"
|
VERSIONFILE = "src/eddn/conf/Version.py"
|
||||||
verstr = "unknown"
|
verstr = "unknown"
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user