Giter Site home page Giter Site logo

git-diff-analyzer's Introduction

Git Diff Analyzer

This github action will look at th differences from the current branch towards the branch determined by $GITHUB_REF and highlight based on the configuration if significant changes have taken place.

It will analyze all the file changes and do the following:

  • Compare the added & removed lines for each change that occurred in each file and determine the Levenshtein distance between the two versions
  • Validate the extension of the file:
    • files that are part of the allowed-file-types will be checked for the ld-threshold and have impact-level: considerable if above the threshold
    • other files will automatically count as impact-level: considerable
  • When there is no file with impact-level: considerable, it is deemed low

The impact level is returned as output, so it can be used in your workflow, e.g. to determine if a PR can automatically be approved.

Inputs

ld-threshold

Optional The maximum Levenshtein distance allowed for the changes to be considered as low impact. Default 10.

allowed-file-types

Optional The types of files that are analyzed. Default md.

git-base-ref

Optional The git base ref to compare against. Default is $GITHUB_BASE_REF, but this is only filled for pull requests. For use in other scenarios, define the base yourself.

Outputs

impact-level

The level of impact on the commit, this can be:

  • low : this means all analyzed files are below the set threshold
  • considerable : this means either files were changed that do not match allowed-file-types, or the changes in at least one of the analyzed files is above the threshold.

Example usage

jobs:
  test_job:
    runs-on: ubuntu-latest
    name: Test the action
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Diff Analyzer
        uses: raimondb/[email protected]
        id: diff-analyze
        with:
          ld-threshold: 8
          allowed-file-types: 'md'
      # Use the output from the previous step
      - name: Show the output
        run: echo "The change was impact-level ${{ steps.diff-analyze.outputs.impact-level }}"

git-diff-analyzer's People

Contributors

raimondb avatar

Watchers

 avatar

git-diff-analyzer's Issues

Git Diff not working in PR context

The git diff that is executed need a base reference branch.
Wrong context variable is now used (GITHUB_REF). It should be GITHUB_BASE_REF instead for a PR context.

To make the action also useable outside PR context, make the bas-ref configurable via the action and have the BASE_REF as a default.

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.