You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-7Lines changed: 38 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,11 @@
3
3
This repo provides utilities for managing copyright headers and license files
4
4
across many repos at scale.
5
5
6
-
You can use it to add or validate copyright headers on source code files, add a
7
-
LICENSE file to a repo, report on what licenses repos are using, and more.
6
+
Features:
7
+
- Add or validate copyright headers on source code files
8
+
- Add and/or manage LICENSE files with git-aware copyright year detection
9
+
- Report on licenses used across multiple repositories
10
+
- Automate compliance checks in CI/CD pipelines
8
11
9
12
## Getting Started
10
13
@@ -33,7 +36,7 @@ Usage:
33
36
copywrite [command]
34
37
35
38
Common Commands:
36
-
headers Adds missing copyright headers to all source code files
39
+
headers Adds missing copyright headers and updates existing headers' year information.
37
40
init Generates a .copywrite.hcl config for a new project
38
41
license Validates that a LICENSE file is present and remediates any issues if found
39
42
@@ -62,8 +65,18 @@ scan all files in your repo and copyright headers to any that are missing:
62
65
copywrite headers --spdx "MPL-2.0"
63
66
```
64
67
65
-
You may omit the `--spdx` flag if you add a `.copywrite.hcl` config, as outlined
66
-
[here](#config-structure).
68
+
The `copywrite license` command validates and manages LICENSE files with git-aware copyright years:
69
+
70
+
```sh
71
+
copywrite license --spdx "MPL-2.0"
72
+
```
73
+
74
+
**Copyright Year Behavior:**
75
+
-**Start Year**: Auto-detected from config file and if not found defaults to repository's first commit
76
+
-**End Year**: Set to current year when an update is triggered (git history only determines if update is needed)
77
+
-**Update Trigger**: Git detects if source code file was modified since the copyright end year
78
+
79
+
You may omit the `--spdx` flag if you add a `.copywrite.hcl` config, as outlined [here](#config-structure).
67
80
68
81
### `--plan` Flag
69
82
@@ -72,6 +85,24 @@ performs a dry-run and will outline what changes would be made. This flag also
72
85
returns a non-zero exit code if any changes are needed. As such, it can be used
73
86
to validate if a repo is in compliance or not.
74
87
88
+
## Technical Details
89
+
90
+
### Copyright Year Logic
91
+
92
+
**Source File Headers:**
93
+
- End year: Set to current year when file's source code is modified
94
+
- Git history determines if update is needed (compares file's last commit year to copyright end year)
95
+
- When triggered, end year updates to current year
96
+
- Ignores copyright header updates made to a file as it is not source code change.
97
+
98
+
**LICENSE Files:**
99
+
- End year: Set to current year when any project file is modified
100
+
- Git history determines if update is needed (compares repo's last commit year to copyright end year)
101
+
- When triggered, end year updates to current year
102
+
- Preserves historical accuracy for archived projects (no forced updates)
103
+
104
+
**Key Distinction:** Git history is used as a trigger to determine *whether* an update is needed, but the actual end year value is always set to the current year when an update occurs.
105
+
75
106
## Config Structure
76
107
77
108
> :bulb: You can automatically generate a new `.copywrite.hcl` config with the
@@ -99,8 +130,8 @@ project {
99
130
100
131
# (OPTIONAL) Represents the year that the project initially began
101
132
# This is used as the starting year in copyright statements
102
-
# If set and different from current year, headers will show: "copyright_year, current_year"
103
-
# If set and same as current year, headers will show: "current_year"
133
+
# If set and different from current year, headers will show: "copyright_year, year-2"
134
+
# If set and same as year-2, headers will show: "copyright_year"
104
135
# If not set (0), the tool will auto-detect from git history (first commit year)
105
136
# If auto-detection fails, it will fallback to current year only
0 commit comments