Git Utils fileMatch API design
See original GitHub issueLooks like a core bit of the git util functionality was removed with a refactor.
https://github.com/netlify/build/blame/master/packages/git-utils/README.md#L48-L53
The fileMatch
function should return a function that
Original code:
const micromatch = require('micromatch')
const mapValues = require('lodash.mapvalues')
const isExclude = p => p.startsWith('!')
module.exports = function fileMatcher(keyedPaths) {
function matchPatterns(patterns) {
return mapValues(keyedPaths, paths => {
const excludePatterns = patterns.filter(p => isExclude(p))
const includePatterns = patterns.filter(p => !isExclude(p))
const included = includePatterns.reduce((accum, pattern) => accum.concat(micromatch.match(paths, pattern)), [])
return excludePatterns.reduce((accum, pattern) => micromatch.match(accum, pattern), included)
})
}
function finalize(keyedPaths) {
return Object.assign(
Object.assign(
{},
mapValues(keyedPaths, paths => paths.length > 0),
),
{ getKeyedPaths: () => keyedPaths },
)
}
return (...patterns) => finalize(matchPatterns(patterns))
}
getKeyedPaths
returns an object that looks like:
{
modified: [ 'example.js', 'src/LocalGit.js' ],
created: [ 'src/index.js' ],
deleted: [ 'src/git/_tests/local_dangerfile_example.js' ],
edited: [ 'example.js', 'src/index.js' ]
}
This is quite important for advanced diffing functionality.
Can we please get this back in
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
How to use the danger.danger.git function in danger
To help you get started, we've selected a few danger.danger.git examples, based on popular ... if (jsAppFiles.length) { const listed = danger.github.utils.
Read more >Make Git Your API
This post describes your options and introduces fusebit/cloud-git, a pure JavaScript git server implementation for Node.js that lets you easily ...
Read more >What programming language is GitHub written in?
The language to learn depends on a number of things. Apple has swift and objectivec. They are integrate with the apple iOS sdk...
Read more >GitHub REST API Tutorial - REST API Support In GitHub
This GitHub Tutorial will explain how to use REST API for various ... have been useful for automating various scenarios for different tools....
Read more >Yaml schema validation golang - cittafamiglia.it
If you are looking for a more reproducible way, design your entities and create ... Under Jobs , click the Explore-GitHub-Actions job. xml...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think I prefer option 2 as well
the keys could return
false
as well if no files come back, which would further simplify usage:I think there’s also an argument to drop the
*Files
part for keys; I’m not sure it adds additional clarity vs:Done at #722.