Skip to content
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

Config option to update files only in defined paths #3357

Open
kusamakura opened this issue May 16, 2024 · 0 comments
Open

Config option to update files only in defined paths #3357

kusamakura opened this issue May 16, 2024 · 0 comments

Comments

@kusamakura
Copy link

We recently got a dependency update PR which contains incorrectly updated files that had, by chance, matching versions with the dependency.
Screenshot 2024-05-16 at 18 19 10

In my investigation, I suppose that this mistake comes from this place in the code:

def findVersionPositions(
repo: Repo,
config: RepoConfig,
version: Version
): F[List[VersionPosition]] =
findPathsContaining(repo, config, version.value)
.map(VersionPositionScanner.findPositions(version, _))
.compile
.foldMonoid

Coupled with the fact that we are using an unrestrained git grep to find the version matches:
override def findFilesContaining(repo: File, string: String): F[List[String]] =
git("grep", "-I", "--fixed-strings", "--files-with-matches", string)(repo)
.handleError(_ => List.empty[String])
.map(_.filter(_.nonEmpty))

I could be mistaken in my opinion, but for version updates, I think this grep function is too aggressive/eager, and could use extra arguments to search only in defined paths, i.e. the resulting git grep command could be something like:
git grep -I --fixed-strings --files-with-matches 'version' -- 'project' '*.sbt'

I suggest that the extra path arguments be exposed in a new configuration key called something like updates.whitelistGlob. I'm sure there's a better way to call it, though.

I'm not familiar enough with the codebase but I'd be happy to create a PR if this feature is agreeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant