jmonkeyengine icon indicating copy to clipboard operation
jmonkeyengine copied to clipboard

Github License detection fails

Open MeFisto94 opened this issue 4 years ago • 23 comments

A very minor issue, but when accessing https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/LICENSE, github does not recognize the license type automatically.

If someone is bored to debug that, potentially we may need to change the wording by a small bit to make it fit the official regex. A quick search made me wonder if BSD-3 is even detected by github at all, but to show what I mean, have a look at this, being licensed under MIT: https://github.com/mit-license/mit-license.github.io/blob/master/LICENSE

https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/licensing-a-repository#detecting-a-license on the other hand claims that BSD3 is supported. Maybe someone can experiment with the ruby gem

MeFisto94 avatar Jun 02 '21 14:06 MeFisto94

Github can recognize BSD3 licenses. For instance, see

  • https://github.com/stephengold/asm
  • https://github.com/stephengold/Banana
  • https://github.com/stephengold/BasicGame-on-Gradle
  • https://github.com/stephengold/Garrett
  • https://github.com/stephengold/jme-vehicles

Editing the LICENSE file now might not help. I suspect that license recognition occurs when a repo is created. As evidence of this, note that my fork of JMonkeyEngine has a recognized license:

  • https://github.com/stephengold/jmonkeyengine

stephengold avatar Jun 02 '21 17:06 stephengold

I think it just needs the: BSD 3-Clause License ...line at the top.

I tried that in one of my projects and it worked.

pspeed42 avatar Jun 02 '21 17:06 pspeed42

I think GitHub supports detection of SPDX License Identifiers: https://spdx.org/licenses/

NetzwergX avatar Jun 02 '21 22:06 NetzwergX

Apparently I can confirm what paul said, the licenses that my projects have, that have been automatically inited by Github contain BSD 3-Clause License, one blank line and then start with the Copyright.

Currently the license is detected as "other"

MeFisto94 avatar Jun 13 '21 21:06 MeFisto94

I edited the LICENSE file at 8017f3bc but so far I haven't seen evidence that Github recognizes the license.

stephengold avatar Jul 11 '21 07:07 stephengold

Maybe the .md extension should be added to the LICENSE file for Github to recognize it. "LICENSE.md" or "license.md"

Ali-RS avatar Jul 11 '21 08:07 Ali-RS

Renaming didn't seem to help. Now it's also in a weird state where I've edited the bullets to be 1., 2., etc. but if you view the raw file it still shows *. Maybe something is cached now.

Edit: if anyone wants to compare, this is my own file that I changed some time back and it worked: https://github.com/Simsilica/SimMath/blob/master/license.md ...you can see the edit in the commits.

pspeed42 avatar Jul 11 '21 09:07 pspeed42

The third bullet in jme's license had been customized compared to the standard bsd3. Also, bullet points do not have justified paragraphs against the bullet.

A correct version of the license is as such:

BSD 3-Clause License

Copyright (c) 2009-2021 jMonkeyEngine
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions 
are met:
 
1. Redistributions of source code must retain the above copyright 
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright 
   notice, this list of conditions and the following disclaimer in 
   the documentation and/or other materials provided with the 
   distribution.

3. Neither the name of the copyright holder nor the names of its 
   contributors may be used to endorse or promote products derived 
   from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
OF THE POSSIBILITY OF SUCH DAMAGE.

tlf30 avatar Jul 11 '21 17:07 tlf30

Renaming might break web links. Also, it was unnecessary. I have several projects where the license file has no extension (or .txt) and those licenses are detected just fine. See the list above.

The .md file extension causes Github to apply "markdown" formatting, which explains why the raw file doesn't match what's displayed.

stephengold avatar Jul 11 '21 19:07 stephengold

Real raw file had 1., 2., 3. The raw file when I viewed it had *'s. Github was messing up somehow.

Versus on my own project where the exact same formatting was sensible.

Easy enough to name it back, I was just trying to see what it would take to match. Once github stopped seeing my updates, I quit.

pspeed42 avatar Jul 12 '21 01:07 pspeed42

It seems like we're all guessing here, and so far none of our guesses has paid off. I'll put the license files back the way they were.

stephengold avatar Jul 12 '21 17:07 stephengold

@stephengold see my comment above. The jme license has custom verbiage in the third bullet that needs to be normalized for the github detection to work.

tlf30 avatar Jul 12 '21 18:07 tlf30

custom verbiage in the third bullet that needs to be normalized for the github detection to work

Do you have access to Github's algorithm, or are you guessing?

Either way, it's not worth altering our license just to get it recognized by Github. As the OP said, it's a very minor issue.

stephengold avatar Jul 12 '21 23:07 stephengold

That is the only difference (other than the copyright name at the top) when performing a diff on a working license file that github detected with the exact same name (when it was names license.txt, it has had several names over the last couple days 😄 )

tlf30 avatar Jul 13 '21 01:07 tlf30

Perhaps Github only performs license detection when a repo is created...

stephengold avatar Jul 13 '21 02:07 stephengold

But earlier in this thread I fixed one of my repositories by simply changing the license. So if it's in the right format then it will find the type. (My own more closely matches the BSD template since it doesn't have the extraneous stuff that JME adds to its license.)

pspeed42 avatar Jul 13 '21 02:07 pspeed42

I fixed one of my repositories by simply changing the license

I didn't realize that.

So suppose we get the LICENSE file just the way Github wants it. Are we also going change the 7,300 copies of that license that are embedded in Java source files?

stephengold avatar Jul 13 '21 03:07 stephengold

Do you have access to Github's algorithm, or are you guessing?

According to https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/licensing-a-repository, GitHub uses https://github.com/licensee/licensee to detect the license.

It only detects the license if the Sørensen–Dice coefficient is greater than 95%.

I just tested it in a fork. If you

  1. Put the text @tlf30 posted into the license.md file and
  2. delete the license.txt or rename it to license-template.txt or something else

then the license is correctly detected.

There is two things throwing GitHub off: the custom verbiage in the 3rd bullet point, and the license.txt file.

This is what my fork shows after the changes:

image

NetzwergX avatar Jul 13 '21 08:07 NetzwergX

Can I take this issue for Hacktoberfest?

b0n541 avatar Sep 27 '22 20:09 b0n541

I don't see why not

tlf30 avatar Sep 27 '22 20:09 tlf30

I fixed the license in my fork of this repository:

https://github.com/b0n541/jmonkeyengine/blob/master/LICENSE.md

Do you want me to also change the license block on top of all of the source files?

b0n541 avatar Oct 01 '22 06:10 b0n541

I also found out that GitHub only seems to re-detect a license if the LICENSE.md file is re-created in a repository and the source file header template file doesn't contain the string "license".

b0n541 avatar Oct 01 '22 07:10 b0n541

Pull request: https://github.com/jMonkeyEngine/jmonkeyengine/pull/1855

b0n541 avatar Oct 03 '22 16:10 b0n541

This issue seems to have been resolved when #1855 was merged. Ping to close?

Sailsman63 avatar Jan 08 '23 04:01 Sailsman63

@Sailsman63 thanks for reminding

Ali-RS avatar Jan 08 '23 04:01 Ali-RS