]> Git Repo - pico-vscode.git/commitdiff
Ensure examples clone is up to date
authorWilliam Vinnicombe <[email protected]>
Thu, 8 Aug 2024 16:20:01 +0000 (17:20 +0100)
committerWilliam Vinnicombe <[email protected]>
Thu, 8 Aug 2024 16:20:01 +0000 (17:20 +0100)
src/utils/download.mts
src/utils/examplesUtil.mts
src/utils/gitUtil.mts

index 7955491263503c2f789e262ee9efae835329624d..cb1f74986692f1a2e01034c9c0985b2f105824e2 100644 (file)
@@ -768,13 +768,15 @@ export async function downloadAndInstallOpenOCD(
   }.${assetExt}`;
 
   const extraCallback = (): void => {
-    // on darwin and linux platforms create windows compatible alias
-    // so confiuration works on all platforms
-    symlinkSync(
-      join(targetDirectory, "openocd"),
-      join(targetDirectory, "openocd.exe"),
-      "file"
-    );
+    if (process.platform !== "win32") {
+      // on darwin and linux platforms create windows compatible alias
+      // so confiuration works on all platforms
+      symlinkSync(
+        join(targetDirectory, "openocd"),
+        join(targetDirectory, "openocd.exe"),
+        "file"
+      );
+    }
   };
 
   return downloadAndInstallGithubAsset(
index 167f45301b8341ce7bede8004a67b7bcaf7fdc73..183dcb2b1a1eab24ef5094c66758f1893daacfdf 100644 (file)
@@ -1,8 +1,8 @@
 import { join as joinPosix } from "path/posix";
 import Logger from "../logger.mjs";
-import { existsSync, readFileSync } from "fs";
+import { existsSync, readFileSync, rmSync } from "fs";
 import { homedir } from "os";
-import { getGit, sparseCheckout, sparseCloneRepository } from "./gitUtil.mjs";
+import { getGit, sparseCheckout, sparseCloneRepository, execAsync } from "./gitUtil.mjs";
 import Settings from "../settings.mjs";
 import { checkForInstallationRequirements } from "./requirementsUtil.mjs";
 import { cp } from "fs/promises";
@@ -16,6 +16,10 @@ const EXAMPLES_REPOSITORY_URL =
 const EXAMPLES_JSON_URL =
   "https://raspberrypi.github.io/pico-vscode/" +
   `${CURRENT_DATA_VERSION}/examples.json`;
+const EXAMPLES_GITREF = 
+  "7fe60d6b4027771e45d97f207532c41b1d8c5418";
+const EXAMPLES_TAG = 
+  "sdk-2.0.0";
 
 export interface Example {
   path: string;
@@ -134,10 +138,23 @@ export async function setupExample(
 
   const gitPath = await getGit(settings);
 
+  if (existsSync(examplesRepoPath)) {
+    let ref = await execAsync(
+      `cd "${examplesRepoPath}" && ${
+        process.env.ComSpec === "powershell.exe" ? "&" : ""
+      }"${gitPath}" rev-parse HEAD`
+    );
+    Logger.log(`Examples git ref is ${ref.stdout}\n`);
+    if (ref.stdout.trim() !== EXAMPLES_GITREF) {
+      Logger.log(`Removing old examples repo\n`);
+      rmSync(examplesRepoPath, { recursive: true, force: true });
+    }
+  }
+
   if (!existsSync(examplesRepoPath)) {
     const result = await sparseCloneRepository(
       EXAMPLES_REPOSITORY_URL,
-      "master",
+      EXAMPLES_TAG,
       examplesRepoPath,
       gitPath
     );
index 18b3b1b9f2444a2aa38b7cc388ff36ebf29d51bc..230e40c9ea69580970f2e42f20398060426f3471 100644 (file)
@@ -8,7 +8,7 @@ import { homedir } from "os";
 import which from "which";
 import { window } from "vscode";
 
-const execAsync = promisify(exec);
+export const execAsync = promisify(exec);
 
 /**
  * Get installed version of git, and install it if it isn't already
This page took 0.032586 seconds and 4 git commands to generate.