mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2025-12-06 06:36:15 +00:00
AboutTab: add git commit if using -git version
This commit is contained in:
@@ -791,6 +791,9 @@
|
||||
},
|
||||
"noctalia": {
|
||||
"download-latest": "Neueste Version herunterladen",
|
||||
"git-commit": "Git-Commit:",
|
||||
"git-commit-copy": "Commit-Hash kopieren",
|
||||
"git-commit-loading": "Lädt...",
|
||||
"installed-version": "Installierte Version:",
|
||||
"latest-version": "Neueste Version:",
|
||||
"section": {
|
||||
|
||||
@@ -791,6 +791,9 @@
|
||||
},
|
||||
"noctalia": {
|
||||
"download-latest": "Download latest release",
|
||||
"git-commit": "Git commit:",
|
||||
"git-commit-copy": "Copy commit hash",
|
||||
"git-commit-loading": "Loading...",
|
||||
"installed-version": "Installed version:",
|
||||
"latest-version": "Latest version:",
|
||||
"section": {
|
||||
|
||||
@@ -791,6 +791,9 @@
|
||||
},
|
||||
"noctalia": {
|
||||
"download-latest": "Descargar la última versión",
|
||||
"git-commit": "Commit de Git:",
|
||||
"git-commit-copy": "Copiar hash del commit",
|
||||
"git-commit-loading": "Cargando...",
|
||||
"installed-version": "Versión instalada:",
|
||||
"latest-version": "Última versión:",
|
||||
"section": {
|
||||
|
||||
@@ -791,6 +791,9 @@
|
||||
},
|
||||
"noctalia": {
|
||||
"download-latest": "Télécharger la dernière version",
|
||||
"git-commit": "Commit Git :",
|
||||
"git-commit-copy": "Copier le hash du commit",
|
||||
"git-commit-loading": "Chargement...",
|
||||
"installed-version": "Version installée :",
|
||||
"latest-version": "Dernière version :",
|
||||
"section": {
|
||||
|
||||
@@ -791,6 +791,9 @@
|
||||
},
|
||||
"noctalia": {
|
||||
"download-latest": "最新版をダウンロード",
|
||||
"git-commit": "Gitコミット:",
|
||||
"git-commit-copy": "コミットハッシュをコピー",
|
||||
"git-commit-loading": "読み込み中...",
|
||||
"installed-version": "現在のバージョン:",
|
||||
"latest-version": "最新のバージョン:",
|
||||
"section": {
|
||||
|
||||
@@ -791,6 +791,9 @@
|
||||
},
|
||||
"noctalia": {
|
||||
"download-latest": "Nieuwste release downloaden",
|
||||
"git-commit": "Git commit:",
|
||||
"git-commit-copy": "Commit hash kopiëren",
|
||||
"git-commit-loading": "Laden...",
|
||||
"installed-version": "Geïnstalleerde versie:",
|
||||
"latest-version": "Nieuwste versie:",
|
||||
"section": {
|
||||
|
||||
@@ -791,6 +791,9 @@
|
||||
},
|
||||
"noctalia": {
|
||||
"download-latest": "Baixar a versão mais recente",
|
||||
"git-commit": "Commit Git:",
|
||||
"git-commit-copy": "Copiar hash do commit",
|
||||
"git-commit-loading": "Carregando...",
|
||||
"installed-version": "Versão instalada:",
|
||||
"latest-version": "Última versão:",
|
||||
"section": {
|
||||
|
||||
@@ -791,6 +791,9 @@
|
||||
},
|
||||
"noctalia": {
|
||||
"download-latest": "Скачать последний выпуск",
|
||||
"git-commit": "Git коммит:",
|
||||
"git-commit-copy": "Скопировать хеш коммита",
|
||||
"git-commit-loading": "Загрузка...",
|
||||
"installed-version": "Установленная версия:",
|
||||
"latest-version": "Последняя версия:",
|
||||
"section": {
|
||||
|
||||
@@ -791,6 +791,9 @@
|
||||
},
|
||||
"noctalia": {
|
||||
"download-latest": "En son sürümü indir",
|
||||
"git-commit": "Git commit:",
|
||||
"git-commit-copy": "Commit hash'ini kopyala",
|
||||
"git-commit-loading": "Yükleniyor...",
|
||||
"installed-version": "Yüklü sürüm:",
|
||||
"latest-version": "En son sürüm:",
|
||||
"section": {
|
||||
|
||||
@@ -791,6 +791,9 @@
|
||||
},
|
||||
"noctalia": {
|
||||
"download-latest": "Завантажити останній реліз",
|
||||
"git-commit": "Git коміт:",
|
||||
"git-commit-copy": "Скопіювати хеш коміту",
|
||||
"git-commit-loading": "Завантаження...",
|
||||
"installed-version": "Встановлена версія:",
|
||||
"latest-version": "Остання версія:",
|
||||
"section": {
|
||||
|
||||
@@ -791,6 +791,9 @@
|
||||
},
|
||||
"noctalia": {
|
||||
"download-latest": "下载最新版本",
|
||||
"git-commit": "Git提交:",
|
||||
"git-commit-copy": "复制提交哈希",
|
||||
"git-commit-loading": "加载中...",
|
||||
"installed-version": "已安装版本:",
|
||||
"latest-version": "最新版本:",
|
||||
"section": {
|
||||
|
||||
@@ -14,11 +14,98 @@ ColumnLayout {
|
||||
property string latestVersion: GitHubService.latestVersion
|
||||
property string currentVersion: UpdateService.currentVersion
|
||||
property var contributors: GitHubService.contributors
|
||||
property string gitCommitHash: ""
|
||||
|
||||
readonly property int topContributorsCount: 20
|
||||
readonly property bool isGitVersion: root.currentVersion.endsWith("-git") || root.hasArchGitVersion()
|
||||
|
||||
property int _gitSearchDepth: 0
|
||||
readonly property int _maxGitSearchDepth: 5
|
||||
|
||||
spacing: Style.marginL
|
||||
|
||||
Component.onCompleted: {
|
||||
if (root.isGitVersion) {
|
||||
// First try to extract from Arch package version format (e.g., 3.4.0.r112.g3f00bec8-1)
|
||||
var archHash = root.extractCommitFromArchVersion();
|
||||
if (archHash) {
|
||||
root.gitCommitHash = archHash;
|
||||
} else {
|
||||
// Fall back to git command for git-cloned installations
|
||||
fetchGitCommit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function hasArchGitVersion() {
|
||||
// Check if version matches Arch package format: X.Y.Z.rN.gHASH-REV
|
||||
// Pattern: version.r<number>.g<hash>-<rev>
|
||||
return /\.r\d+\.g[0-9a-fA-F]+-/.test(root.currentVersion);
|
||||
}
|
||||
|
||||
function extractCommitFromArchVersion() {
|
||||
// Extract commit hash from Arch package version format
|
||||
// Format: 3.4.0.r112.g3f00bec8-1 or v3.4.0.r112.g3f00bec8-1
|
||||
// We want to extract the hash after ".g" and before "-"
|
||||
var match = root.currentVersion.match(/\.g([0-9a-fA-F]+)-/i);
|
||||
if (match && match[1]) {
|
||||
// Return first 7 characters (short hash)
|
||||
return match[1].substring(0, 7);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function fetchGitCommit() {
|
||||
// Try to find git repository starting from shellDir and going up
|
||||
var searchDir = Quickshell.shellDir || "";
|
||||
if (!searchDir) {
|
||||
Logger.w("AboutTab", "Cannot determine shell directory, skipping git commit fetch");
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset search depth
|
||||
root._gitSearchDepth = 0;
|
||||
|
||||
// Try current directory first, then parent directories
|
||||
gitCommitProcess.workingDirectory = searchDir;
|
||||
gitCommitProcess.running = true;
|
||||
}
|
||||
|
||||
Process {
|
||||
id: gitCommitProcess
|
||||
command: ["git", "rev-parse", "HEAD"]
|
||||
running: false
|
||||
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode === 0) {
|
||||
var commitHash = stdout.text.trim();
|
||||
if (commitHash) {
|
||||
// Show short hash (first 7 characters)
|
||||
root.gitCommitHash = commitHash.substring(0, 7);
|
||||
Logger.d("AboutTab", "Git commit hash:", root.gitCommitHash);
|
||||
}
|
||||
} else {
|
||||
// If git command fails, try parent directory (up to max depth)
|
||||
if (root._gitSearchDepth < root._maxGitSearchDepth) {
|
||||
var currentDir = gitCommitProcess.workingDirectory || "";
|
||||
var parentDir = currentDir.split("/").slice(0, -1).join("/");
|
||||
if (parentDir && parentDir !== currentDir && parentDir.length > 0) {
|
||||
root._gitSearchDepth++;
|
||||
gitCommitProcess.workingDirectory = parentDir;
|
||||
gitCommitProcess.running = true;
|
||||
} else {
|
||||
Logger.d("AboutTab", "Could not find git repository");
|
||||
}
|
||||
} else {
|
||||
Logger.d("AboutTab", "Could not find git repository (max search depth reached)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stdout: StdioCollector {}
|
||||
stderr: StdioCollector {}
|
||||
}
|
||||
|
||||
NHeader {
|
||||
label: I18n.tr("settings.about.noctalia.section.label")
|
||||
description: I18n.tr("settings.about.noctalia.section.description")
|
||||
@@ -54,6 +141,37 @@ ColumnLayout {
|
||||
color: Color.mOnSurface
|
||||
font.weight: Style.fontWeightBold
|
||||
}
|
||||
|
||||
// Git commit hash (only shown for -git versions)
|
||||
NText {
|
||||
visible: root.isGitVersion
|
||||
text: I18n.tr("settings.about.noctalia.git-commit")
|
||||
color: Color.mOnSurface
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
visible: root.isGitVersion
|
||||
spacing: Style.marginXS
|
||||
|
||||
NText {
|
||||
text: root.gitCommitHash || I18n.tr("settings.about.noctalia.git-commit-loading")
|
||||
color: Color.mOnSurface
|
||||
font.weight: Style.fontWeightBold
|
||||
font.family: "monospace"
|
||||
}
|
||||
|
||||
NIconButton {
|
||||
visible: root.gitCommitHash !== ""
|
||||
icon: "clipboard-copy"
|
||||
tooltipText: I18n.tr("settings.about.noctalia.git-commit-copy")
|
||||
baseSize: Style.baseWidgetSize * 0.7
|
||||
onClicked: {
|
||||
if (root.gitCommitHash) {
|
||||
Quickshell.execDetached(["sh", "-c", `echo -n "${root.gitCommitHash}" | wl-copy`]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update button
|
||||
|
||||
Reference in New Issue
Block a user