diff --git a/lib/htsget-lambda.ts b/lib/htsget-lambda.ts index 53c1958..5d73256 100644 --- a/lib/htsget-lambda.ts +++ b/lib/htsget-lambda.ts @@ -1,4 +1,6 @@ import { readFileSync } from "fs"; +import { join } from "node:path"; +import { tmpdir } from "os"; import { Aws, @@ -53,6 +55,7 @@ import { JwtConfig, } from "./config"; import { getManifestPath } from "cargo-lambda-cdk/lib/cargo"; +import { exec } from "cargo-lambda-cdk/lib/util"; /** * @ignore @@ -68,10 +71,23 @@ export class HtsgetLambda extends Construct { }; } + const gitRemote = "https://github.com/umccr/htsget-rs"; + const gitReference = props.gitReference; + const latestCommit = exec("git", [ + "ls-remote", + gitRemote, + gitReference || "HEAD", + ]) + .stdout.toString() + .split(/(\s+)/)[0]; + + const localPath = join(tmpdir(), latestCommit); + const manifestPath = getManifestPath({ - gitRemote: "https://github.com/umccr/htsget-rs", + manifestPath: join(localPath, "Cargo.toml"), + gitRemote, gitForceClone: props.gitForceClone, - gitReference: props.gitReference, + gitReference, }); const repoDir = path.dirname(manifestPath); diff --git a/package.json b/package.json index 4dc0273..da8ea50 100644 --- a/package.json +++ b/package.json @@ -36,5 +36,5 @@ "watch": "tsc -w", "typedoc": "typedoc" }, - "version": "0.8.1" + "version": "0.8.2" }