Skip to content

Commit

Permalink
[FEATURE] 서비스 버전 표기 (#319)
Browse files Browse the repository at this point in the history
* feat: subprocess 설정 (#317)

* feat: 서비스 버전 표기 (#317)
  • Loading branch information
hyunmin0317 authored Oct 13, 2024
1 parent 87079b0 commit e4bf057
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions config/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import subprocess


def git_tag():
try:
return subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0']).strip().decode('utf-8')
except:
return "v0.0.0"


def commit_hash():
try:
hash = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip().decode('utf-8')
return hash, hash[:7]
except:
return "", ""


def version_processor(request):
commit, short_commit = commit_hash()
return {'git_tag': git_tag(), 'commit': commit, 'short_commit': short_commit}
1 change: 1 addition & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'config.context_processors.version_processor',
],
},
},
Expand Down
2 changes: 2 additions & 0 deletions templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ <h4>
</h4>
<h4>
Copyright ⓒ Smunity
<a href="https://github.com/smu-nity/SMUNITY/releases/tag/{{ git_tag }}" class="footer_link" target="_blank">{{ git_tag }}</a>
(<a href="https://github.com/smu-nity/SMUNITY/commit/{{ commit }}" class="footer_link" target="_blank">{{ short_commit }}</a>)
</h4>
</div>
</footer>

0 comments on commit e4bf057

Please sign in to comment.