|
8 | 8 | from celery.schedules import crontab
|
9 | 9 | from corsheaders.defaults import default_headers
|
10 | 10 |
|
11 |
| -from .utils import config, get_sentry_integrations |
| 11 | +from .utils import config, get_git_sha, get_release, get_sentry_integrations |
12 | 12 |
|
13 | 13 | # Build paths inside the project, so further paths can be defined relative to
|
14 | 14 | # the code root.
|
|
378 | 378 | # multiple login urls defined.
|
379 | 379 | LOGIN_URLS = [reverse_lazy("admin:login")]
|
380 | 380 |
|
| 381 | + |
381 | 382 | if "GIT_SHA" in os.environ:
|
382 | 383 | GIT_SHA = config("GIT_SHA", "")
|
383 |
| -# in docker (build) context, there is no .git directory |
384 |
| -elif (BASE_DIR / ".git").exists(): |
385 |
| - try: |
386 |
| - import git |
387 |
| - except ImportError: |
388 |
| - GIT_SHA = None |
389 |
| - else: |
390 |
| - repo = git.Repo(search_parent_directories=True) |
391 |
| - try: |
392 |
| - GIT_SHA = repo.head.object.hexsha |
393 |
| - except ( |
394 |
| - ValueError |
395 |
| - ): # on startproject initial runs before any git commits have been made |
396 |
| - GIT_SHA = repo.active_branch.name |
397 | 384 | else:
|
398 |
| - GIT_SHA = None |
| 385 | + GIT_SHA = get_git_sha() |
| 386 | + |
| 387 | +if "RELEASE" in os.environ: |
| 388 | + RELEASE = config("RELEASE", "") |
| 389 | +else: |
| 390 | + RELEASE = get_release() or GIT_SHA |
399 | 391 |
|
400 |
| -RELEASE = config("RELEASE", GIT_SHA) |
401 | 392 |
|
402 | 393 | REQUESTS_READ_TIMEOUT = config("REQUESTS_READ_TIMEOUT", 30)
|
403 | 394 | # Default (connection timeout, read timeout) for the requests library (in seconds)
|
|
0 commit comments