Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
bonyuta0204 committed Nov 30, 2023
1 parent 7b35033 commit 1b10628
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 11 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/auto-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
workflow_dispatch:
push:
branches:
- main
- test/ci
- test/*

jobs:
run:
Expand All @@ -19,9 +20,4 @@ jobs:
uses: ./
with:
src-branch: "release-stg"
target-branch: "main"
- name: Run a script
uses: ./
with:
src-branch: "main"
target-branch: "test/merge-target"
target-branch: "main"
52 changes: 50 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34355,16 +34355,56 @@ function wrappy (fn, cb) {

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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)();
/**
* Fetches all commits from the remote repository
*/
async function fullFetch() {
return (0, promises_1.access)(path.join(".git", "shallow"))
.then(async () => {
(0, core_1.debug)("Repository is shallow, fetching all commits");
await git.fetch(["--unshallow"]);
})
.catch(async () => {
(0, core_1.debug)("Repository is complete, fetching commits");
await git.fetch([]);
});
}
exports.fullFetch = fullFetch;
async function fetchRemoteBranches() {
await git.fetch([]);
await fullFetch();
const branches = await git.branch(["-r"]);
return branches.all.map((branch) => branch.replace("origin/", ""));
}
Expand Down Expand Up @@ -34463,6 +34503,14 @@ module.exports = require("fs");

/***/ }),

/***/ 3292:
/***/ ((module) => {

"use strict";
module.exports = require("fs/promises");

/***/ }),

/***/ 3685:
/***/ ((module) => {

Expand Down
21 changes: 19 additions & 2 deletions src/git-util.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import { debug } from "@actions/core";
import { debug, info } from "@actions/core";
import { readdir, access } from "fs/promises";
import * as path from "path";
import simpleGit from "simple-git";

const git = simpleGit();

/**
* Fetches all commits from the remote repository
*/
export async function fullFetch(): Promise<void> {
return access(path.join(".git", "shallow"))
.then(async () => {
debug("Repository is shallow, fetching all commits");
await git.fetch(["--unshallow"]);
})
.catch(async () => {
debug("Repository is complete, fetching commits");
await git.fetch([]);
});
}

export async function fetchRemoteBranches() {
await git.fetch([]);
await fullFetch();
const branches = await git.branch(["-r"]);
return branches.all.map((branch) => branch.replace("origin/", ""));
}
Expand Down

0 comments on commit 1b10628

Please sign in to comment.