icebear0828 Claude Opus 4.6 commited on
Commit
1b1294e
·
1 Parent(s): 7dfb571

fix: version display picks higher of git tag vs package.json

Browse files

On master branch, `git describe --tags` may find an old tag (v0.8.0)
since release tags live on the electron branch. Now both sources are
compared and the higher version wins, so package.json's synced version
(e.g. 1.0.16) is used correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. src/self-update.ts +17 -9
src/self-update.ts CHANGED
@@ -80,23 +80,31 @@ export function getProxyInfo(): ProxyInfo {
80
  let version: string | null = null;
81
  let commit: string | null = null;
82
 
83
- // Try git tag first (meaningful for versioned releases)
 
 
 
84
  try {
85
  const tag = execFileSync("git", ["describe", "--tags", "--abbrev=0", "HEAD"], {
86
  cwd: process.cwd(),
87
  encoding: "utf-8",
88
  timeout: 5000,
89
  }).trim();
90
- if (tag) version = tag.startsWith("v") ? tag.slice(1) : tag;
91
  } catch { /* no reachable tag */ }
92
 
93
- // Fall back to package.json (skip "1.0.0" placeholder on master)
94
- if (!version) {
95
- try {
96
- const pkg = JSON.parse(readFileSync(resolve(getRootDir(), "package.json"), "utf-8")) as { version?: string };
97
- const v = pkg.version;
98
- if (v && v !== "1.0.0") version = v;
99
- } catch { /* ignore */ }
 
 
 
 
 
100
  }
101
 
102
  try {
 
80
  let version: string | null = null;
81
  let commit: string | null = null;
82
 
83
+ // Collect version from both sources, pick the higher one
84
+ let tagVersion: string | null = null;
85
+ let pkgVersion: string | null = null;
86
+
87
  try {
88
  const tag = execFileSync("git", ["describe", "--tags", "--abbrev=0", "HEAD"], {
89
  cwd: process.cwd(),
90
  encoding: "utf-8",
91
  timeout: 5000,
92
  }).trim();
93
+ if (tag) tagVersion = tag.startsWith("v") ? tag.slice(1) : tag;
94
  } catch { /* no reachable tag */ }
95
 
96
+ try {
97
+ const pkg = JSON.parse(readFileSync(resolve(getRootDir(), "package.json"), "utf-8")) as { version?: string };
98
+ const v = pkg.version;
99
+ if (v && v !== "1.0.0") pkgVersion = v;
100
+ } catch { /* ignore */ }
101
+
102
+ // Pick whichever is higher (tag on electron branch may be unreachable from master)
103
+ if (tagVersion && pkgVersion) {
104
+ version = pkgVersion.localeCompare(tagVersion, undefined, { numeric: true }) > 0
105
+ ? pkgVersion : tagVersion;
106
+ } else {
107
+ version = tagVersion ?? pkgVersion;
108
  }
109
 
110
  try {