GithubHelp home page GithubHelp logo

aishwarryavs / truegitcodechurn Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flacle/truegitcodechurn

0.0 0.0 0.0 34 KB

Python script to compute "true" code churn of a Git repository.

License: MIT License

Python 100.00%

truegitcodechurn's Introduction

True Git Code Churn

GitHub release version

A Python script to compute "true" code churn of a Git repository. Useful for software teams to openly help manage technical debt.

Code churn has several definitions, the one that to me provides the most value as a metric is:

"Code churn is when an engineer rewrites their own code in a short period of time."

Reference: https://www.pluralsight.com/blog/teams/why-code-churn-matters

Solutions that I've found online looked at changes to files irrespective whether these are new changes or edits to existing lines of code (LOC) within existing files. Hence this solution that segments line-of-code edits (churn) with new code changes (contribution).

Tested with Python version 3.5.3 and Git version 2.20.1

How it works

This lightweight script looks at commits per author for a given date range on the current branch. For each commit it bookkeeps the files that were changed along with the LOC for each file. LOC are kept in a sparse structure and changes per LOC are taken into account as the program loops. When a change to the same LOC is detected it updates this separately to bookkeep the true code churn. Result is a print with aggregated contribution and churn per author for a given period in time.

Note: This includes the --no-merges flag as it assumes that merge commits with or without merge conflicts are not indicative of churn.

Usage

Positional (required) arguments:

  • after        after a certain date, in YYYY[-MM[-DD]] format
  • before     before a certain date, in YYYY[-MM[-DD]] format
  • author     author string (not a committer), leave blank to scope all authors
  • dir            include Git repository directory

Optional arguments:

  • -h, --h, --help    show this help message and exit
  • -exdir                   exclude Git repository subdirectory

Usage Example 1

python ./gitcodechurn.py after="2018-11-29" before="2019-03-01" author="an author" dir="/Users/myname/myrepo" -exdir="excluded-directory"

Output 1

author:       an author
contribution: 844
churn:        -28

Usage Example 2

python ./gitcodechurn.py after="2018-11-29" before="2019-03-01" author="" dir="/Users/myname/myrepo" -exdir="excluded-directory"

Output 2

authors:      author1, author2, author3
contribution: 4423
churn:        -543

Outputs of Usage Example 1 can be used as part of a pipeline that generates bar charts for reports: contribution vs churn example chart

truegitcodechurn's People

Contributors

flacle avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.