Skip to content

Instantly share code, notes, and snippets.

@hastebrot
Last active May 27, 2022 16:51
Show Gist options
  • Save hastebrot/1268c22907e90617f059d1ce1f360e40 to your computer and use it in GitHub Desktop.
Save hastebrot/1268c22907e90617f059d1ce1f360e40 to your computer and use it in GitHub Desktop.
isomorphic-git in deno
#!/usr/bin/env -S deno run --no-check --allow-env --allow-read --allow-write --allow-net isogit.ts
import fs from "https://deno.land/[email protected]/node/fs.ts";
import path from "https://deno.land/[email protected]/node/path.ts";
import git from "https://esm.sh/[email protected]";
import http from "https://esm.sh/[email protected]/http/node.js";
const repositoryDir = path.join(Deno.cwd(), "/../test-repository");
const repositoryUrl = "https://github.com/isomorphic-git/lightning-fs";
await git.clone({
fs,
http,
dir: repositoryDir,
url: repositoryUrl,
ref: "main",
singleBranch: true,
noCheckout: true,
});
const realRepositoryDir = await Deno.realPath(repositoryDir);
console.log("repository dir:", realRepositoryDir);
const commitObjectId = await git.resolveRef({
fs,
dir: realRepositoryDir,
ref: "HEAD",
});
const object = await git.readCommit({
fs,
dir: realRepositoryDir,
oid: commitObjectId,
});
console.log("commit object:", object);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment