@@ -820,11 +820,40 @@ def run_server(log_level):
820820 os .environ ["LOG_LEVEL" ] = log_level .upper ()
821821 if not os .path .isdir (config .STATIC_DIR ):
822822 import atexit
823+ import subprocess
823824 from subprocess import Popen
824825
825826 # take our frontend vars and export them for the frontend to consume
826827 envvars = os .environ .copy ()
827828 envvars .update ({x : getattr (config , x ) for x in dir (config ) if x .startswith ("VITE_" )})
829+
830+ # Add git commit information for development
831+ try :
832+ commit_hash = subprocess .check_output (
833+ ["git" , "rev-parse" , "HEAD" ], cwd = "." , stderr = subprocess .DEVNULL
834+ ).decode ("utf-8" ).strip ()
835+ envvars ["VITE_DISPATCH_COMMIT_HASH" ] = commit_hash
836+ except (subprocess .CalledProcessError , FileNotFoundError ):
837+ # If git is not available or not in a git repo, use a default value
838+ envvars ["VITE_DISPATCH_COMMIT_HASH" ] = "dev-local"
839+
840+ try :
841+ commit_message = subprocess .check_output (
842+ ["git" , "log" , "-1" , "--pretty=%B" ], cwd = "." , stderr = subprocess .DEVNULL
843+ ).decode ("utf-8" ).strip ()
844+ envvars ["VITE_DISPATCH_COMMIT_MESSAGE" ] = commit_message
845+ except (subprocess .CalledProcessError , FileNotFoundError ):
846+ # If git is not available or not in a git repo, use a default value
847+ envvars ["VITE_DISPATCH_COMMIT_MESSAGE" ] = "Development build"
848+
849+ try :
850+ commit_date = subprocess .check_output (
851+ ["git" , "log" , "-1" , "--pretty=%cd" , "--date=short" ], cwd = "." , stderr = subprocess .DEVNULL
852+ ).decode ("utf-8" ).strip ()
853+ envvars ["VITE_DISPATCH_COMMIT_DATE" ] = commit_date
854+ except (subprocess .CalledProcessError , FileNotFoundError ):
855+ # If git is not available or not in a git repo, use a default value
856+ envvars ["VITE_DISPATCH_COMMIT_DATE" ] = "Unknown"
828857 is_windows = os .name == "nt"
829858 windows_cmds = ["cmd" , "/c" ]
830859 default_cmds = ["npm" , "run" , "serve" ]
0 commit comments