Skip to main content

check for uncommitted git changes to identify outdated generated content during continuous integration

Project description

PyPI Python Versions Build Status License

check_uncommitted_git_changes

check_uncommitted_git_changes is a command line tool to check for uncommitted git changes to identify outdated generated content during continuous integration.

The problem

While generated code generally should not be committed, there are cases for where it can make sense, for example *.po files containing translations that are derived from source code.

Developers might change the underlying source code but forget to generate the files derived from it. This causes headache for the next developer who wants to a translated message while implementing a separate task, and not has to deal with the outdated content in some way.

The solution

If your project uses continuous integration, you can use it to run the code generators. Ideally they produce the same code that has already been committed to the repository.

However, if a developer forgot to commit up to date generated code, the code generators will produce slightly different code that can for example be viewed using

git status

Calling check_uncommitted_git_changes after the generators have run can check for such changes. If there are none, its exit code is 0 and continuous integration can continue. If changes are found, the exit code is 1 and continuous integration fails.

Usage

Add check_uncommitted_git_changes to your projects using the respective command depending on how you manage your Python packages.

For poetry, run:

poetry add --dev check_uncommitted_git_changes

For setuptools, run:

pip install --upgrade check_uncommitted_git_changes

or add an entry to your *requirements.txt.

The following example outlines a GitHub action step that first collects all translated messages of a Django project and then checks if they differ from the versions found in the repository:

...
jobs:
  build:
    ...
    steps:
      ...
      - name: Check that translations are up to date
        run: |
          python manage.py makemessages --all --ignore venv --no-location --no-obsolete
          check_uncommitted_git_changes

The same principle can be applied to other continuous integration platforms.

License

Check_uncommitted_git_changes is open source and distributed under the BSD license. The source code is available from https://github.com/roskakori/check_uncommitted_git_changes.

Change history

See "CHANGES".

Development and contributing

For information on how to build the project and contribute to it see "CONTRIBUTING".

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

check_uncommitted_git_changes-1.0.1.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page