mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
feat: add git information display in update modals and enhance version check functionality
This commit is contained in:
@@ -2,6 +2,8 @@ import os
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import logging
|
import logging
|
||||||
import toml
|
import toml
|
||||||
|
import subprocess
|
||||||
|
from datetime import datetime
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from typing import Dict, Any, List
|
from typing import Dict, Any, List
|
||||||
|
|
||||||
@@ -25,6 +27,9 @@ class UpdateRoutes:
|
|||||||
# Read local version from pyproject.toml
|
# Read local version from pyproject.toml
|
||||||
local_version = UpdateRoutes._get_local_version()
|
local_version = UpdateRoutes._get_local_version()
|
||||||
|
|
||||||
|
# Get git info (commit hash, branch)
|
||||||
|
git_info = UpdateRoutes._get_git_info()
|
||||||
|
|
||||||
# Fetch remote version from GitHub
|
# Fetch remote version from GitHub
|
||||||
remote_version, changelog = await UpdateRoutes._get_remote_version()
|
remote_version, changelog = await UpdateRoutes._get_remote_version()
|
||||||
|
|
||||||
@@ -39,7 +44,8 @@ class UpdateRoutes:
|
|||||||
'current_version': local_version,
|
'current_version': local_version,
|
||||||
'latest_version': remote_version,
|
'latest_version': remote_version,
|
||||||
'update_available': update_available,
|
'update_available': update_available,
|
||||||
'changelog': changelog
|
'changelog': changelog,
|
||||||
|
'git_info': git_info
|
||||||
})
|
})
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -72,6 +78,72 @@ class UpdateRoutes:
|
|||||||
logger.error(f"Failed to get local version: {e}", exc_info=True)
|
logger.error(f"Failed to get local version: {e}", exc_info=True)
|
||||||
return "v0.0.0"
|
return "v0.0.0"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_git_info() -> Dict[str, str]:
|
||||||
|
"""Get Git repository information"""
|
||||||
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
plugin_root = os.path.dirname(os.path.dirname(current_dir))
|
||||||
|
|
||||||
|
git_info = {
|
||||||
|
'commit_hash': 'unknown',
|
||||||
|
'short_hash': 'unknown',
|
||||||
|
'branch': 'unknown',
|
||||||
|
'commit_date': 'unknown'
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Check if we're in a git repository
|
||||||
|
if not os.path.exists(os.path.join(plugin_root, '.git')):
|
||||||
|
return git_info
|
||||||
|
|
||||||
|
# Get current commit hash
|
||||||
|
result = subprocess.run(
|
||||||
|
['git', 'rev-parse', 'HEAD'],
|
||||||
|
cwd=plugin_root,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
text=True,
|
||||||
|
check=False
|
||||||
|
)
|
||||||
|
if result.returncode == 0:
|
||||||
|
git_info['commit_hash'] = result.stdout.strip()
|
||||||
|
git_info['short_hash'] = git_info['commit_hash'][:7]
|
||||||
|
|
||||||
|
# Get current branch name
|
||||||
|
result = subprocess.run(
|
||||||
|
['git', 'rev-parse', '--abbrev-ref', 'HEAD'],
|
||||||
|
cwd=plugin_root,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
text=True,
|
||||||
|
check=False
|
||||||
|
)
|
||||||
|
if result.returncode == 0:
|
||||||
|
git_info['branch'] = result.stdout.strip()
|
||||||
|
|
||||||
|
# Get commit date
|
||||||
|
result = subprocess.run(
|
||||||
|
['git', 'show', '-s', '--format=%ci', 'HEAD'],
|
||||||
|
cwd=plugin_root,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
text=True,
|
||||||
|
check=False
|
||||||
|
)
|
||||||
|
if result.returncode == 0:
|
||||||
|
commit_date = result.stdout.strip()
|
||||||
|
# Format the date nicely if possible
|
||||||
|
try:
|
||||||
|
date_obj = datetime.strptime(commit_date, '%Y-%m-%d %H:%M:%S %z')
|
||||||
|
git_info['commit_date'] = date_obj.strftime('%Y-%m-%d')
|
||||||
|
except:
|
||||||
|
git_info['commit_date'] = commit_date
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Error getting git info: {e}")
|
||||||
|
|
||||||
|
return git_info
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def _get_remote_version() -> tuple[str, List[str]]:
|
async def _get_remote_version() -> tuple[str, List[str]]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -95,7 +95,7 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.version-info {
|
.version-content .version-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
flex-direction: row !important;
|
flex-direction: row !important;
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.version-info .base-model {
|
.version-content .version-info .base-model {
|
||||||
background: oklch(var(--lora-accent) / 0.1);
|
background: oklch(var(--lora-accent) / 0.1);
|
||||||
color: var(--lora-accent);
|
color: var(--lora-accent);
|
||||||
padding: 2px 8px;
|
padding: 2px 8px;
|
||||||
|
|||||||
@@ -37,13 +37,11 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: rgba(0, 0, 0, 0.02); /* 轻微的灰色背景 */
|
|
||||||
border: 1px solid rgba(0, 0, 0, 0.08); /* 更明显的边框 */
|
|
||||||
border-radius: var(--border-radius-sm);
|
border-radius: var(--border-radius-sm);
|
||||||
padding: var(--space-3);
|
padding: var(--space-3);
|
||||||
}
|
}
|
||||||
|
|
||||||
.version-info {
|
.update-info .version-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
@@ -70,6 +68,15 @@
|
|||||||
color: var(--lora-accent);
|
color: var(--lora-accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add styling for git info display */
|
||||||
|
.git-info {
|
||||||
|
font-size: 0.85em;
|
||||||
|
opacity: 0.7;
|
||||||
|
margin-top: 4px;
|
||||||
|
font-family: monospace;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
.update-link {
|
.update-link {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ export class UpdateService {
|
|||||||
this.latestVersion = "v0.0.0"; // Initialize with default values
|
this.latestVersion = "v0.0.0"; // Initialize with default values
|
||||||
this.updateInfo = null;
|
this.updateInfo = null;
|
||||||
this.updateAvailable = false;
|
this.updateAvailable = false;
|
||||||
|
this.gitInfo = {
|
||||||
|
short_hash: "unknown",
|
||||||
|
branch: "unknown",
|
||||||
|
commit_date: "unknown"
|
||||||
|
};
|
||||||
this.updateNotificationsEnabled = getStorageItem('show_update_notifications');
|
this.updateNotificationsEnabled = getStorageItem('show_update_notifications');
|
||||||
this.lastCheckTime = parseInt(getStorageItem('last_update_check') || '0');
|
this.lastCheckTime = parseInt(getStorageItem('last_update_check') || '0');
|
||||||
}
|
}
|
||||||
@@ -62,6 +67,7 @@ export class UpdateService {
|
|||||||
this.currentVersion = data.current_version || "v0.0.0";
|
this.currentVersion = data.current_version || "v0.0.0";
|
||||||
this.latestVersion = data.latest_version || "v0.0.0";
|
this.latestVersion = data.latest_version || "v0.0.0";
|
||||||
this.updateInfo = data;
|
this.updateInfo = data;
|
||||||
|
this.gitInfo = data.git_info || this.gitInfo;
|
||||||
|
|
||||||
// Explicitly set update availability based on version comparison
|
// Explicitly set update availability based on version comparison
|
||||||
this.updateAvailable = this.isNewerVersion(this.latestVersion, this.currentVersion);
|
this.updateAvailable = this.isNewerVersion(this.latestVersion, this.currentVersion);
|
||||||
@@ -77,7 +83,8 @@ export class UpdateService {
|
|||||||
console.log("Update check complete:", {
|
console.log("Update check complete:", {
|
||||||
currentVersion: this.currentVersion,
|
currentVersion: this.currentVersion,
|
||||||
latestVersion: this.latestVersion,
|
latestVersion: this.latestVersion,
|
||||||
updateAvailable: this.updateAvailable
|
updateAvailable: this.updateAvailable,
|
||||||
|
gitInfo: this.gitInfo
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -152,6 +159,21 @@ export class UpdateService {
|
|||||||
if (currentVersionEl) currentVersionEl.textContent = this.currentVersion;
|
if (currentVersionEl) currentVersionEl.textContent = this.currentVersion;
|
||||||
if (newVersionEl) newVersionEl.textContent = this.latestVersion;
|
if (newVersionEl) newVersionEl.textContent = this.latestVersion;
|
||||||
|
|
||||||
|
// Update git info
|
||||||
|
const gitInfoEl = modal.querySelector('.git-info');
|
||||||
|
if (gitInfoEl && this.gitInfo) {
|
||||||
|
if (this.gitInfo.short_hash !== 'unknown') {
|
||||||
|
let gitText = `Commit: ${this.gitInfo.short_hash}`;
|
||||||
|
if (this.gitInfo.commit_date !== 'unknown') {
|
||||||
|
gitText += ` - Date: ${this.gitInfo.commit_date}`;
|
||||||
|
}
|
||||||
|
gitInfoEl.textContent = gitText;
|
||||||
|
gitInfoEl.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
gitInfoEl.style.display = 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update changelog content if available
|
// Update changelog content if available
|
||||||
if (this.updateInfo && this.updateInfo.changelog) {
|
if (this.updateInfo && this.updateInfo.changelog) {
|
||||||
const changelogContent = modal.querySelector('.changelog-content');
|
const changelogContent = modal.querySelector('.changelog-content');
|
||||||
|
|||||||
@@ -391,6 +391,7 @@
|
|||||||
<span class="label">Current Version:</span>
|
<span class="label">Current Version:</span>
|
||||||
<span class="version-number">v0.0.0</span>
|
<span class="version-number">v0.0.0</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="git-info" style="display:none;">Commit: unknown</div>
|
||||||
<div class="new-version">
|
<div class="new-version">
|
||||||
<span class="label">New Version:</span>
|
<span class="label">New Version:</span>
|
||||||
<span class="version-number">v0.0.0</span>
|
<span class="version-number">v0.0.0</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user