Code Monkey home page Code Monkey logo

insert-license-header's Introduction

Tool: insert-license-header

This python script automatically inserts your license header at the beginning of specified source code files.

Forked from Lucas-C/pre-commit-hooks and modified to realize the following behaviour:

⚠️ The behaviour of --dynamic-years changed in version 1.1.0.

Add argument --dynamic-years which determines the start year of the copyright time range automatically - based on when the file was first tracked with Git. If a start year is already present, it is not touched. If a file is not tracked by Git, the current year is used as start year. The end year is automatically set to the date of the last commit that affected the file. If an end year is already present that is in the future, don't touch it. It is, however, incremented if it lies in the past. If the file is not tracked by Git, use the current year.

Include a {year_start} and {year_end} in your license header to use this feature.

Add argument --license-base64 to include a license not via a file but through a base64 encoded string that is passed as a value for this argument. Obtain your license base64 encoded string with cat LICENSE.txt | base64. Including a license via --license-base64 {base64string} overrides the --license-filepath option.

⚠️ This is not a pre-commit hook anymore. Instead, this repository contains just the base script to insert licenses in text-based files. To check out the resulting pre-commit hook, visit: https://github.com/Quantco/pre-commit-insert-license

insert-license-header's People

Contributors

lucas-c avatar mdeweerd avatar thomasmarwitzqc avatar thomasmarwitz avatar aostrowski avatar antoined avatar yiftachkarkason avatar jumanjiman avatar mjpieters avatar potiuk avatar daisylb avatar oerp-odoo avatar chriskuehl avatar cclauss avatar henryiii avatar snoopj avatar njzjz avatar maxbachmann avatar vorburger avatar gadgetsteve avatar xaver-k avatar daniela-winkler avatar

Stargazers

Bela Stoyan avatar

Watchers

 avatar

insert-license-header's Issues

Issue when running with pre-commit

While transitioning codebases to utilize pre-commit-insert-license, I've noticed an issue when running as a pre-commit-hook with the —all option. This operation adds a license header to all files, with the header's content partially dependent on the file's last modification date.

For instance, the inserted header might appear as follows:

Copyright (c) Corp 2019-2021

Once this change is committed, the subsequent invocation of pre-commit will attempt to update the license header again. This is because the last modification date has now shifted to the current date, resulting in a new header that might look like this:

Copyright (c) Corp 2019-2024

To mitigate this, I propose that when insert-license-header adds a new header to a file that previously had none (while running as a pre-commit hook), it should use the current year as the end date. This change would prevent the generation of commits that fail their own pre-commit hooks.

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.