{"id":14963088,"url":"https://github.com/espressif/check-copyright","last_synced_at":"2025-10-19T08:31:50.705Z","repository":{"id":40765756,"uuid":"504062880","full_name":"espressif/check-copyright","owner":"espressif","description":"Pre-commit/gitlab-ci script for checking and adding license SPDX headers","archived":false,"fork":false,"pushed_at":"2025-01-09T13:49:55.000Z","size":30,"stargazers_count":9,"open_issues_count":0,"forks_count":7,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-01-31T17:17:34.764Z","etag":null,"topics":["ci","espressif","gitlab-ci","pre-commit-hook"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/espressif.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-16T07:52:13.000Z","updated_at":"2025-01-09T13:49:53.000Z","dependencies_parsed_at":"2022-07-19T14:39:00.690Z","dependency_job_id":null,"html_url":"https://github.com/espressif/check-copyright","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/espressif%2Fcheck-copyright","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/espressif%2Fcheck-copyright/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/espressif%2Fcheck-copyright/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/espressif%2Fcheck-copyright/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/espressif","download_url":"https://codeload.github.com/espressif/check-copyright/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237092674,"owners_count":19254251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","espressif","gitlab-ci","pre-commit-hook"],"created_at":"2024-09-24T13:31:00.171Z","updated_at":"2025-10-19T08:31:45.330Z","avatar_url":"https://github.com/espressif.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# check_copyright\n\nEspressif repository for the script to check SPDX License Header in the files. \n\n# Information about optional parameters\n\n| Short parameter name | Full parameter name       | Default value               | Description                                                                                    |\n|----------------------|---------------------------|-----------------------------|------------------------------------------------------------------------------------------------|\n| -v                   | --verbose                 | false                       | Print additional information for debugging                                                     |\n| -r                   | --replace                 | false                       | Tries to add/replace license header                                                            |\n| -m                   | --max-lines               | 30                          | How far to check for copyright notice in a file                                                |\n| -f                   | --fuzzy-ratio             | 95                          | Minimum %% ratio to be considered as equal to the old header style                             |\n| -d                   | --debug                   | false                       | Print debug info                                                                               |\n| -du                  | --dont-update-ignore-list | false                       | Don't update ignore list                                                                       |\n| -dr                  | --dry-run                 | false                       | Just check license headers without replace                                                     |\n| -i                   | --ignore                  | check_copyright_ignore      | Path to the file with list of ignoring files                                                   |\n| -l                   | --lines-changed           | 5                           | Minimum number of changed lines that will enforce copyright date update                        |\n| -c                   | --config                  | check_copyright_config.yaml | Path to the config file                                                                        |\n|                      | filenames                 | Require parameter           | Path to the folder or file to check. If it is a folder, all files will be analyzed recursively |\n\n# How to add check to a new project\n\n## Prepare steps:\n\nIf you want to add that script into your project, you should\n\n1. (Optional) Create file [with the list of ignoring files](#configure-ignore-list) (i.e. `ignore_list_copyright`) \n2. Create [config file](#creating-config-file) (i.e `check_copyright_config.yaml`)\n\n## As pre-commit\n\nYou can use this script as a [pre-commit](https://pre-commit.com/) hook. You should add pre-commit hook into \n`.pre-commit-config.yaml` with arguments `--replace` and `--config \u003cpath to the config\u003e`. \nYou can also add external arguments from the table above (i.e --verbose)\n\nExample of the .pre-commit-config.yaml file \n```yaml\n- repo: https://github.com/espressif/check-copyright/\n  rev: v1.0.0\n  hooks:\n    - id: check-copyright\n      args: ['--config', 'ci/check_copyright_config.yaml', '--ignore', 'ci/ignore_list_copyright']\n```\n\n## As CI\n\nFor CI you need to use flag --dry-run. Script returns list of files without SPDX header without trying to replace it.\n\nExample of Gitlab CI:\n```yaml\ncheck_copyright:\n  before_script:\n    - pip install git+https://github.com/espressif/check-copyright.git@master\n  script:\n    - python -m check_copyright --verbose --dry-run --ignore ci/ignore_list_copyright --config ci/check_copyright_config.yaml .\n```\n\n\n# Configure ignore list\n\nTo skip license header checks for some files, you can create a file with the list of paths to ignore. You should pass the path to the ignore list as the `--ignore` parameter.\n```text\ntools/test1/main/test_file.c\ntools/test1/tools/pythonTestFile.py\ninclude/new_project/pgenheaders.h\n...\n```\n\n# Creating config file\n\nYou also need to set rules for group of files, which licenses can be used etc:\n\n```yaml\nDEFAULT:\n  perform_check: yes  # should the check be performed?\n  # Sections setting this to 'no' don't need to include any other options as they are ignored\n  # When a file is using a section with the option set to 'no', no checks are performed.\n\n  # what licenses (or license expressions) are allowed for files in this section\n  # when setting this option in a section, you need to list all the allowed licenses\n  allowed_licenses:\n    - Apache-2.0\n  license_for_new_files: Apache-2.0  # license to be used when inserting a new copyright notice\n  new_notice_c: |  # notice for new C, CPP, H, HPP and LD files\n    /*\n     * SPDX-FileCopyrightText: {years} Espressif Systems (Shanghai) CO LTD\n     *\n     * SPDX-License-Identifier: {license}\n     */\n  new_notice_python: |  # notice for new python files\n    # SPDX-FileCopyrightText: {years} Espressif Systems (Shanghai) CO LTD\n    # SPDX-License-Identifier: {license}\n\n  # comment lines matching:\n  # SPDX-FileCopyrightText: year[-year] Espressif Systems\n  # or\n  # SPDX-FileContributor: year[-year] Espressif Systems\n  # are replaced with this template prefixed with the correct comment notation (# or // or *) and SPDX- notation\n  espressif_copyright: '{years} Espressif Systems (Shanghai) CO LTD'\n\n# You can create your own rules for files or group of files\nexamples_and_unit_tests:\n  include:\n   - 'examples/'\n   - 'components/**/test/**'\n   - 'components/**/test_apps/**'\n   - 'tools/test_apps/**'\n  allowed_licenses:\n  - Apache-2.0\n  - Unlicense\n  - CC0-1.0\n  license_for_new_files: Unlicense OR CC0-1.0\n\nignore:  # You can also select ignoring files here\n  perform_check: no  # Don't check files from that block\n  include:\n    - components/bt/host/nimble/nimble/\n    - components/bt/common/osi/\n    - components/bt/porting/ext/\n    - components/bt/porting/nimble/\n    - components/http_parser/\n    - components/wpa_supplicant/src/\n    - '!components/wpa_supplicant/esp_supplicant/'\n    - components/bt/host/bluedroid/\n    - '!components/bt/host/bluedroid/api/'\n    - '!components/bt/host/bluedroid/btc/'\n    - examples/zigbee/\n```\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fespressif%2Fcheck-copyright","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fespressif%2Fcheck-copyright","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fespressif%2Fcheck-copyright/lists"}