I have a mono repo and I want to figure out "per package" diff in Github actions.
I'm using git rev-list --format=%aN%cN%B <from-tag>..HEAD -- packages/<name>
, which is working fine and giving all commits to analyse.
However, some of commits are squashed using default Github notation (ends with PR number (#1234)
). In this case I want to "unsquash" the commit by replacing it with all commits in PR (with directory filter).
So I was trying to use @octokit/rest
for this to obtain PR base
and head
SHAs like following:
import { Octokit } from '@octokit/rest'
import get from 'lodash/get'
const octokit = new Octokit()
const pr = await octokit.rest.pulls.get({
owner: '<owner-name>',
repo: '<repo-name>',
pull_number: <pull-number>,
})
const baseSha = get(pr, ['data', 'base', 'sha'], null)
const headSha = get(pr, ['data', 'head', 'sha'], null)
And then running the same command above, but for a different range: git rev-list --format=%aN%cN%B <baseSha>..<headSha>-- packages/<name>
.
The problem is after Squash and Merge PRs some branches can be deleted. So, they're not available for git.
It seems that there are two ways to go here:
- Somehow tell the git about the deleted branches
- Get this information from octokit
The first option sounds impossible, so the question is:
Is there a way to obtain this information in simple way, like git rev-list
does (no sub-request for each commit to receive file list)?