Skip to content

Instantly share code, notes, and snippets.

@hastebrot
Last active May 27, 2022
Embed
What would you like to do?
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/std@0.140.0/node/fs.ts";
import path from "https://deno.land/std@0.140.0/node/path.ts";
import git from "https://esm.sh/isomorphic-git@1.17.2";
import http from "https://esm.sh/isomorphic-git@1.17.2/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