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

Pathspec for allowlist #143

Closed
adamochayon opened this issue Apr 28, 2023 · 2 comments
Closed

Pathspec for allowlist #143

adamochayon opened this issue Apr 28, 2023 · 2 comments

Comments

@adamochayon
Copy link

Hey! I was looking to use the utility to calculate git stats within a specific directory only.
I tried using the pathspec env var but this only seemed to work for excluding and not including pathspecs.
Ideally I'd be able to run the utility such that I generate stats related only to changes within the specific pathspec (so an allowlist and not a blocklist).

Would love to know if that's possible, thanks so much!

@rickschubert
Copy link

I would also like to know how to use this, thank you!

@tomice
Copy link
Collaborator

tomice commented Oct 1, 2024

It works in the inverse as described. So in the README.md, _GIT_PATHSPEC is restricting the stats from directories or files. In this case, you would remove the ! for it to only follow directories.

Note that this feature only works on options that have the $_pathspec option. So that's detailedGitStats(), changelogs(), csvOutput(), contributors(), newContributors(), commitsPerDay(), commitsByTimezone(), and suggestedReviewers().

When using this repo as an example, if I select Suggested Reviewers (option #22 in interactive mode), I get the following:

Suggested code reviewers (based on git history):

     27 Tom Ice
     26 Lukas Mestan
      5 jdeguzman
      4 Joshua de Guzman
      3 arzzen
      3 Michael Czigler
      3 Ben Cotton
      2 s-okita
      2 frederic.cogny
      2 Sandro
      2 Matthieu Treussart
      2 Denys Havrysh
      2 B. van Berkum
      2 Andrej
      1 riderius
      1 pyxide
      1 jgtoriginal
      1 Y.D.X
      1 Rui Chen
      1 Pawaer
      1 Michael Robinson
      1 Matt Hickman
      1 Martin Schaaf
      1 Kevin Kuehler
      1 Jérémy WALTHER
      1 Jorge Maldonado Ventura
      1 Edwin Kofler
      1 Chandra Prakash
      1 Cameron Rodriguez

Then I set export _GIT_PATHSPEC="tests" to only show commits that have occurred in the tests directory. I re-run the commands. I get:

Suggested code reviewers (based on git history):

      9 Tom Ice
      5 Lukas Mestan
      2 Matthieu Treussart
      1 s-okita
      1 riderius
      1 pyxide
      1 Joshua de Guzman
      1 Denys Havrysh
      1 Ben Cotton
      1 B. van Berkum

If you'd like pathspec to be extended to more options, open up another issue with the ones you'd like supported, and we'll add it to the queue of enhancements :)

@tomice tomice closed this as completed Oct 1, 2024
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

3 participants