Skip to content

Overrides Tracker tracks all monkey patches in your codebase and the methods they override. It allows for comparison between builds to reveal changes you might miss otherwise.

License

Notifications You must be signed in to change notification settings

chrismear/overrides_tracker

 
 

Repository files navigation

Overrides Tracker

Overrides Tracker keeps track of all overriding methods in your project and allows for comparison across branches.

Gem Version Coverage Status CircleCI

Contact

Code and Bug Reports

Getting started

  1. Add OverridesTracker to your Gemfile and bundle install:

    gem 'overrides_tracker', group: [:test, :development]
  2. Add overrides_tracker/*.otf to your .gitignore file because you want to keep hold of your report file when switching branches.

  3. Track you overrides by running:

    bundle exec overrides_tracker track

    The output will look like this.

    Reading all methods...
    Checking...AClass
    Checking...BClass
    Method is a new instance method: AClass#a_new_method
    Method is instance override: AClass#a_instance_method_override
    .
    .
    .
    Checking...YClass
    Method is a new singleton method: YClass#a_new_method
    Method is singleton override: YClass#a_singelton_method_override
    Checking...ZClass
    
    ===========
    Report saved to /PATH_TO_PROJECT/overrides_tracker/BRANCH_NAME#LAST_COMMIT_ID.otf
    
  4. This will create a folder called overrides_tracker and a file containing all methods you override as well as your overrides in that branch.

  5. Switch branch and follow steps 1-3 again. If you want to compare multiple branches you need to redo these steps for every branch.

  6. Now you have at least 2 files in the overrides_tracker folder

  7. It's time to compare these overrides accross branches.

    bundle exec overrides_tracker compare
  8. The result gives you an overview on what has changed and what not.

    ===========================================================================================
    
    1) Override: OrdinaryGem::AnotherTypicalClass#a_singleton_method_that_stays_the_same
    
    ...........................................................................................
    
    main#cc5a31dc4833734a177f01bd161047f8c7909e16.otf
    -------------------------------------------------------------------------------------------
    
    Original:
    
    def self.a_singleton_method_that_stays_the_same
      "This is the implementation of a simple singleton method."
      "This method will stay the same in the next version."
    end
    
    
    in BUNDLE_PATH/bundler/gems/ordinary-gem-e67e062189bb/lib/ordinary_gem/another_typical_class.rb:19
    
    
    -------------------------------------------------------------------------------------------
    
    Override:
    
    def self.a_singleton_method_that_stays_the_same
      "This is our override of a simple singleton method."
      "This method should stay the same in the next version."
    end
    
    
    in: APP_PATH/app/models/ordinary_gem/another_typical_class_monkey_patch.rb:2
    
    
    
    ...........................................................................................
    
    attached-to-next-version#a7231014c006a4a5848eb4d92bb465eb5c89ee01.otf
    -------------------------------------------------------------------------------------------
    
    Original:
    
    def self.a_singleton_method_that_stays_the_same
      "This is the implementation of a simple singleton method."
      "This method will stay the same in the next version."
    end
    
    
    in BUNDLE_PATH/bundler/gems/ordinary-gem-f92e5a1a70a6/lib/ordinary_gem/another_typical_class.rb:13
    
    
    -------------------------------------------------------------------------------------------
    
    Override:
    
    def self.a_singleton_method_that_stays_the_same
      "This is our override of a simple singleton method."
      "This method should stay the same in the next version."
    end
    
    
    in: APP_PATH/app/models/ordinary_gem/another_typical_class_monkey_patch.rb:2
    
    
    
    ...........................................................................................
    
    main#1d279724b26c9491e6e5a01e9711b61a73e9f7e0.otf
    Method not available
    
    
    
    
    
    ...........................................................................................
    .
    .
    .
    .
    ===========================================================================================
    
    Summary:
    
    Investigated methods: 70
    Diffences on overrides: 42
    Diffences on added methods: 28
    
    

Overrides.io integration

Bildschirm­foto 2023-01-10 um 21 39 42

Overrides.io is a service that monitors code you override for changes. It notifies you whenever those changes occur. Additionally it gives you a beautiful overview of all the methods you have overridden as well as your overrides side by side.

Bildschirm­foto 2023-01-10 um 21 39 15 Bildschirm­foto 2023-01-10 um 21 39 28

Overrides Tracker can easily be integrated into you CI/CD pipeline and configured to send the result files to overrides.io.

You basically just have to set OVERRIDES_API_TOKEN environment variable and call 'bundle exec overrides_tracker track'. To push it to overrides.io locally you could also just call 'bundle exec overrides_tracker track YOUR_OVERRIDES_API_TOKEN'.

You can find a detailed description how to integrate it with CircleCI, GitHub Action and Jenkins here:

https://www.overrides.io/continuous_integration

GEM support

Overrides Tracker can also be used on GEMs. It will autoload all classes in the lib and app folders.

Sometimes that is not enough:

If you need further requirements, you can just add a .overrides_tracker folder and add a requirements.rb file to it. In that one you can just require the classes your gem depends on.

You can also use the 'require_all' way to include complete folders, filter files etc..

Ruby version compatibility

Overrides Tracker is built in [Continuous Integration] on Ruby 2.3+.

Code of Conduct

Everyone participating in this project's development, issue trackers and other channels is expected to follow our Code of Conduct

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright

Copyright (c) 2023 Simon Meyborg. See MIT-LICENSE for details.

About

Overrides Tracker tracks all monkey patches in your codebase and the methods they override. It allows for comparison between builds to reveal changes you might miss otherwise.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 99.9%
  • Shell 0.1%