UNPKG

@pagopa/dx-cli

Version:

A CLI useful to manage DX tools.

19 lines (18 loc) 688 B
import { getLogger } from "@logtape/logtape"; import { Octokit } from "octokit"; export const getLatestCommitSha = async (owner, repo, ref = "main") => { const octokit = new Octokit(); const response = await octokit.rest.repos.getCommit({ owner, ref, repo, }); return response.data.sha; }; export const getLatestCommitShaOrRef = async (owner, repo, ref = "main") => { const logger = getLogger(["dx-cli", "codemod"]); return getLatestCommitSha(owner, repo, ref).catch(() => { logger.warn("Failed to fetch the latest commit from {owner}/{repo}, fallback to {fallback}", { fallback: ref, owner, repo }); return ref; }); };