A highly customizable framework to quantify a pull request within a repository context to drive a optimal PR experience.
- Counts pull request changes with high accuracy
- Uses git history to provide a repository level context to the pull request
- Provides customizations through a yaml file for fine grained behavior control
- .NET 7.0 runtime is required for the framework to work properly.
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a balance between between PR complexity and PR review overhead. PRs within the optimal size (typical small, or medium sized PRs) mean:
- Fast and predictable releases to production:
- Optimal size changes are more likely to be reviewed faster with fewer iterations.
- Similarity in low PR complexity drives similar review times.
- Review quality is likely higher as complexity is lower:
- Bugs are more likely to be detected.
- Code inconsistencies are more likely to be detected.
- Knowledge sharing is improved within the participants:
- Small portions can be assimilated better.
- Better engineering practices are exercised:
- Solving big problems by dividing them in well contained, smaller problems.
- Exercising separation of concerns within the code changes.
- Use the PullRequestQuantifier to quantify your PR accurately
- Create a context profile for your repo using the context generator
- Exclude files that are not necessary to be reviewed or do not increase the
review complexity.
Example: Autogenerated code, docs, project IDE setting files, binaries, etc.
Check out the
Excluded
section from yourprquantifier.yaml
context profile. - Understand your typical change complexity, drive towards the desired complexity
by adjusting the label mapping in your
prquantifier.yaml
context profile. - Only use the labels that matter to you, see context specification
to customize your
prquantifier.yaml
context profile.
- Change your engineering behaviors
- For PRs that fall outside of the desired spectrum, review the details and check
if:
- Your PR could be split in smaller, self-contained PRs instead
- Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).
- For PRs that fall outside of the desired spectrum, review the details and check
if:
- One line was added:
+1 -0
- One line was deleted:
+0 -1
- One line was modified:
+1 -1
(git diff doesn't know about modified, it will interpret that line like one addition plus one deletion) - Change percentiles: Change characteristics (addition, deletion, modification) of this PR in relation to all other PRs within the repository.
How to develop new clients
Three steps
- Load the context, if available
- Call Quantifier
- Output the results
// 1. point to the context file (with behavior specification)
var contextFile = "path/to/context/file/prquantifier.yaml";
// 2. quantify local git repository
var quantifyClient = new QuantifyClient(contextFile);
var quantifierResult = await quantifyClient.Compute("path/to/local/git/repo");
// 3. output the results
Console.WriteLine(quantifierResult.Label);
Console.WriteLine(quantifierResult.QuantifiedLinesAdded);
Console.WriteLine(quantifierResult.QuantifiedLinesDeleted);
Context customization
See context specification for details of the yaml-based customization.
Download latest version of context generator and run it from the command line inside a git repository.
Developing
PullRequestQuantifier uses `netstandard2.1` for the main library(PullRequestQuantifier.Client) and `net5.0` for the unit tests (Xunit).
Build
From the root directory
dotnet build .\PullRequestQuantifier.sln
Test
From the root directory
dotnet test .\PullRequestQuantifier.sln
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.