From 66468afe2a48df3d9af5fcedcbf4af91bf84e86f Mon Sep 17 00:00:00 2001 From: Yuta Nakamura Date: Thu, 30 Nov 2023 22:30:19 +0900 Subject: [PATCH] test --- dist/index.js | 22 ++++++++++++++-------- src/git-util.ts | 6 +++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/dist/index.js b/dist/index.js index ac474df..4f5c003 100644 --- a/dist/index.js +++ b/dist/index.js @@ -34382,21 +34382,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.hasCommitsBetween = exports.fetchRemoteBranches = void 0; +exports.hasCommitsBetween = exports.fetchRemoteBranches = exports.fullFetch = void 0; const core_1 = __nccwpck_require__(9093); const promises_1 = __nccwpck_require__(3292); const path = __importStar(__nccwpck_require__(1017)); const simple_git_1 = __importDefault(__nccwpck_require__(791)); const git = (0, simple_git_1.default)(); -async function listGitDirectory() { - const dir = ".git"; - const files = await (0, promises_1.readdir)(dir); - return files.map((file) => path.join(dir, file)); +/** + * Fetches all commits from the remote repository + */ +async function fullFetch() { + (0, promises_1.access)(path.join(".git", "shallow")) + .then(async () => { + await git.fetch(["--unshallow"]); + }) + .catch(async () => { + await git.fetch([]); + }); } +exports.fullFetch = fullFetch; async function fetchRemoteBranches() { - const files = await listGitDirectory(); - (0, core_1.info)(files.join("\n")); - await git.fetch(["--unshallow"]); + await fullFetch(); const branches = await git.branch(["-r"]); return branches.all.map((branch) => branch.replace("origin/", "")); } diff --git a/src/git-util.ts b/src/git-util.ts index 8587817..5afc0a2 100644 --- a/src/git-util.ts +++ b/src/git-util.ts @@ -26,7 +26,7 @@ export async function fetchRemoteBranches() { export async function hasCommitsBetween( srcBranch: string, - targetBranch: string + targetBranch: string, ) { const commits = await git.log({ from: srcBranch, @@ -35,8 +35,8 @@ export async function hasCommitsBetween( }); debug( `Commits between ${srcBranch} and ${targetBranch}: ${JSON.stringify( - commits - )}` + commits, + )}`, ); return commits.total > 0; }