build branch commits

This commit is contained in:
Peter Evans 2024-08-08 14:08:16 +00:00
parent 477c78c3f2
commit 77c6c11180
3 changed files with 104 additions and 2 deletions

16
dist/index.js vendored
View file

@ -42,6 +42,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WorkingBaseType = void 0;
exports.getWorkingBaseAndType = getWorkingBaseAndType;
exports.tryFetch = tryFetch;
exports.buildBranchCommits = buildBranchCommits;
exports.buildBranchFileChanges = buildBranchFileChanges;
exports.createOrUpdateBranch = createOrUpdateBranch;
const core = __importStar(__nccwpck_require__(2186));
@ -83,6 +84,21 @@ function tryFetch(git, remote, branch, depth) {
}
});
}
function buildBranchCommits(git, base, branch) {
return __awaiter(this, void 0, void 0, function* () {
const output = yield git.exec(['log', '--format=%H', `${base}..${branch}`]);
const shas = output.stdout
.split('\n')
.filter(x => x !== '')
.reverse();
const commits = [];
for (const sha of shas) {
const commit = yield git.getCommit(sha);
commits.push(commit);
}
return commits;
});
}
function buildBranchFileChanges(git, base, branch) {
return __awaiter(this, void 0, void 0, function* () {
const branchFileChanges = {