I have previously written a lot of code that is hosted on a public repo on GitHub, but it never had a license. It was written as part of my work while working for a non-commercial academic entity, and I would like to add a license before the link to the repo will be included in something that will be made public, potentially attracting one or two visitors.

This leaves me with a couple of questions:

  1. Can I just add a license after the fact and it will be valid for all prior work?
  2. Do I have to make sure the license is included in all branches of the repo, or does this not matter? There are for instance a couple of branches that are used to freeze the state of code at a certain time for reproducibility’s sake (I know this could be solved in a better way, but that’s how it is).
  3. I have myself reused some of the code in my current work for a commercial entity (internal analysis work, only distributed within the organization). Should this influence the type of license I choose? I am considering a GPL-license, but should I go with (what I believe to be) a more permissive license like MIT because of this?
  • Daniel Quinn@lemmy.ca
    link
    fedilink
    English
    arrow-up
    32
    ·
    9 months ago

    These are fun questions! There’s a few other things you have to consider though before you can have some answers.

    If the work was done for your employer (non-commercial, academic, or otherwise) you should be sure that your work for that organisation did not include the transfer of ownership of the work you create to said organisation. Most organisations that employ people to write software usually include a stipulation in your contract that anything you create “in the course of your employment” (this is a legal term meaning work you do for your job as well as work you might do related to you job as inspiration/necessity for your job etc) is owned by the employer. If that’s the case for you, you can’t simply re-license the software, even if it’s already publicly viewable. You need to seek the consent of the copyright owner to either (a) transfer the ownership to you, or (b) agree to a new license.

    Which brings me to the first thing people tend to forget about copyright: unless otherwise stipulated (like through the inclusion of a LICENSE file) all creative works are copyrighted and cannot be copied, imported, modified, distributed, etc. without the express consent of the copyright holder (usually through a licensing agreement).

    So with that in mind, and assuming that you already have the copyright to this code, I’ll answer your three questions:

    1. Can I just add a license after the fact and it will be valid for all prior work?

    This is fun question because it hinges on a silly technicality of software development. If you add a license to your repo today, the license applies to the code as of that point in the commit history. There’s no official way to say (through the standard of including a file in the repo) that this license applies retroactively, but if you’re the sole copyright holder (see notes on this below) of the work in its current state as well as everything that came before (ie. you didn’t get PRs from other people thinking they were committing to a project under a proprietary license) then practically speaking, you can apply a Free license to all the old versions because you’re the copyright holder – you can do whatever you want. The problem is a practical one: without a LICENSE file, it’s not clear that this software is Free.

    Unless you’ve got a bunch of other people/teams/organisations working off of forks of your current codebase though, it’s really just a thought experiment: no one will care because the latest version is Freely licensed. Someone could conceivably fork your repo from an earlier point in history, but without a LICENSE file in that fork, legally speaking that code is solely your property, so copying it would be illegal unless you made a copy for them with a LICENSE file included.

    2. Do I have to make sure the license is included in all branches of the repo, or does this not matter? There are for instance a couple of branches that are used to freeze the state of code at a certain time for reproducibility’s sake (I know this could be solved in a better way, but that’s how it is).

    There’s a lot of overlap here with #1. Basically your old release branches will be copyrighted by you and not licensed Freely. If it’s important to you that these releases also be under your new Free license, then yeah, you’re going to have to include a new commit on each release branch with your LICENSE file. Personally though, I wouldn’t bother. If anyone is using an old release, they’ll get the Free version once they upgrade and that’s usually good enough for most people.

    3. I have myself reused some of the code in my current work for a commercial entity (internal analysis work, only distributed within the organization). Should this influence the type of license I choose? I am considering a GPL-license, but should I go with (what I believe to be) a more permissive license like MIT because of this?

    So much of this centres around the current ownership of all code in the repo. If this were a personal project into which no one but you has ever committed any code and for which there’s no existing contract stating that your-employer-not-you owns the code, then the answer is really simple: it’s your work, you can do whatever you like.

    For example, you can write a program, license it under the AGPL3, and post it on GitLab for all the world to see. Strangers from the other side of the planet can download it, modify it, and run it in their own projects so long as they adhere to the AGPL3 license. So long as you don’t accept any merge requests from anyone else, you can also re-license the code (or a portion thereof) to a private company (your employer, a contract gig, whatever). Remember, it’s your code, you can do with it as you like, so if you choose to give it to a company to build into their proprietary project, there’s no problem.

    The problem comes once you accept code from someone else. If I submit a merge request to your project that fixes a bug, I do so under the terms of that project’s license. My code is AGPL3 because the project’s license is AGPL3. You can’t now take my bugfix and copy that into a private project because I didn’t grant you that right. This is why re-licensing a Free software project, even from GPL-2 to GPL-3 can be really painful: you have to contact each contributor and acquire the right to change the license.

    So, TL;DR: if it’s 100% your code, you can make 10 copies, all under different licenses. Do whatever you want. If it’s 99% your code, you’re bound by the license in affect at the time those other contributions were made.

    [Source: I’m a Free software nerd with a penchant for copyright, so much so that I married a copyright lawyer so we talk about this stuff a lot.]

    • cyberwolfieOP
      link
      fedilink
      arrow-up
      7
      ·
      9 months ago

      Wow, thanks a lot for this thorough answer. I see I need to dust off the old employment contract and see what it says - I’ve had an assumption that any ownership my previous employer has pertains only to any discovery that could be commercialized through patents and spin-offs - this is not that. This work is academic research, and I was required to make any publication openly accessible (with CC-licenses) due to how the work was funded, and this code base contains all the analysis tools that underpin these publications.

      • Daniel Quinn@lemmy.ca
        link
        fedilink
        English
        arrow-up
        2
        ·
        9 months ago

        Interesting. I wonder if this code would fall under the license of the publication then? The blurry line between documentation licenses and software licenses is usually when I stop and go ask my wife :-)

      • kevincoxM
        link
        fedilink
        arrow-up
        1
        ·
        9 months ago

        In general, If you did work for your employer they own the code. You may wish to just ask them, maybe they are fine with adding a license.

        If you didn’t write it for them, during “work hours” or using their resources then you may own the code. Some employment contracts will claim that they own everything you wrote while employed for them but that may not be legal in some jurisdictions.

    • ResoluteCatnap
      link
      fedilink
      English
      arrow-up
      2
      ·
      9 months ago

      This is why re-licensing a Free software project, even from GPL-2 to GPL-3 can be really painful: you have to contact each contributor and acquire the right to change the license.

      Is that true if you leave in the license the “or (at your option) any later version” text regarding what version youre using? I understood that to mean that even if i accept contributions then my licensing clearly defines it as GPL-3 or later version so I’m able to relicense to a future GPL-4 if i wanted. Or would i still need to get any contributors agreement to relicense?

      • Daniel Quinn@lemmy.ca
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        9 months ago

        That’s a good question. I believe there is official text for “GPL-3 or later” that you can use, which should (I just asked the wife to be sure) then let you re-license the project to GPL-4 later. This is probably possible because the “or later” portion of the license text includes consent by contributors for the future change.

    • kevincoxM
      link
      fedilink
      arrow-up
      1
      ·
      9 months ago
      1. Can I just add a license after the fact and it will be valid for all prior work?

      This is fun question because it hinges on a silly technicality of software development. If you add a license to your repo today, the license applies to the code as of that point in the commit history.

      I think you are getting a bit too caught up at the process of adding a LICENCE file to a repo. This is just one way to licence some work. You can just say “I as the copyright owner of this work licence it, including all previous revisions under licence X”. That is also licensing the code and doesn’t matter if the LICENCE file exists at any particular commit.

      But yes, I would say that by default adding a LICENCE file would be interpreted just as releasing that version of the code under the particular licence.

      • Daniel Quinn@lemmy.ca
        link
        fedilink
        English
        arrow-up
        2
        ·
        9 months ago

        That’s fair, though if you’re looking for something more legally ironclad, I’m not sure I would want to depend on a declaration like that. But you’re right, as the sole copyright holder, you can choose to apply your licence any way you like, so long as it’s clear (for some value of clear) to the recipient that the software, what the license is.