feat/show version

close #5
This commit is contained in:
SouthFox 2023-03-18 13:08:17 +08:00
parent 3e677afebc
commit cde57f2604
2 changed files with 18 additions and 2 deletions

View file

@ -4,6 +4,8 @@ import tomli
import pydantic
DEBUG = True
MAIN_VERSION = "0.0.1"
ROOT_DIR = Path().parent.resolve()
DB_PATH = ROOT_DIR / "data" / "database.db"
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_PATH}"
@ -39,6 +41,18 @@ def load_config() -> Config:
f"{_CONFIG_FILE} is missing"
)
def get_version_commit() -> str:
import subprocess
try:
return (
'+' +
subprocess.check_output(["git", "rev-parse", "--short=8", "HEAD"])
.split()[0]
.decode()
)
except Exception:
return "+dev"
CONFIG = load_config()
DOMAIN = CONFIG.domain
_SCHEME = "https" if CONFIG.https else "http"
@ -47,7 +61,8 @@ BASE_URL = ID
USERNAME = CONFIG.username
KEY_PATH = (ROOT_DIR / "data" / "key.pem")
USER_AGENT = "Fediverse Application/Foxhole-0.0.1"
VERSION = "Foxhole-"+ MAIN_VERSION + get_version_commit()
USER_AGENT = "Fediverse Application/" + VERSION
AP_CONTENT_TYPE = "application/activity+json"
MANUALLY_APPROVES_FOLLOWERS = CONFIG.manually_approves_followers

View file

@ -24,6 +24,7 @@ from app.config import BASE_URL
from app.config import DOMAIN
from app.config import ID
from app.config import USERNAME
from app.config import VERSION
from app.database import AsyncSession
from app.database import get_db_session
from app.boxes import save_incoming
@ -109,7 +110,7 @@ async def nodeinfo(
"version": "2.0",
"software": {
"name": "foxhole",
"version": "0.0.1",
"version": VERSION,
},
"protocols": ["activitypub"],
"services": {"inbound": [], "outbound": []},