Git – Automatically update copyright date range from git

copyrightgit

As I write, we're 10 days into 2012. I bet many programmers are editing the copyright string at the top of their source files to something like:

// Copyright 2008, 2010-2012 Some Company Unlimited

Your version control system knows when files were modified so surely it can help write or rewrite these strings. So my question: is there a script that can examine git logs for each file and output (or better insert) a string like that about?

I'm using git so that's of primary interest but do let me know if such scripts exist for other systems.

Update:

We need a script that does this:

  • Walks all source files in our working copy
  • Locates existing copyright string and identifies years e.g. 2007,2009-2011 would be {2007, 2009, 2010, 2011}
  • For each year that is not mentioned, diff between 1 Jan and 31 Dec (or today if current year). Examine diff and decide if it's worthy of a mention in the copyright string
  • Insert new copyright string.

Best Answer

TL;DR

Don't worry! Your copyright over the project won't expire if you didn't update the year in time! You are safe - it doesn't work that way.

Long version:

I'm pretty sure that all year numbers in the copyright notice indicate the start of copyright not the range. If you add a year it means the continuation of the start, not end. You use it if you add new content (like new modules) to indicate the starting year for that new content only. It is optional but should be used for large changes, like whole new modules or a complete design makeover.

The copyright should expire after fixed number years (which depends on the laws in your country) after the last year in your notice.

So, I don't see a reason to busily update source headers at all.

EDIT:

The thing is that usually changes which are substantial enough involve completely new source files or a re-implementation of old ones. So, as long as you always use the current year in the headers of new source files you're fine. There is no need whatsoever to pass through every single file to make the update. Actually, the only thing that requires a manual change is if you have date range in the licence text itself or in readme file.

Disclaimer: I am a programmer, not a lawyer.

Related Topic