github / git-sizer

Compute various size metrics for a Git repository, flagging those that might cause problems
MIT License
3.48k stars 139 forks source link

Expand the use of refgroups #87

Closed mhagger closed 2 years ago

mhagger commented 3 years ago

Reference groups or "refgroups" were introduced in https://github.com/github/git-sizer/pull/84 as a way to limit the references that git-sizer uses as starting points when scanning repository contents. This PR expands on that feature in the following ways:

Putting this all together, one could use something like this config:

[refgroup "tags.releases"]
        name = Release tags
        includeRegexp = refs/tags/v\\d+\\.\\d+(\\.\\d+)?

and run git-sizer the following way to see counts of branches and tags, the latter broken down by release tags and other tags:

$ git-sizer -v --include=@branches --include=@tags
| Name                         | Value     | Level of concern               |
| ---------------------------- | --------- | ------------------------------ |
[…]
| * References                 |           |                                |
|   * Count                    |    18     |                                |
|     * Branches               |     5     |                                |
|     * Tags                   |     6     |                                |
|       * Release tags         |     5     |                                |
|       * Other                |     1     |                                |
|     * Ignored                |     7     |                                |
|                              |           |                                |
[…]

Any references that are excluded from the scan entirely are tallied under "Ignored".

I also made the --include and --exclude options more flexible. Aside from the existing --include=PREFIX style, one can now also use --include=/REGEXP/ as a shorter version of --include-regexp=REGEXP and --include=@REFGROUP as an equivalent of --refgroup=REFGROUP. The old-style versions of these options have been deprecated.

This PR is written so that it can be read commit-by-commit. It sprouts from the branch for https://github.com/github/git-sizer/pull/86 because it uses some of the new test features introduced by that PR.

/cc @ttaylorr and @tgummerer as possible reviewers.

mhagger commented 2 years ago

@tgummerer: Commit d508da2473307df13addd7a0d6c14bdd58bd433f should fix the problem that I mentioned here.