-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output the stat data #126
base: master
Are you sure you want to change the base?
Output the stat data #126
Conversation
export async function listAllFilesAsAdded(): Promise<File[]> { | ||
return core.group(`Listing all files tracked by git`, async () => { | ||
const emptyTreeHash = (await exec('git', ['hash-object', '-t', 'tree', '/dev/null'])).stdout | ||
return getGitDiffStatusNumstat(emptyTreeHash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The git ls-files
does not return the data about the number of lines added. Comparing the current revision to an empty tree both allows getting the stat data, and lets us reuse the existing diff logic.
const matchingFilenamesList = Object.values(result).flatMap(filteredFiles => filteredFiles.map(file => file.filename)) | ||
const matchingFilenamesSet = new Set(matchingFilenamesList) | ||
result.other = files.filter(file => !matchingFilenamesSet.has(file.filename)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there already was a filter group named other
, it won't be overwritten. If the config did not have it, adding a new non-declared group should be safe - the keys are not in JSON, so it is unlikely that there exists logic in a step that uses paths-filter output that discovers the keys rather than uses the hardcoded names.
1396714
to
81575a9
Compare
Getting more data about the changes that are grouped by path would unlock new ways to use this action.
My motivation is to get enough data to make a comment with changes broken down by the filter groups - see the example. Another usecase would be to have a condition that applies a label depending on the number of lines changed. For example, marking a PR with few changes in
src
as easy to review.There is a new output
{key}_stat
with a JSON/CSV that has the numstat data, aggregated by the filter groups. In effect, the data is similar to what one would get by callinggit diff --shortstat <diff_refs> <list of filter globs>
for each filter group.Here are the details:
FileNumstat
andFileStatus
and rename the existing functions that deal withgit diff
to mention status.git diff --numstat
for all scenarios of getting the data from gitother
for the files not matched by any filters. This is not related to the numstat changes but supports the usecase for commenting the breakdown of changes.The only observable change for the existing users should be the addition of a new group
other
.