diff --git a/LICENSES/Apache-2.0.txt b/LICENSES/Apache-2.0.txt new file mode 100644 index 0000000..137069b --- /dev/null +++ b/LICENSES/Apache-2.0.txt @@ -0,0 +1,73 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + +To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/LICENSES/CC-BY-SA-4.0.txt b/LICENSES/CC-BY-SA-4.0.txt new file mode 100644 index 0000000..835a683 --- /dev/null +++ b/LICENSES/CC-BY-SA-4.0.txt @@ -0,0 +1,170 @@ +Creative Commons Attribution-ShareAlike 4.0 International + + Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. + +Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors. + +Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. + +Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public. + +Creative Commons Attribution-ShareAlike 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. + +Section 1 – Definitions. + + a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. + + c. BY-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License. + + d. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. + + e. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. + + f. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. + + g. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike. + + h. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. + + i. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. + + j. Licensor means the individual(s) or entity(ies) granting rights under this Public License. + + k. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. + + l. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. + + m. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. + +Section 2 – Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: + + A. reproduce and Share the Licensed Material, in whole or in part; and + + B. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. + + 3. Term. The term of this Public License is specified in Section 6(a). + + 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. + + 5. Downstream recipients. + + A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. + + B. Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply. + + C. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. + + 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this Public License. + + 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. + +Section 3 – License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified form), You must: + + A. retain the following if it is supplied by the Licensor with the Licensed Material: + + i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of warranties; + + v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; + + B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and + + C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. + + 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. + + b. ShareAlike.In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply. + + 1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License. + + 2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material. + + 3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply. + +Section 4 – Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; + + b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and + + c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. +For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. + +Section 5 – Disclaimer of Warranties and Limitation of Liability. + + a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. + + b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. + + c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. + +Section 6 – Term and Termination. + + a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or + + 2. upon express reinstatement by the Licensor. + + c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. + + d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. + + e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. + +Section 7 – Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. + +Section 8 – Interpretation. + + a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. + + c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. + + d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. + +Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 0000000..d817195 --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,18 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +associated documentation files (the "Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO +EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 75ddc71..f6b3cf0 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,10 @@ licet apply --dry-run # print the full plan without writing `apply` refuses to modify a dirty working tree unless `--allow-dirty`, so `git checkout` is always a clean undo. Writes are atomic (temp-file + rename). Missing standard license -texts are materialized into `LICENSES/` from the offline bundle; `LicenseRef-*` texts are -scaffolded as placeholders. +texts are materialized into `LICENSES/` from the offline bundle. A text that can't be +produced is **never** stubbed (a placeholder would falsely read as compliant): the apply +fails with guidance — the SPDX download URL for a standard id, or the `LICENSES/.txt` +path to create for a `LicenseRef-*`. ### `init` / `lint` @@ -107,9 +109,11 @@ licet add-license --all # every referenced-but-missing text ``` Unlike `apply`, it writes **only** under `LICENSES/` — it never edits source files or -`license.toml`, so it does not require a clean working tree. `LicenseRef-*` ids are -scaffolded as placeholders. Exit `0` on success, `1` if a requested text can't be supplied -offline, `2` on flag misuse (neither ids nor `--all`, or both). +`license.toml`, so it does not require a clean working tree. A standard id absent from the +bundle can be fetched with `--allow-curl` (an opt-in that shells out to your own `curl`; an +interactive terminal is asked y/N otherwise); `LicenseRef-*` ids are never fetched or stubbed. +Exit `0` on success, `1` if a requested text can't be supplied (naming its path/URL), `2` on +flag misuse (neither ids nor `--all`, or both). ### Shell completions @@ -132,7 +136,9 @@ Supported shells: `bash`, `zsh`, `fish`, `powershell`, `elvish`. ## Behavior guarantees - **Deterministic**: same inputs → same classification, ordering, and exit code. -- **Offline by default**: no network unless `--allow-network` is passed to `lint`. +- **Offline by default**: the binary ships no network capability; the only network access is + an explicit opt-in (`--allow-curl`, or an interactive y/N) that shells out to your own + `curl` to fetch standard SPDX texts absent from the bundle. - **Copyright-safe**: copyright/authorship preserved across a license-only replace. - **Detection precedence**: when an in-file header and out-of-band metadata disagree, the out-of-band value wins and a non-failing `source_override` warning is emitted. diff --git a/license.toml b/license.toml new file mode 100644 index 0000000..4f7a66e --- /dev/null +++ b/license.toml @@ -0,0 +1,17 @@ +# Generated by `licet init` from existing repository state. + +[default] +license = "MIT OR Apache-2.0" +copyright = "2026 Knitli Inc" + + +[[rule]] +glob = "**/*" +license = "MIT OR Apache-2.0" +copyright = "2026 Knitli Inc." + +[[rule]] +include = "docs/REUSE_Specification_v3.3.md" +license = "CC-BY-SA 4.0" +copyright = "2026 Free Software Foundation Europe (FSFE)" + diff --git a/mise.toml b/mise.toml index b399ea5..7ea0352 100644 --- a/mise.toml +++ b/mise.toml @@ -3,7 +3,7 @@ python = "3.13.14" rust = "nightly" git-cliff = "latest" cargo-release = "latest" -"cargo:licet" = "0.2.1" +"cargo:licet" = "0.2.2" [tools.'pipx:reuse'] version = "latest" diff --git a/specs/001-declarative-license-headers/contracts/cli.md b/specs/001-declarative-license-headers/contracts/cli.md index 43ea9e8..993e201 100644 --- a/specs/001-declarative-license-headers/contracts/cli.md +++ b/specs/001-declarative-license-headers/contracts/cli.md @@ -24,9 +24,10 @@ RuleConflict, missing license text} to exit `1`. `Uncovered` (FR-012a) and `Unre modified); `3` when some writes succeeded and others failed (FR-021). `add-license` exit semantics: `0` when every targeted text is present in `LICENSES/` -afterward; `1` when one or more requested/referenced texts could not be supplied (absent -from the bundle and not a `LicenseRef-*`, with `--allow-network` not given), naming the -identifier; `2` on flag misuse (neither identifiers nor `--all` given, or both). +afterward; `1` when one or more requested/referenced texts could not be supplied (a +`LicenseRef-*`, or an unbundled standard id not fetched because `--allow-curl` was not given +and the run was non-interactive), naming the identifier and its path/URL; `2` on flag misuse +(neither identifiers nor `--all` given, or both). ## Global flags @@ -93,7 +94,10 @@ licet apply [--additive] [--target-header ] [--allow-dirty] **`apply --dry-run`** answers "exactly what would `apply` change?" (per-file before/after). - Writes missing headers in the file's resolved comment style (FR-011), respecting shebang/encoding first-lines (FR-019). Materializes missing standard license texts into - `LICENSES/` from the offline bundle; scaffolds `LicenseRef-*` placeholders (FR-017). + `LICENSES/` from the offline bundle (against the **post-apply** references). A text that + cannot be produced — an unbundled standard id without `--allow-curl`, or any + `LicenseRef-*` — is **never** stubbed; it fails the apply (exit `1`) with guidance naming + the upstream URL or the path to create (FR-017). - On partial failure: exit `3`, report changed vs unchanged files (FR-021). **Acceptance**: destructive replaces a wrong `LicenseRef-MarqueLicense-1.0` under @@ -112,12 +116,14 @@ licet init [--from-reuse] [--output ] ## `lint` — REUSE-compatibility & license-text report (FR-014, FR-017; US5) ``` -licet lint [--allow-network] +licet lint ``` - Reports REUSE conformance posture: SPDX headers present, `LICENSES/` completeness, - out-of-band coverage for non-annotatable files. -- Lists referenced-but-missing license texts. Resolves known ids from the **offline - bundle**; `--allow-network` permits fetching only ids absent from the bundle (FR-017). + out-of-band coverage for non-annotatable files. Read-only: it never writes or fetches. +- Lists referenced-but-missing license texts with actionable guidance — bundled ids point + to `add-license`, other standard ids give the exact SPDX download URL, and `LicenseRef-*` + ids name the `LICENSES/.txt` path to create (FR-017). `LICENSES/` texts are recognized + under a `.txt`/`.md` suffix or none, matching `reuse`. - Reports the embedded **SPDX license-list version** so the compliance posture is auditable (FR-028). - Exit `1` if the repository would not pass a REUSE-spec compliance check. @@ -125,7 +131,7 @@ licet lint [--allow-network] ## `add-license` (alias `add`) — materialize license texts offline (FR-017, FR-029; US5) ``` -licet add-license [ …] [--all] [--allow-network] [--format …] +licet add-license [ …] [--all] [--allow-curl] [--format …] licet add … ``` - Copies referenced license texts into `LICENSES/` from the **embedded bundle** — the @@ -135,11 +141,14 @@ licet add … identifier referenced by the config and existing headers that is **missing** from `LICENSES/` (the parallel of `reuse download --all`). Supplying neither — and not `--all` — is a usage error → exit `2`; supplying both is also exit `2`. -- `LicenseRef-*` identifiers are scaffolded as empty placeholder texts for the maintainer to - fill in (FR-017); they are never fetched. -- `--allow-network`: permits fetching identifiers absent from the bundle; without it, an - unbundled non-`LicenseRef` identifier cannot be supplied and the run exits `1`, naming it - (consistent with `lint`). +- `LicenseRef-*` identifiers are **never** scaffolded as placeholders (a stub would falsely + satisfy REUSE's text-existence check). They cannot be fetched; the run exits `1` naming the + `LICENSES/.txt` path for the maintainer to create (FR-017). +- `--allow-curl`: permits shelling out to the system `curl` to fetch standard ids absent from + the bundle (the binary itself ships no network capability — offline-guard invariant — this + only runs a `curl` the user already has). Without the flag, an interactive terminal is + asked y/N; a non-interactive run leaves the id missing. An unfetched non-`LicenseRef` + identifier exits `1`, naming it and its SPDX download URL (consistent with `lint`). - Writes **only** under `LICENSES/`: it never modifies source files or `license.toml`, and therefore — unlike `apply` — does **not** require a clean working tree. (`apply` still materializes texts as a side-effect of annotating; `add-license` exposes that @@ -150,7 +159,10 @@ licet add … ## Behavior guarantees (cross-command) - **Deterministic**: same inputs → same classification, ordering, and exit code (FR-002). -- **Offline by default**: no network unless `--allow-network` is passed (FR-017). +- **Offline by default**: the binary ships no network capability (offline-guard invariant); + the only network access is an explicit opt-in that shells out to the user's own `curl` + (`--allow-curl`, or an interactive y/N), used solely to fetch standard SPDX texts absent + from the bundle (FR-017). - **Subset honoring**: when a selection flag is given, only those files are evaluated (FR-013), but rule precedence still considers the full ruleset. Selection flags are mutually exclusive (FR-027). diff --git a/specs/001-declarative-license-headers/data-model.md b/specs/001-declarative-license-headers/data-model.md index 5e52733..fb23021 100644 --- a/specs/001-declarative-license-headers/data-model.md +++ b/specs/001-declarative-license-headers/data-model.md @@ -211,7 +211,7 @@ Tracks referenced identifiers vs present texts in `LICENSES/` (FR-014, FR-017, F |-------|------|-------| | `referenced` | set of SPDX id | Every identifier used anywhere in the repo/config. | | `present` | set of SPDX id | Texts found under `LICENSES/`. | -| `missing` | derived set | `referenced − present` → reported; standard ids materializable from the embedded bundle offline; `LicenseRef-*` scaffolded as placeholders. The `add-license` command (FR-029) materializes this set (or an explicit subset) into `LICENSES/`. | +| `missing` | derived set | `referenced − present` → reported; standard ids materializable from the embedded bundle offline. A missing text is **never** stubbed with a placeholder (a stub would falsely pass REUSE's text-existence check): unbundled standard ids may be fetched via opt-in `curl` (`--allow-curl`, or an interactive y/N), and `LicenseRef-*` ids must be supplied by hand at `LICENSES/.txt`; otherwise the run errors with guidance. `present` recognizes the text under a `.txt`/`.md` suffix or none, matching `reuse`. The `add-license` command (FR-029) materializes this set (or an explicit subset) into `LICENSES/`. | | `bundled` | set of SPDX id | Identifiers whose text is embedded in the binary. | --- diff --git a/specs/001-declarative-license-headers/research.md b/specs/001-declarative-license-headers/research.md index 086119a..8671eee 100644 --- a/specs/001-declarative-license-headers/research.md +++ b/specs/001-declarative-license-headers/research.md @@ -159,10 +159,13 @@ diagnostic). Let the in-file header win (rejected — same decision). ## 8. Bundled license texts & acquisition (FR-017) **Decision**: Embed the full SPDX license-text set in the binary at build time. On -`apply`/`lint`, materialize any referenced-but-missing standard text into `LICENSES/` -from the bundle **offline**. Network fetch is opt-in (`--allow-network`) and only for -identifiers absent from the bundle. `LicenseRef-*` custom licenses are **scaffolded as -placeholder files** for the maintainer to fill. +`apply`/`add-license`, materialize any referenced-but-missing standard text into `LICENSES/` +from the bundle **offline**. A text that cannot be produced is **never** stubbed with a +placeholder — a stub would falsely pass REUSE's text-existence check and read as compliant. +Instead the run errors with guidance: standard ids give the exact SPDX download URL, +`LicenseRef-*` ids name the `LICENSES/.txt` path to create. Fetching is opt-in and only +for standard ids absent from the bundle: the binary ships no network capability (offline-guard +invariant), so `--allow-curl` (or an interactive y/N) shells out to the user's own `curl`. **Rationale**: Implements the clarified offline-by-default posture (hermetic CI) while still supporting unusual/custom identifiers. Embedding avoids any runtime download for the diff --git a/specs/001-declarative-license-headers/spec.md b/specs/001-declarative-license-headers/spec.md index e4248b7..34cbedf 100644 --- a/specs/001-declarative-license-headers/spec.md +++ b/specs/001-declarative-license-headers/spec.md @@ -118,7 +118,7 @@ The tool produces output that conforms to the REUSE specification (SPDX identifi 1. **Given** a repository the tool has reconciled, **When** a standard REUSE compliance check is run, **Then** it reports the repository as compliant. 2. **Given** an existing project with a `REUSE.toml` and annotated files, **When** the maintainer runs the bootstrap step, **Then** an initial declarative configuration is generated that, when projected, matches the project's current licensing. -3. **Given** a referenced license identifier whose text is not present, **When** the tool runs, **Then** it reports the missing license text (consistent with REUSE expectations) and can fetch or scaffold it. +3. **Given** a referenced license identifier whose text is not present, **When** the tool runs, **Then** it reports the missing license text (consistent with REUSE expectations) with actionable guidance, and **never** stubs a placeholder (which would falsely read as compliant): a standard id can be supplied from the bundle or fetched via opt-in `curl`, a custom `LicenseRef-*` must be added by hand, and otherwise the run fails. 4. **Given** a referenced license identifier whose standard text is bundled but absent from `LICENSES/`, **When** the maintainer runs the materialize command (`licet add-license `, or `--all` for every missing text), **Then** the text is written into `LICENSES/` from the embedded bundle without contacting the network and without modifying any source file or the configuration. --- @@ -163,7 +163,7 @@ The tool produces output that conforms to the REUSE specification (SPDX identifi - **FR-014**: The system MUST produce output conforming to the REUSE specification (SPDX header identifiers, a `LICENSES/` tree of referenced texts, and a recognized mechanism for non-annotatable files) so existing REUSE consumers remain compatible. - **FR-015**: The system MUST cover non-annotatable/binary files via a REUSE-compatible mechanism so they are still subject to enforcement, without byte-editing the asset. `apply` writes a `.license` sidecar by default, or appends a `REUSE.toml` annotation when configured (`[output] non_annotatable = "reuse-toml"`, or `--non-annotatable`). When a file is already *correctly* covered out-of-band, `apply` writes nothing. When it is covered but the recorded license is wrong, `apply` reconciles it where the coverage lives — rewriting the `REUSE.toml` annotation in place, or appending a more-specific exact-path annotation when only a glob matches (REUSE 3.3 last match wins); legacy `.reuse/dep5` coverage is reported for manual fixup rather than rewritten. All `REUSE.toml` writes MUST be idempotent. - **FR-016**: The system MUST allow paths to be explicitly excluded from coverage, and MUST distinguish explicit exclusions from accidental non-coverage in reporting. -- **FR-017**: The system MUST report referenced-but-missing license texts and MUST be able to supply the missing text. It MUST ship a bundled set of standard SPDX license texts and use them offline by default (no network access required for known identifiers). Fetching a text over the network MUST be limited to identifiers absent from the bundle and MUST require explicit opt-in; custom `LicenseRef-` licenses are scaffolded as placeholders for the maintainer to fill in. +- **FR-017**: The system MUST report referenced-but-missing license texts with actionable guidance and supply standard texts from a bundled set of SPDX license texts used offline by default (no network access required for known identifiers). It MUST recognize an existing `LICENSES/` text under a `.txt`/`.md` suffix or none (matching `reuse`), and MUST split a compound expression (e.g. `MIT OR Apache-2.0`) into its constituent identifiers rather than treating the whole expression as one filename. It MUST NOT stub a missing text with a placeholder — a placeholder would falsely satisfy REUSE's text-existence check and let a non-compliant repository read as compliant. Fetching a text over the network MUST be limited to standard identifiers absent from the bundle and MUST require explicit opt-in (a `--allow-curl` flag, or an interactive y/N confirmation, shelling out to the user's own `curl`; the binary itself ships no network capability). A custom `LicenseRef-` text MUST be provided by the maintainer at `LICENSES/.txt`; when a required text cannot be supplied, the run MUST fail rather than silently proceed. - **FR-018**: The system MUST be able to bootstrap an initial declarative configuration from an existing project's current state (including an existing `REUSE.toml` and existing headers). - **FR-019**: The system MUST insert headers in a position that respects required-first lines such as shebangs and encoding declarations. - **FR-020**: The system MUST warn when an operation produces an internally contradictory result (e.g., additive mode leaving two different declared licenses on one file). @@ -175,7 +175,7 @@ The tool produces output that conforms to the REUSE specification (SPDX identifi - **FR-026**: When writing or modifying a header the system MUST preserve the file's existing newline convention (LF vs CRLF) and MUST NOT introduce mixed line endings. - **FR-027**: The file-selection flags (`--staged`, `--changed`, `--files`/`--files-from`/stdin) MUST be mutually exclusive; supplying more than one is a usage error (exit 2). - **FR-028**: The system MUST report, in `--version` and in the `lint` output, the version of the embedded SPDX license list so operators can audit which license corpus a given binary carries. -- **FR-029**: The system MUST provide a standalone command to materialize referenced-but-missing license texts into the `LICENSES/` tree from the embedded bundle, without modifying any source file or the configuration. The command MUST accept either an explicit set of SPDX identifiers or an "all referenced-but-missing" mode, MUST scaffold `LicenseRef-*` identifiers as empty placeholders, and MUST honor the same offline-by-default / explicit-network-opt-in policy as FR-017 (never reaching the network for a bundled identifier). This is the offline analog of REUSE's `download`: because licet embeds the SPDX corpus, the operation is a copy from the bundle rather than a network fetch. Because it writes only under `LICENSES/`, it does not require a clean working tree. +- **FR-029**: The system MUST provide a standalone command to materialize referenced-but-missing license texts into the `LICENSES/` tree from the embedded bundle, without modifying any source file or the configuration. The command MUST accept either an explicit set of SPDX identifiers or an "all referenced-but-missing" mode, MUST NOT scaffold placeholders for `LicenseRef-*` (or any other) identifiers, and MUST honor the same offline-by-default / explicit-network-opt-in policy as FR-017 (never reaching the network for a bundled identifier, and fetching an unbundled standard id only under explicit opt-in). A text that cannot be supplied causes a non-zero exit naming the identifier and its `LICENSES/.txt` path or SPDX download URL. This is the offline analog of REUSE's `download`: because licet embeds the SPDX corpus, the operation is a copy from the bundle rather than a network fetch. Because it writes only under `LICENSES/`, it does not require a clean working tree. - **FR-030**: When detecting a file's in-file licensing, the system MUST honor REUSE 3.3 ignore blocks and SPDX snippets. Licensing information between `REUSE-IgnoreStart` and `REUSE-IgnoreEnd` (an unclosed `REUSE-IgnoreStart` extends to end of input) MUST be ignored entirely — it never contributes to the file's detected license or copyright. Licensing information inside an `SPDX-SnippetBegin`..`SPDX-SnippetEnd` region describes the *snippet*, not the file: it MUST NOT be treated as the file's license (so a snippet neither satisfies nor violates the file's declared intent), but any `SPDX-License-Identifier` it declares MUST still be counted among the referenced license texts for `LICENSES/` completeness (FR-014/FR-017). Ignore blocks take precedence over snippet markers. ### Key Entities *(include if data involved)* diff --git a/specs/001-declarative-license-headers/tasks.md b/specs/001-declarative-license-headers/tasks.md index 967646f..741f1f8 100644 --- a/specs/001-declarative-license-headers/tasks.md +++ b/specs/001-declarative-license-headers/tasks.md @@ -96,7 +96,7 @@ Single Rust project: library core in `src/`, integration/conformance/perf suites - [X] T023 [P] [US2] Implement the comment-style header writer (write side) in `src/comment/mod.rs`: render an SPDX header block in a given `CommentStyle` (line-prefix and block forms) (FR-011) - [X] T024 [P] [US2] Implement the first-line-aware inserter in `src/reconcile/insert.rs`: detect/skip shebang, encoding/XML decl, BOM and insert the header immediately after (FR-019, research.md §6) - [X] T025 [US2] Implement the reconcile engine in `src/reconcile/mod.rs`: destructive license-id replacement (default), additive append with contradiction detection, copyright preservation by default, and targeted-header selection among multiple blocks (FR-006, FR-007, FR-008, FR-009, FR-020) — depends on T023, T024 -- [X] T026 [US2] Implement offline license-text materialization in `src/reuse/inventory.rs`: write referenced-but-missing standard texts into `LICENSES/` from the embedded bundle and scaffold `LicenseRef-*` placeholders (FR-017) — depends on T007 +- [X] T026 [US2] Implement offline license-text materialization in `src/reuse/inventory.rs`: write referenced-but-missing standard texts into `LICENSES/` from the embedded bundle; never scaffold placeholders — surface unbundled/`LicenseRef-*` ids as still-missing with guidance, recognize `.txt`/`.md`/extension-less `LICENSES/` files, and offer opt-in `curl` fetch for standard ids (FR-017) — depends on T007 - [X] T027 [US2] Add symlink-safety dedup in `src/walk/mod.rs` so a file reached via symlink is annotated only once (Edge Cases) - [X] T028 [US2] Wire the `apply` command in `src/cli/apply.rs`: `--additive`, `--target-header `, `--dry-run` (emit ReconciliationPlan without writing); partial-apply reporting with exit 3; populate `change`/`warnings` in the JSON report (FR-007, FR-008, FR-021) — depends on T025, T026 @@ -156,15 +156,15 @@ Single Rust project: library core in `src/`, integration/conformance/perf suites - [X] T039 [P] [US5] Conformance test in `tests/conformance/reuse_compat.rs`: reconcile a fixture then assert the upstream `reuse lint` (or its spec checks) reports it compliant; gate-skip with a clear message if `reuse` is unavailable (SC-007) - [X] T040 [P] [US5] Integration test in `tests/integration/us5_init.rs`: `init --from-reuse` against a fixture with `REUSE.toml` + headers produces a `license.toml` whose projection matches current licensing (spec US5 scenarios 1–3, SC-008) -- [X] T051 [P] [US5] Integration suite in `tests/us5_add_license.rs` for the `add-license` command: explicit-id and `--all` materialization, idempotent re-run, `LicenseRef` placeholder scaffold, unknown-id exit 1, flag-misuse exit 2, dirty-tree tolerance + source/config untouched, and JSON shape (FR-029) +- [X] T051 [P] [US5] Integration suite in `tests/us5_add_license.rs` for the `add-license` command: explicit-id and `--all` materialization, idempotent re-run, `LicenseRef` never-scaffolded exit 1 with path guidance, compound-expression split, `.md` text recognition, unknown-id exit 1, flag-misuse exit 2, dirty-tree tolerance + source/config untouched, and JSON shape (FR-029) ### Implementation for User Story 5 - [X] T041 [P] [US5] Implement `LicenseTextInventory` reporting in `src/reuse/inventory.rs`: compute referenced/present/missing/bundled-available over `LICENSES/` and config (FR-014, FR-017) — extends T026 - [X] T042 [P] [US5] Implement out-of-band metadata writing for non-annotatable/binary files via `REUSE.toml` in `src/reuse/oob.rs`, reading `.reuse/dep5` for backward compatibility (FR-015, research.md §7) - [X] T043 [US5] Implement the `init`/bootstrap command in `src/cli/init.rs`: inspect existing headers + `REUSE.toml`/`.reuse/dep5` and emit `license.toml` (`--output`), modifying no source files (FR-018) — depends on T018, T009 -- [X] T044 [US5] Implement the `lint` command in `src/cli/lint.rs`: report REUSE posture (header presence, `LICENSES/` completeness, out-of-band coverage), list missing texts resolved from the offline bundle, `--allow-network` opt-in for ids absent from the bundle, exit 1 if non-compliant (FR-014, FR-017) — depends on T041, T042 -- [X] T052 [US5] Implement the `add-license` command (alias `add`) in `src/cli/add_license.rs`: materialize referenced license texts into `LICENSES/` from the offline bundle standalone — explicit ids or `--all` (mutually exclusive), `LicenseRef-*` placeholder scaffold, never touching source files/config or requiring a clean tree; exit 0/1/2 per cli.md. Wire into `src/cli/mod.rs`; repoint the `lint` missing-text hint from `apply` to `add-license` (FR-017, FR-029) — depends on T041 +- [X] T044 [US5] Implement the `lint` command in `src/cli/lint.rs`: report REUSE posture (header presence, `LICENSES/` completeness, out-of-band coverage), list missing texts with actionable guidance (bundle/add-license, SPDX URL, or `LICENSES/.txt` path), read-only/no fetch, exit 1 if non-compliant (FR-014, FR-017) — depends on T041, T042 +- [X] T052 [US5] Implement the `add-license` command (alias `add`) in `src/cli/add_license.rs`: materialize referenced license texts into `LICENSES/` from the offline bundle standalone — explicit ids or `--all` (mutually exclusive), never scaffolding placeholders, opt-in `--allow-curl`/interactive fetch for unbundled standard ids, never touching source files/config or requiring a clean tree; exit 0/1/2 per cli.md. Wire into `src/cli/mod.rs`; repoint the `lint` missing-text hint from `apply` to `add-license` (FR-017, FR-029) — depends on T041 **Checkpoint**: Output is REUSE-compliant, `lint` reports posture offline, and existing projects migrate via bootstrap. @@ -179,7 +179,7 @@ Single Rust project: library core in `src/`, integration/conformance/perf suites - [X] T047 [P] Write `README.md` usage docs and run the quickstart.md scenarios end-to-end as a documented manual/CI validation pass - [X] T048 [P] Add a `criterion` benchmark harness under `benches/` for scan throughput, tracking the SC-006 budget over time (`benches/scan.rs`, cold + warm cache groups; ~120k files/s observed) - [X] T049 Cross-platform release wiring (Linux/macOS/Windows, x86-64 + arm64) producing a single self-contained binary (`.github/workflows/release.yml` matrix via `taiki-e/upload-rust-binary-action`; Linux static musl; release notes via `git-cliff`/`cliff.toml`; versioning via `cargo-release`/`release.toml`) -- [X] T050 Final determinism + offline-by-default audit: confirm identical inputs → identical classification/ordering/exit code and no network without `--allow-network` (FR-002, FR-017) (`tests/determinism.rs`: byte-identical reports, sorted ordering, `--allow-network` is a no-op; verified zero network-capable crates in the dependency tree) +- [X] T050 Final determinism + offline-by-default audit: confirm identical inputs → identical classification/ordering/exit code and that the default paths reach no network (FR-002, FR-017) (`tests/determinism.rs`: byte-identical reports, sorted ordering, `lint` is offline & deterministic; verified zero network-capable crates in the dependency tree — the only network access is opt-in `--allow-curl`, which shells out to the user's own `curl`) --- diff --git a/src/cli/add_license.rs b/src/cli/add_license.rs index f56c6f8..7a2185e 100644 --- a/src/cli/add_license.rs +++ b/src/cli/add_license.rs @@ -2,9 +2,11 @@ //! from the embedded bundle, offline (FR-017, FR-029; US5). //! //! This is the offline analog of REUSE's `download`: because the SPDX corpus is embedded, -//! the operation is a copy from the bundle (or a `LicenseRef-*` placeholder scaffold), -//! never a network fetch. It writes **only** under `LICENSES/` — it never modifies a source -//! file or `license.toml`, and therefore does not require a clean working tree. +//! the operation is a copy from the bundle, never a network fetch (a `LicenseRef-*` or an +//! unbundled standard id is reported missing, never stubbed). Standard ids absent from the +//! bundle may be fetched only via an explicit opt-in that shells out to the user's own +//! `curl` (`--allow-curl`, or an interactive y/N). It writes **only** under `LICENSES/` — it +//! never modifies a source file or `license.toml`, and so does not require a clean tree. use std::collections::BTreeSet; @@ -56,8 +58,11 @@ pub fn run(args: AddLicenseArgs) -> Result { .collect(); let res = inventory::materialize(&root, &targets)?; + // Texts absent from the bundle: fetch standard SPDX ids via `curl` when opted in, + // otherwise leave them missing to report with a download link (never stub them). + let still_missing = super::resolve_missing_texts(&root, &res.still_missing, args.allow_curl); let after = LicenseTextInventory::compute(&root, &targets); - let success = res.still_missing.is_empty(); + let success = still_missing.is_empty(); match args.format { Format::Json => { @@ -93,15 +98,10 @@ pub fn run(args: AddLicenseArgs) -> Result { println!(" = {id}"); } } - if !res.still_missing.is_empty() { - println!("Unavailable offline:"); - for id in &res.still_missing { - let why = if args.allow_network { - "absent from bundle — network fetch is unavailable in this hermetic build" - } else { - "absent from bundle — needs --allow-network" - }; - println!(" ! {id} ({why})"); + if !still_missing.is_empty() { + println!("Could not materialize:"); + for id in &still_missing { + println!(" ! {}", inventory::missing_text_guidance(id)); } } } diff --git a/src/cli/apply.rs b/src/cli/apply.rs index 5ec54b5..69293ca 100644 --- a/src/cli/apply.rs +++ b/src/cli/apply.rs @@ -220,29 +220,35 @@ pub fn run(args: ApplyArgs) -> Result { }); } - // Materialize referenced-but-missing license texts (offline) unless dry-run. + // Re-scan post-write so the report, exit code, and license-text inventory reflect the + // actual on-disk result (dry-run keeps the pre-apply states, since nothing was written). + let partial = any_failure && any_success; + let (final_states, scan_warnings, post_referenced) = if args.dry_run { + (scan.states, scan.warnings.clone(), scan.referenced_ids) + } else { + let mut fresh = super::check::open_cache(&args.common, &root, &config_text); + let r = engine.scan(&selection, &mut fresh)?; + (r.states, r.warnings, r.referenced_ids) + }; + + // Materialize referenced-but-missing license texts (offline) unless dry-run, against the + // *post-apply* references so texts for licenses we just replaced are not sought. A text we + // cannot produce is a hard failure (FR-017): silently stubbing it would let a non-compliant + // repo read as compliant. Standard SPDX ids may be fetched via `curl` when the user opts in + // (`--allow-curl` or an interactive y/N); the rest fail with guidance. + let mut missing_texts: Vec = Vec::new(); if !args.dry_run - && let Ok(res) = inventory::materialize(&root, &scan.referenced_ids) + && let Ok(res) = inventory::materialize(&root, &post_referenced) { - for id in res.still_missing { + missing_texts = super::resolve_missing_texts(&root, &res.still_missing, args.allow_curl); + for id in &missing_texts { warnings.push(Warning { kind: "missing_license_text".to_string(), path: None, - message: format!("no offline text for `{id}` (use lint --allow-network)"), + message: inventory::missing_text_guidance(id), }); } } - - // Re-scan post-write so the report and exit code reflect the actual on-disk result - // (dry-run keeps the pre-apply states, since nothing was written). - let partial = any_failure && any_success; - let (final_states, scan_warnings) = if args.dry_run { - (scan.states, scan.warnings.clone()) - } else { - let mut fresh = super::check::open_cache(&args.common, &root, &config_text); - let r = engine.scan(&selection, &mut fresh)?; - (r.states, r.warnings) - }; // Final report warnings: post-write detection warnings, then apply-pass warnings. let mut all_warnings = scan_warnings; all_warnings.append(&mut warnings); @@ -250,7 +256,7 @@ pub fn run(args: ApplyArgs) -> Result { let exit = if partial { ExitCode::Partial - } else if has_unfixable(&final_states) || any_failure { + } else if has_unfixable(&final_states) || any_failure || !missing_texts.is_empty() { ExitCode::Violations } else { ExitCode::Success diff --git a/src/cli/lint.rs b/src/cli/lint.rs index 1a8b2ac..46f8e5b 100644 --- a/src/cli/lint.rs +++ b/src/cli/lint.rs @@ -4,7 +4,7 @@ use super::{Format, LintArgs}; use crate::config::LicensingConfiguration; use crate::engine::Engine; use crate::error::{ExitCode, Result}; -use crate::reuse::inventory::LicenseTextInventory; +use crate::reuse::inventory::{self, LicenseTextInventory}; use crate::spdx; use crate::walk::cache::ScanCache; use crate::walk::{Selection, discover_root}; @@ -54,16 +54,13 @@ pub fn run(args: LintArgs) -> Result { if !inv.missing.is_empty() { println!(" missing license texts:"); for id in &inv.missing { - let hint = if spdx::bundled_text(id).is_some() { - "available offline (run `licet add-license`)" - } else if spdx::is_license_ref(id) { - "custom LicenseRef — scaffold a placeholder" - } else if args.allow_network { - "absent from bundle — would fetch (network allowed)" + if spdx::bundled_text(id).is_some() { + println!( + " - `{id}` is available offline — run `licet add-license {id}`" + ); } else { - "absent from bundle — needs --allow-network" - }; - println!(" - {id} ({hint})"); + println!(" - {}", inventory::missing_text_guidance(id)); + } } } println!( diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 2476a0e..d33cd81 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -6,7 +6,7 @@ pub mod check; pub mod init; pub mod lint; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use clap::{Args, CommandFactory, Parser, Subcommand}; use clap_complete::Shell; @@ -190,6 +190,11 @@ pub struct ApplyArgs { /// How to cover non-annotatable files, overriding `[output] non_annotatable`. #[arg(long, value_enum)] pub non_annotatable: Option, + /// Permit shelling out to the system `curl` to fetch standard SPDX texts absent from + /// the offline bundle (see `add-license --allow-curl`). Without it, a missing license + /// text fails the apply with a download link instead of being silently stubbed. + #[arg(long)] + pub allow_curl: bool, } #[derive(Debug, Args)] @@ -212,9 +217,6 @@ pub struct LintArgs { pub config: PathBuf, #[arg(long, value_enum, default_value_t = Format::Human)] pub format: Format, - /// Permit fetching license ids absent from the offline bundle. - #[arg(long)] - pub allow_network: bool, } #[derive(Debug, Args)] @@ -225,10 +227,11 @@ pub struct AddLicenseArgs { /// Materialize every referenced-but-missing license text. #[arg(long)] pub all: bool, - /// Permit fetching ids absent from the offline bundle (the hermetic binary never - /// reaches the network; accepted for parity with `lint`/FR-017). + /// Permit shelling out to the system `curl` to fetch standard SPDX texts absent from + /// the offline bundle. The binary itself never reaches the network; this only runs a + /// `curl` you already have. Without it, a missing text errors with a download link. #[arg(long)] - pub allow_network: bool, + pub allow_curl: bool, /// Path to the declarative config (only read by --all to discover referenced ids). #[arg(long, default_value = "license.toml")] pub config: PathBuf, @@ -250,6 +253,50 @@ pub fn print_completions(shell: Shell) { clap_complete::generate(shell, &mut cmd, name, &mut std::io::stdout()); } +/// Resolve license texts left missing after an offline `materialize`. For standard SPDX +/// ids, fetch via `curl` when permitted — `allow_curl` grants it outright; otherwise an +/// interactive terminal is asked y/N (a non-TTY without the flag never fetches). +/// `LicenseRef-*` is never fetched. Returns the ids still missing afterward, for the caller +/// to report with [`crate::reuse::inventory::missing_text_guidance`] and fail on. +pub fn resolve_missing_texts(root: &Path, missing: &[String], allow_curl: bool) -> Vec { + use std::io::IsTerminal; + let interactive = std::io::stdin().is_terminal(); + let mut unresolved = Vec::new(); + for id in missing { + if spdx::is_license_ref(id) { + unresolved.push(id.clone()); + continue; + } + let permitted = allow_curl + || (interactive + && prompt_yes_no(&format!("Fetch `{id}` from SPDX via curl into LICENSES/?"))); + if !permitted { + unresolved.push(id.clone()); + continue; + } + match crate::reuse::inventory::fetch_via_curl(root, id) { + Ok(path) => println!(" ↓ fetched {id} → {}", path.display()), + Err(e) => { + eprintln!(" ! could not fetch {id}: {e}"); + unresolved.push(id.clone()); + } + } + } + unresolved +} + +/// Ask a y/N question on the terminal; any non-affirmative reply (including EOF) is No. +fn prompt_yes_no(question: &str) -> bool { + use std::io::Write; + print!("{question} [y/N] "); + let _ = std::io::stdout().flush(); + let mut line = String::new(); + if std::io::stdin().read_line(&mut line).is_err() { + return false; + } + matches!(line.trim(), "y" | "Y" | "yes" | "Yes" | "YES") +} + /// Render the `--version` line including the embedded SPDX list version (FR-028). pub fn version_string() -> String { format!( diff --git a/src/engine.rs b/src/engine.rs index 3a95b63..e192679 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -95,7 +95,10 @@ impl<'a> Engine<'a> { }); } if let Some(l) = &state.actual.detected_license { - referenced_ids.insert(l.clone()); + // The detected value may be a compound expression (`MIT OR Apache-2.0`); + // split it into constituent ids so each text is sought separately — never + // treat the whole expression as one `LICENSES/.txt` filename. + collect_ids(l, &mut referenced_ids); } // SPDX-snippet licenses are not the file's license, but their texts must still // exist under LICENSES/ for REUSE compliance (FR-030). diff --git a/src/report/mod.rs b/src/report/mod.rs index 1c8f27a..e93ebe5 100644 --- a/src/report/mod.rs +++ b/src/report/mod.rs @@ -123,11 +123,16 @@ impl Report { } } + // A referenced license text that could not be supplied is a compliance failure, not + // a mere warning: surfacing PASS here while exiting non-zero is exactly the "looks + // compliant when it isn't" trap we removed placeholders to avoid. + let missing_text = warnings.iter().any(|w| w.kind == "missing_license_text"); let pass = counts.wrong_license == 0 && counts.missing_header == 0 && counts.uncovered == 0 && counts.unreadable == 0 - && counts.conflicts == 0; + && counts.conflicts == 0 + && !missing_text; let change_by_path: std::collections::HashMap<&std::path::Path, &FileChange> = changes.iter().map(|c| (c.path.as_path(), c)).collect(); diff --git a/src/reuse/inventory.rs b/src/reuse/inventory.rs index 9c69854..298b032 100644 --- a/src/reuse/inventory.rs +++ b/src/reuse/inventory.rs @@ -1,7 +1,7 @@ //! License-text inventory and offline materialization into `LICENSES/` (FR-014, FR-017). use std::collections::BTreeSet; -use std::path::Path; +use std::path::{Path, PathBuf}; use crate::spdx; @@ -42,25 +42,49 @@ impl LicenseTextInventory { } } -/// Identifiers whose text files exist under `LICENSES/`. +/// Identifiers whose text files exist under `LICENSES/`. REUSE recognizes the license +/// text with a `.txt` or `.md` suffix or no suffix at all, so all three spellings map to +/// the same identifier (matching `reuse`'s own discovery — FR-014). fn present_texts(root: &Path) -> BTreeSet { let mut present = BTreeSet::new(); let dir = root.join("LICENSES"); if let Ok(entries) = std::fs::read_dir(&dir) { for e in entries.flatten() { - let path = e.path(); - if path.extension().map(|x| x == "txt").unwrap_or(false) - && let Some(stem) = path.file_stem().and_then(|s| s.to_str()) + if !e.file_type().map(|t| t.is_file()).unwrap_or(false) { + continue; + } + if let Some(name) = e.path().file_name().and_then(|s| s.to_str()) + && let Some(id) = license_id_from_filename(name) { - present.insert(stem.to_string()); + present.insert(id); } } } present } -/// Materialize referenced-but-missing texts into `LICENSES/` from the offline bundle; -/// scaffold `LicenseRef-*` placeholders (FR-017). Returns ids written and ids still missing. +/// Map a `LICENSES/` filename to its SPDX identifier: strip a trailing `.txt`/`.md` +/// (case-insensitive). Any other filename *is* the id — an extension-less `LicenseRef-Acme-1.0` +/// must not have its `.0` treated as an extension, so we never split on the last dot. +fn license_id_from_filename(name: &str) -> Option { + if name.is_empty() { + return None; + } + let lower = name.to_ascii_lowercase(); + for ext in [".txt", ".md"] { + if lower.ends_with(ext) { + return Some(name[..name.len() - ext.len()].to_string()); + } + } + Some(name.to_string()) +} + +/// Materialize referenced-but-missing texts into `LICENSES/` from the offline bundle. +/// Returns ids written and ids still missing (FR-017). +/// +/// **Never scaffolds a placeholder.** A stub file would satisfy REUSE's text-existence +/// check while leaving the repo non-compliant, so a missing text is surfaced as +/// `still_missing` for the caller to fetch (opt-in) or error on — never papered over. pub fn materialize( root: &Path, referenced: &BTreeSet, @@ -78,18 +102,8 @@ pub fn materialize( } std::fs::create_dir_all(&dir)?; for id in &inv.missing { - let dest = dir.join(format!("{id}.txt")); if let Some(text) = spdx::bundled_text(id) { - std::fs::write(&dest, text)?; - written.push(id.clone()); - } else if spdx::is_license_ref(id) { - // Scaffold a placeholder for the maintainer to fill. - let placeholder = format!( - "{id}\n\nTODO: provide the full text of the custom license `{id}`.\n\ - This placeholder satisfies REUSE's text-existence check but is flagged by\n\ - `licet lint` until filled.\n" - ); - std::fs::write(&dest, placeholder)?; + std::fs::write(dir.join(format!("{id}.txt")), text)?; written.push(id.clone()); } else { still_missing.push(id.clone()); @@ -107,6 +121,63 @@ pub struct MaterializeResult { pub still_missing: Vec, } +/// Direct SPDX raw-text URL for a standard (non-`LicenseRef`) license id. +pub fn spdx_text_url(id: &str) -> String { + format!( + "https://raw.githubusercontent.com/spdx/license-list-data/refs/heads/main/text/{id}.txt" + ) +} + +/// Actionable guidance for a missing license text — never mentions an unavailable network +/// flag. For a `LicenseRef-*` we can only name the path to create; for a standard SPDX id we +/// link the exact upstream text to drop into `LICENSES/`. +pub fn missing_text_guidance(id: &str) -> String { + if spdx::is_license_ref(id) { + format!("`{id}` is missing — add its full text at LICENSES/{id}.txt") + } else { + format!( + "`{id}` is missing — download {url} and save it to LICENSES/{id}.txt", + url = spdx_text_url(id) + ) + } +} + +/// Fetch a standard SPDX license text via the system `curl` into `LICENSES/.txt`. +/// +/// Opt-in only: licet ships nothing that can reach the network (the offline-guard forbids +/// any network crate in the dependency tree). This shells out to a `curl` binary the user +/// already has, only when they have explicitly permitted it. Errors — writing nothing — for +/// `LicenseRef-*`, when `curl` is absent, or on any non-success/empty response. Returns the +/// written path on success. +pub fn fetch_via_curl(root: &Path, id: &str) -> Result { + if spdx::is_license_ref(id) { + return Err(format!("{id} is a custom LicenseRef and cannot be fetched")); + } + let dir = root.join("LICENSES"); + std::fs::create_dir_all(&dir).map_err(|e| e.to_string())?; + let dest = dir.join(format!("{id}.txt")); + let url = spdx_text_url(id); + let status = std::process::Command::new("curl") + .arg("-fsSL") + .arg(&url) + .arg("-o") + .arg(&dest) + .status() + .map_err(|e| format!("could not run curl: {e}"))?; + if !status.success() { + let _ = std::fs::remove_file(&dest); + return Err(format!("curl failed for {url} ({status})")); + } + // Guard against an empty body (e.g. a 404 page suppressed by `-f`) passing as success. + match std::fs::metadata(&dest) { + Ok(m) if m.len() > 0 => Ok(dest), + _ => { + let _ = std::fs::remove_file(&dest); + Err(format!("curl produced no text for {id}")) + } + } +} + #[cfg(test)] mod tests { use super::*; @@ -123,15 +194,50 @@ mod tests { } #[test] - fn scaffolds_license_ref_placeholder() { + fn license_ref_is_reported_missing_never_scaffolded() { let dir = tempdir().unwrap(); let mut refs = BTreeSet::new(); refs.insert("LicenseRef-Marque-1.0".to_string()); let res = materialize(dir.path(), &refs).unwrap(); - assert_eq!(res.written.len(), 1); - let text = - std::fs::read_to_string(dir.path().join("LICENSES/LicenseRef-Marque-1.0.txt")).unwrap(); - assert!(text.contains("TODO")); + // No placeholder is written; the id is surfaced for the caller to act on. + assert!(res.written.is_empty()); + assert_eq!(res.still_missing, vec!["LicenseRef-Marque-1.0".to_string()]); + assert!( + !dir.path() + .join("LICENSES/LicenseRef-Marque-1.0.txt") + .exists() + ); + } + + #[test] + fn present_texts_recognizes_md_and_extensionless() { + let dir = tempdir().unwrap(); + let licenses = dir.path().join("LICENSES"); + std::fs::create_dir_all(&licenses).unwrap(); + std::fs::write(licenses.join("MIT.md"), "x").unwrap(); + std::fs::write(licenses.join("Apache-2.0"), "x").unwrap(); + std::fs::write(licenses.join("LicenseRef-Acme-1.0"), "x").unwrap(); + let present = present_texts(dir.path()); + assert!(present.contains("MIT"), "{present:?}"); + assert!(present.contains("Apache-2.0"), "{present:?}"); + // An extension-less LicenseRef keeps its trailing version segment intact. + assert!(present.contains("LicenseRef-Acme-1.0"), "{present:?}"); + } + + #[test] + fn missing_guidance_links_spdx_text_and_names_license_ref_path() { + let std = missing_text_guidance("MIT"); + assert!( + std.contains("license-list-data") && std.contains("MIT.txt"), + "{std}" + ); + assert!(!std.contains("--allow"), "no network-flag hint: {std}"); + let lref = missing_text_guidance("LicenseRef-Acme"); + assert!(lref.contains("LICENSES/LicenseRef-Acme.txt"), "{lref}"); + assert!( + !lref.contains("http"), + "LicenseRef has no upstream URL: {lref}" + ); } #[test] diff --git a/tests/determinism.rs b/tests/determinism.rs index 2c6e932..f10c401 100644 --- a/tests/determinism.rs +++ b/tests/determinism.rs @@ -2,9 +2,11 @@ //! //! 1. Identical inputs → byte-identical JSON report (classification, ordering, exit code). //! 2. File ordering is a stable lexicographic sort. -//! 3. The binary makes no network calls; `--allow-network` is advisory only. (The absence -//! of any network-capable crate in the dependency tree is the structural guarantee — -//! asserted in CI by `cargo tree`; here we confirm the offline paths behave identically.) +//! 3. The binary makes no network calls by default. The absence of any network-capable +//! crate in the dependency tree is the structural guarantee (asserted in CI by the +//! offline-guard / `cargo tree`); here we confirm the default `lint` path is offline and +//! deterministic. Network access exists only as an explicit opt-in (`--allow-curl`, which +//! shells out to the user's own `curl`) and is exercised in the add-license suite. // REUSE-IgnoreStart — SPDX tags below are test fixtures, not this file's licensing. mod common; @@ -68,29 +70,28 @@ fn file_ordering_is_lexicographically_sorted() { } #[test] -fn allow_network_flag_does_not_change_offline_behavior() { - // A repo whose declared license is a non-bundled SPDX id: with or without - // --allow-network, `lint` runs offline and produces the same posture/exit code. +fn lint_is_offline_and_deterministic() { + // `lint` is a read-only checker: it never reaches the network and produces a + // byte-identical posture across runs for identical inputs. let f = Fixture::new(); f.config("[default]\nlicense=\"MIT\"\n") .write("a.rs", "// SPDX-License-Identifier: MIT\nfn a(){}\n") .commit("init"); - let offline = f - .licet() - .args(["lint", "--format", "json"]) - .output() - .unwrap(); - let allowed = f - .licet() - .args(["lint", "--allow-network", "--format", "json"]) - .output() - .unwrap(); - assert_eq!(offline.status.code(), allowed.status.code()); + let run = || { + let out = f + .licet() + .args(["lint", "--format", "json"]) + .output() + .unwrap(); + (out.status.code(), String::from_utf8(out.stdout).unwrap()) + }; + let (code1, json1) = run(); + let (code2, json2) = run(); + assert_eq!(code1, code2, "lint exit code must be stable"); assert_eq!( - String::from_utf8(offline.stdout).unwrap(), - String::from_utf8(allowed.stdout).unwrap(), - "JSON lint posture must be identical regardless of --allow-network (no fetch occurs)" + json1, json2, + "lint posture must be byte-identical across runs" ); } // REUSE-IgnoreEnd diff --git a/tests/us3_comment_style.rs b/tests/us3_comment_style.rs index da2ff64..754cd9d 100644 --- a/tests/us3_comment_style.rs +++ b/tests/us3_comment_style.rs @@ -12,6 +12,12 @@ fn pkl_gets_c_style_header_and_round_trips() { "[default]\nlicense=\"LicenseRef-MarqueLicense-1.0\"\n\ [[comment_style]]\next=\"pkl\"\nstyle=\"c\"\n", ) + // The custom LicenseRef text must exist under LICENSES/ for the repo to be compliant + // (licet no longer scaffolds a placeholder). + .write( + "LICENSES/LicenseRef-MarqueLicense-1.0.txt", + "Marque License 1.0\n\nAll rights reserved.\n", + ) .write("hk.pkl", "amends \"...\"\n") .commit("init"); diff --git a/tests/us5_add_license.rs b/tests/us5_add_license.rs index 2737cb6..a44abcd 100644 --- a/tests/us5_add_license.rs +++ b/tests/us5_add_license.rs @@ -74,7 +74,7 @@ fn unknown_id_unavailable_offline_exits_violations() { } #[test] -fn license_ref_is_scaffolded_as_placeholder() { +fn license_ref_is_never_scaffolded_and_errors_with_path_guidance() { let f = Fixture::new(); f.write("a.rs", "fn a(){}\n").commit("init"); let out = f @@ -82,9 +82,18 @@ fn license_ref_is_scaffolded_as_placeholder() { .args(["add", "LicenseRef-Acme-1.0"]) .output() .unwrap(); - assert_eq!(out.status.code(), Some(0)); - let text = f.read("LICENSES/LicenseRef-Acme-1.0.txt"); - assert!(text.contains("TODO"), "placeholder scaffold: {text}"); + // A custom LicenseRef has no text to materialize: it must NOT be stubbed (a placeholder + // would falsely satisfy REUSE), and must fail with guidance naming the path to create. + assert_eq!(out.status.code(), Some(1)); + assert!( + !f.path().join("LICENSES/LicenseRef-Acme-1.0.txt").exists(), + "no placeholder file should be written" + ); + let stdout = String::from_utf8_lossy(&out.stdout); + assert!( + stdout.contains("LICENSES/LicenseRef-Acme-1.0.txt"), + "names the path to create: {stdout}" + ); } #[test] @@ -135,6 +144,54 @@ fn writes_only_under_licenses_and_does_not_require_clean_tree() { assert!(f.path().join("LICENSES/MIT.txt").exists()); } +#[test] +fn compound_expression_materializes_each_constituent_separately() { + // A detected `MIT OR Apache-2.0` header must split into two texts, never a single + // `LICENSES/MIT OR Apache-2.0.txt` file. + let f = Fixture::new(); + f.config("[default]\nlicense=\"MIT OR Apache-2.0\"\n") + .write( + "a.rs", + "// SPDX-License-Identifier: MIT OR Apache-2.0\nfn a(){}\n", + ) + .commit("init"); + let out = f.licet().args(["add", "--all"]).output().unwrap(); + assert_eq!( + out.status.code(), + Some(0), + "{}", + String::from_utf8_lossy(&out.stdout) + ); + assert!(f.path().join("LICENSES/MIT.txt").exists(), "MIT split out"); + assert!( + f.path().join("LICENSES/Apache-2.0.txt").exists(), + "Apache-2.0 split out" + ); + assert!( + !f.path().join("LICENSES/MIT OR Apache-2.0.txt").exists(), + "must not write the whole expression as one filename" + ); +} + +#[test] +fn existing_md_license_text_is_recognized_not_re_materialized() { + // REUSE accepts `LICENSES/.md`; licet must see it as present and not report missing. + let f = Fixture::new(); + f.config("[default]\nlicense=\"MIT\"\n") + .write( + "LICENSES/MIT.md", + "MIT License\n\nPermission is hereby granted...\n", + ) + .write("a.rs", "// SPDX-License-Identifier: MIT\nfn a(){}\n") + .commit("init"); + let out = f.licet().arg("lint").output().unwrap(); + let stdout = String::from_utf8_lossy(&out.stdout); + assert!( + !stdout.contains("missing license texts"), + "MIT.md should count as present: {stdout}" + ); +} + #[test] fn json_output_is_well_formed() { let f = Fixture::new();