Coder Social home page Coder Social logo

mte90 / gh-license Goto Github PK

View Code? Open in Web Editor NEW
44.0 4.0 23.0 125 KB

Scan your online repo, check if it is missing the license (or install the Git Hooks in your machine)

License: GNU General Public License v3.0

Python 99.30% Shell 0.70%
license github hacktoberfest legal

gh-license's Introduction

GitHosting License

License

This script scans every repo of a user (on GitHub/Bitbucket/GitLab or other providers available) for:

  • Check if include a license file
  • Download a license to the project folder (automatically execute a git commit)
  • Adds a license badge in the readme (automatically execute a git commit)
  • Include git hooks to check if your project has one.

Remember, without a license file your project is proprietary even if it is online!

Install

pip3 install gh-license

In case of a git clone:

pip3 install -e ./folder-of-the-repo

Info: This overwrites the init.templatedir global git config after creating a backup of the current value in ~/.gh-license/config.ini with the key templatedir in section main.
The installed git template contains a hook that will be installed every time you run git init. The hook reminds you to install a license if you ever forget, and disables itself after adding one.

Example

gh-license --scan Mte90

With this command you will get a report in a file called Mte90-github-license-report

gh-license --scan Mte90 --provider bitbucket

With this command you will get a report in a file called Mte90-bitbucket-license-report

gh-license --scan Mte90 --report my-report

With this command you will get a report in a file called my-report

gh-license --license-list

With this command will be showed the licenses avalaible

gh-license --license GPLv3

With this command, a GPLv3 license will be downloaded, a shields will be added in the readme and if Git is available a commit will be added and the changes will be pushed to the repo.

gh-license --license GPLv3 -- origin upstream

With this command the commit will be pushed on the upstream origin

Example of output

gh-license's People

Contributors

3onyc avatar aklife97 avatar alberthdev avatar dynnammo avatar fabianaboldrin avatar fatualux avatar fossabot avatar gioditalia avatar jayvdb avatar marcovolpato00 avatar mte90 avatar mubaris avatar rajibmitra avatar revolter avatar rivergillis avatar thecodeartist avatar tkindy avatar yurimalheiros avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gh-license's Issues

Remember the last used license

Actually when you use the tool you have to remember the last license or what you use mostly with the codename used in the package.
It will be cool to remind what are the most used on creating when the license is not specified with a prompt to ask to the user what of the license most used want to use.

Revamp the report file

[Very shiny feature, not urgent at all, but may be useful someway]

Currently, the report file is "only" a text file listing all repos with their licensing characteristics.

What could be great is to generate a visual file, HTML or Markdown (to be discussed) with minimal formating that would give a shinier view of what's going on in your organization/user account. This option could be available by giving a --visual-report option with html|markdown flag

Undetected license file for unusual repos

Some repos have license files named somewhat strangely : License-Agplv3.txt, etc. (cf. github.com/decidim/decidim as instance).

It would be great, instead of covering this by having a license_files list, to work followingly :

  1. For GH, using the API, which itself relies on Licensee, a ruby gem that do the job pretty well : https://docs.github.com/en/rest/licenses#get-the-license-for-a-repository
  2. For Bitbucket, same API endpoint does exist : https://developer.atlassian.com/server/bitbucket/rest/v804/api-group-project/#api-api-latest-projects-projectkey-repos-repositoryslug-license-get

Scan export as file

Will be useful to have the scan report as file with all the links of the repos.

Installation error?

OS: Manjaro

Collecting gh-license
  Downloading gh-license-0.2.4.tar.gz
Collecting pygithub>=1.5.0 (from gh-license)
  Downloading PyGithub-1.35.tar.gz (2.6MB)
    100% |████████████████████████████████| 2.6MB 387kB/s 
Collecting bitbucket-api>=0.5.0 (from gh-license)
  Downloading bitbucket-api-0.5.0.tar.gz
Collecting pyjwt (from pygithub>=1.5.0->gh-license)
  Downloading PyJWT-1.5.3-py2.py3-none-any.whl
Requirement already satisfied: requests in /usr/lib/python3.6/site-packages (from bitbucket-api>=0.5.0->gh-license)
Collecting sh (from bitbucket-api>=0.5.0->gh-license)
  Downloading sh-1.12.14-py2.py3-none-any.whl
Collecting requests-oauthlib (from bitbucket-api>=0.5.0->gh-license)
  Downloading requests_oauthlib-0.8.0-py2.py3-none-any.whl
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/lib/python3.6/site-packages (from requests->bitbucket-api>=0.5.0->gh-license)
Requirement already satisfied: idna<2.7,>=2.5 in /usr/lib/python3.6/site-packages (from requests->bitbucket-api>=0.5.0->gh-license)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/lib/python3.6/site-packages (from requests->bitbucket-api>=0.5.0->gh-license)
Collecting oauthlib>=0.6.2 (from requests-oauthlib->bitbucket-api>=0.5.0->gh-license)
  Downloading oauthlib-2.0.6.tar.gz (127kB)
    100% |████████████████████████████████| 133kB 721kB/s 
Installing collected packages: pyjwt, pygithub, sh, oauthlib, requests-oauthlib, bitbucket-api, gh-license
  Running setup.py install for pygithub ... done
  Running setup.py install for oauthlib ... done
  Running setup.py install for bitbucket-api ... done
  Running setup.py install for gh-license ... done
Successfully installed bitbucket-api-0.5.0 gh-license-0.2.4 oauthlib-2.0.6 pygithub-1.35 pyjwt-1.5.3 requests-oauthlib-0.8.0 sh-1.12.14

$ gh-license --scan italia
ERROR: Provider 'github' does not exist!

Add GitLab provider

In requirements.txt there are traces of a tentative to implement that support but is missing.

Force a commit after the license download

As you can see in the readme I suggest to do a commit but will be useful a check if the folder have github and done automatically with a parameter for the command itself.

Git hooks

It will be helpful to have a git hooks installed globally when is executed git init to remember to download a license.

Add URL link for unlicensed repositories in analysis phase

As a developer, it would be awesome to have a https link to the repository in which there is no license.

Currently, link is here for already licensed projects and in the output file, but I think it could be helpful to ease the process of License adding if you provide a link also for unlicensed repos, since in few clicks I can solve this afterward.

Fix broken character

This line:

print(' ☐ Is a fork, check the original or create a PR!')

has a character which can't be displayed for me on macOS High Sierra, neither in terminal, nor the browser:

screen shot 2017-10-07 at 00 36 17

Is this happening only for me? What character should it be?

--scan should default to Sources

Currently --scan processes forks, mirrors, etc. While that is useful, it is usually not what users would expect as the default.

Add stats in the report file

Will be useful get in the end of the report the stats about the repo with license and without and how many of them are fork with the same problem.

Add unit tests

The package is working but unit tests can transform the tool in a swiss knife for every developer if we have unit tests.

Improve License suggestion help

Actually this is the output:
First parameter is missing: The license: GPLv2, GPLv3, LGPLv3, AGPLv3, FDLv1.3, Apachev2, CC-BY

Add a list with all the licenses with an explanation will be useful to choice.

Support for GitLab, BitBucket

The script born for GitHub but support other services is important.
The script check a profile for all the repos and search in all of them for a license file.
Is hardcoded the support for GitHub but probably with only a switch of the domain works also with other services.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.