Git Product home page Git Product logo

rhook's Introduction

rhook - Realm Git Hook

A git hook to work with Realm

Introduction

This repo contains a git commit-hook which can be used to check if Realm data model in your project has accidentally been modified without a migration. This way a commit shouldn't be made in the Realm data model without the related migration, avoid unexpected runtime crashes in your app!

How it works

This is based on a git pre-commit hook, which will be executed after a 'git commit' is typed and before the commit itself. Inside the hook script, we check if there is a file in the Realm data model of your project which has changes and if the migration file hasn't, in that case the hook script will exit non-zero and abort the commit.

This script is meant to be added as a "pre-commit"-hook. See this page for further information:

Customizing git - git hooks

Usage

Repo contains two files: 'pre-commit' which is the hook itself and a 'paths.json' file, which contains the paths needed by the hook script.

  • Copy the script in your '.git/hooks' folder (be sure that it has execution perms). Note: You can also make a symbolic link in your '.git/hooks' folder of your project to the file in this repo (recommended way, as it would be easier for you to update it)

  • Copy the 'paths.json' file in the root of your project and fill it with the needed paths (one for the Realm data model and other for the path of the file where you make your Realm migrations)

{
    "realmDataModelPath": "Your Realm data model path",
    "realmMigrationPath": "Your Realm Migration file path"
}

Example:

{
    "realmDataModelPath": "app/src/main/java/com/idealista/android/realm/entity/",
    "realmMigrationPath": "app/src/main/java/com/idealista/android/realm/Migration.java"
}

TODO

  • Improve hook logic related to migration checks in order to know if a migration for the Realm data model changed has been provided (now we only checks if Migration file has any changes).
  • Create a task for gradle to work with this.

License

Apache 2.0 Licence

This project is licensed under the Apache 2.0 license - see the LICENSE.txt file for details.

rhook's People

Contributors

vicfran avatar

Watchers

James Cloos avatar Jose del Pozo 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.