Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
bonyuta0204 committed Nov 30, 2023
1 parent 464a65c commit 66468af
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
22 changes: 14 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/", ""));
}
Expand Down
6 changes: 3 additions & 3 deletions src/git-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -35,8 +35,8 @@ export async function hasCommitsBetween(
});
debug(
`Commits between ${srcBranch} and ${targetBranch}: ${JSON.stringify(
commits
)}`
commits,
)}`,
);
return commits.total > 0;
}

0 comments on commit 66468af

Please sign in to comment.