Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ ENV VITE_DISPATCH_COMMIT_HASH="Unknown"
ARG VITE_DISPATCH_COMMIT_MESSAGE
ENV VITE_DISPATCH_COMMIT_MESSAGE="Unknown"

ARG VITE_DISPATCH_COMMIT_DATE
ENV VITE_DISPATCH_COMMIT_DATE="Unknown"

COPY . /usr/src/dispatch/
RUN YARN_CACHE_FOLDER="$(mktemp -d)" \
&& export YARN_CACHE_FOLDER \
Expand Down
29 changes: 29 additions & 0 deletions src/dispatch/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,11 +820,40 @@ def run_server(log_level):
os.environ["LOG_LEVEL"] = log_level.upper()
if not os.path.isdir(config.STATIC_DIR):
import atexit
import subprocess
from subprocess import Popen

# take our frontend vars and export them for the frontend to consume
envvars = os.environ.copy()
envvars.update({x: getattr(config, x) for x in dir(config) if x.startswith("VITE_")})

# Add git commit information for development
try:
commit_hash = subprocess.check_output(
["git", "rev-parse", "HEAD"], cwd=".", stderr=subprocess.DEVNULL
).decode("utf-8").strip()
envvars["VITE_DISPATCH_COMMIT_HASH"] = commit_hash
except (subprocess.CalledProcessError, FileNotFoundError):
# If git is not available or not in a git repo, use a default value
envvars["VITE_DISPATCH_COMMIT_HASH"] = "dev-local"

try:
commit_message = subprocess.check_output(
["git", "log", "-1", "--pretty=%B"], cwd=".", stderr=subprocess.DEVNULL
).decode("utf-8").strip()
envvars["VITE_DISPATCH_COMMIT_MESSAGE"] = commit_message
except (subprocess.CalledProcessError, FileNotFoundError):
# If git is not available or not in a git repo, use a default value
envvars["VITE_DISPATCH_COMMIT_MESSAGE"] = "Development build"

try:
commit_date = subprocess.check_output(
["git", "log", "-1", "--pretty=%cd", "--date=short"], cwd=".", stderr=subprocess.DEVNULL
).decode("utf-8").strip()
envvars["VITE_DISPATCH_COMMIT_DATE"] = commit_date
except (subprocess.CalledProcessError, FileNotFoundError):
# If git is not available or not in a git repo, use a default value
envvars["VITE_DISPATCH_COMMIT_DATE"] = "Unknown"
is_windows = os.name == "nt"
windows_cmds = ["cmd", "/c"]
default_cmds = ["npm", "run", "serve"]
Expand Down
25 changes: 17 additions & 8 deletions src/dispatch/static/dispatch/src/app/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const getDefaultRefreshState = () => {

const latestCommitHash = import.meta.env.VITE_DISPATCH_COMMIT_HASH
const latestCommitMessage = import.meta.env.VITE_DISPATCH_COMMIT_MESSAGE
const latestCommitDate = import.meta.env.VITE_DISPATCH_COMMIT_DATE

const state = {
toggleDrawer: true,
Expand All @@ -18,6 +19,7 @@ const state = {
},
loading: false,
currentVersion: latestCommitHash,
currentVersionDate: latestCommitDate,
}

const getters = {
Expand All @@ -36,14 +38,21 @@ const actions = {
commit("SET_LOADING", value)
},
showCommitMessage({ commit }) {
commit(
"notification_backend/addBeNotification",
{
text: `Hash: ${latestCommitHash} | Message: ${latestCommitMessage}`,
type: "success",
},
{ root: true }
)
if (latestCommitHash && latestCommitHash !== "Unknown" && latestCommitHash !== "dev-local") {
// Open GitHub commit URL in a new tab
const githubUrl = `https://github.com/Netflix/dispatch/commit/${latestCommitHash}`
window.open(githubUrl, "_blank")
} else {
// Fallback to showing notification for local development or unknown commits
commit(
"notification_backend/addBeNotification",
{
text: `Hash: ${latestCommitHash} | Message: ${latestCommitMessage}`,
type: "success",
},
{ root: true }
)
}
},
}

Expand Down
14 changes: 10 additions & 4 deletions src/dispatch/static/dispatch/src/components/AppToolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@
/>
<v-list-item
v-if="currentVersion()"
@click="showCommitMessage"
append-icon="mdi-page-next-outline"
:href="`https://github.com/Netflix/dispatch/commit/${currentVersion()}`"
target="_blank"
append-icon="mdi-open-in-new"
>
<v-list-item-title>
Current version: {{ formatHash(currentVersion()) }}
Current version: {{ formatHash(currentVersion())
}}{{
currentVersionDate() && currentVersionDate() !== "Unknown"
? ` (${currentVersionDate()})`
: ""
}}
</v-list-item-title>
</v-list-item>
</v-list>
Expand Down Expand Up @@ -230,7 +236,7 @@ export default {
})
},
...mapState("auth", ["currentUser"]),
...mapState("app", ["currentVersion"]),
...mapState("app", ["currentVersion", "currentVersionDate"]),
...mapActions("auth", ["logout", "getExperimentalFeatures"]),
...mapActions("search", ["setQuery"]),
...mapActions("organization", ["showCreateEditDialog"]),
Expand Down
Loading