urlstechie / urlchecker-python

:snake: :link: Python module and client for checking URLs
https://urlchecker-python.readthedocs.io
MIT License
20 stars 12 forks source link

add precommit hook #55

Closed aerickson closed 3 years ago

aerickson commented 3 years ago

Fixes https://github.com/urlstechie/urlchecker-python/issues/54.

Issues:

Areas for improvement:

test .pre-commit-config.yaml:

repos:
-   repo: https://github.com/aerickson/urlchecker-python
    rev: 046de9cd19134f1648d1904297d4d6514f0e730c
    hooks:
    - id: urlchecker

once landed and 0.0.17 has been tagged, the following will work:

repos:
-   repo: https://github.com/urlstechie/urlchecker-python
    rev: 0.0.17
    hooks:
    - id: urlchecker

example run:

➜  test_repo git:(main) ✗  pre-commit run -a
urlchecker...............................................................Failed
- hook id: urlchecker
- exit code: 1

original path: .
              final path: /Users/aerickson/git/test_repo
               subfolder: None
                  branch: master
                 cleanup: False
              file types: ['*']
                   files: ['repositories.json']
               print all: True
           urls excluded: []
   url patterns excluded: []
  file patterns excluded: []
              force pass: False
             retry count: 2
                    save: None
                 timeout: 5

 /Users/aerickson/git/test_repo/repositories.json 
 ------------------------------------------------
REDACTED

Done. All URLS passed.
           original path: .
              final path: /Users/aerickson/git/test_repo
               subfolder: None
                  branch: master
                 cleanup: False
              file types: ['*']
                   files: ['test2/blah.txt']
               print all: True
           urls excluded: []
   url patterns excluded: []
  file patterns excluded: []
              force pass: False
             retry count: 2
                    save: None
                 timeout: 5

 /Users/aerickson/git/test_repo/test2/blah.txt 
 ---------------------------------------------
HTTPConnectionPool(host='a.bad.', port=80): Max retries exceeded with url: /link (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10e7a22e0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))
http://a.bad./link
HTTPConnectionPool(host='a.bad.', port=80): Max retries exceeded with url: /link (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10e7a2370>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))
http://a.bad./link

Done. The following urls did not pass:
http://a.bad./link

➜  test_repo git:(main) ✗  
codecov[bot] commented 3 years ago

Codecov Report

Merging #55 (046de9c) into master (08fc1bb) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #55   +/-   ##
=======================================
  Coverage   76.76%   76.76%           
=======================================
  Files          12       12           
  Lines         383      383           
=======================================
  Hits          294      294           
  Misses         89       89           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 08fc1bb...046de9c. Read the comment docs.

aerickson commented 3 years ago

Works for me.

Ideally we'd add an option that summarizes the bad files and URLS so output is easier to parse (the strange way I'm driving urlchecker doesn't help this).