Skip to content

Commit c482316

Browse files
authored
Merge pull request #90 from casperdcl/devel
next release v2.0.2
2 parents 687643b + 7e5309e commit c482316

13 files changed

+186
-279
lines changed

.github/workflows/comment-bot.yml

+8-39
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,17 @@
1+
# runs on any comment matching the format `/tag <tagname> <commit>`
12
name: Comment Bot
23
on:
34
issue_comment: {types: [created]}
45
pull_request_review_comment: {types: [created]}
56
jobs:
6-
tag: # /tag <tagname> <commit>
7-
if: startsWith(github.event.comment.body, '/tag ')
7+
tag:
88
runs-on: ubuntu-latest
9+
permissions: {contents: write, pull-requests: write, issues: write}
910
steps:
10-
- uses: actions/checkout@v3
11-
- name: React Seen
12-
uses: actions/github-script@v6
11+
- uses: actions/checkout@v4
1312
with:
14-
script: |
15-
const perm = await github.rest.repos.getCollaboratorPermissionLevel({
16-
owner: context.repo.owner, repo: context.repo.repo,
17-
username: context.payload.comment.user.login})
18-
post = (context.eventName == "issue_comment"
19-
? github.rest.reactions.createForIssueComment
20-
: github.rest.reactions.createForPullRequestReviewComment)
21-
if (!["admin", "write"].includes(perm.data.permission)){
22-
post({
23-
owner: context.repo.owner, repo: context.repo.repo,
24-
comment_id: context.payload.comment.id, content: "laugh"})
25-
throw "Permission denied for user " + context.payload.comment.user.login
26-
}
27-
post({
28-
owner: context.repo.owner, repo: context.repo.repo,
29-
comment_id: context.payload.comment.id, content: "eyes"})
30-
- name: Tag Commit
31-
run: |
32-
git clone https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} repo
33-
git -C repo tag $(echo "$BODY" | awk '{print $2" "$3}')
34-
git -C repo push --tags
35-
rm -rf repo
36-
env:
37-
BODY: ${{ github.event.comment.body }}
38-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
39-
- name: React Success
40-
uses: actions/github-script@v6
13+
fetch-depth: 0
14+
token: ${{ secrets.GH_TOKEN || github.token }}
15+
- uses: casperdcl/comment-bot@v1
4116
with:
42-
script: |
43-
post = (context.eventName == "issue_comment"
44-
? github.rest.reactions.createForIssueComment
45-
: github.rest.reactions.createForPullRequestReviewComment)
46-
post({
47-
owner: context.repo.owner, repo: context.repo.repo,
48-
comment_id: context.payload.comment.id, content: "rocket"})
17+
token: ${{ secrets.GH_TOKEN || github.token }}

.github/workflows/test.yml

+14-52
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,22 @@ on:
44
pull_request:
55
schedule: [{cron: '3 2 1 * *'}] # M H d m w (monthly at 2:03)
66
jobs:
7-
check:
8-
if: github.event_name != 'pull_request' || !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)
9-
name: Check
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: actions/checkout@v3
13-
- uses: actions/setup-python@v4
14-
with:
15-
python-version: '3.x'
16-
- name: Prepare cache
17-
run: echo "PYSHA=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
18-
- uses: actions/cache@v3
19-
with:
20-
path: ~/.cache/pre-commit
21-
key: pre-commit|${{ env.PYSHA }}|${{ hashFiles('.pre-commit-config.yaml') }}
22-
- name: Dependencies
23-
run: pip install -U pre-commit
24-
- uses: reviewdog/action-setup@v1
25-
- if: github.event_name == 'push' || github.event_name == 'pull_request'
26-
name: Comment
27-
run: |
28-
if [[ $EVENT == pull_request ]]; then
29-
REPORTER=github-pr-review
30-
else
31-
REPORTER=github-check
32-
fi
33-
pre-commit run -a todo | reviewdog -efm="%f:%l: %m" -name=TODO -tee -reporter=$REPORTER -filter-mode nofilter
34-
pre-commit run -a flake8 | reviewdog -f=pep8 -name=flake8 -tee -reporter=$REPORTER -filter-mode nofilter
35-
env:
36-
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37-
EVENT: ${{ github.event_name }}
38-
- name: Lint
39-
run: pre-commit run -a --show-diff-on-failure
407
test:
418
if: github.event_name != 'pull_request' || !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)
429
name: py${{ matrix.python }}-${{ matrix.os }}
4310
strategy:
4411
matrix:
4512
os: [ubuntu]
46-
python: [3.7, 3.8, 3.9, '3.10', 3.11]
13+
python: [3.7, 3.8, 3.9, '3.10', 3.11, 3.12]
4714
include:
48-
- os: macos
49-
python: 3.11
50-
- os: windows
51-
python: 3.11
15+
- {os: macos, python: 3.12}
16+
- {os: windows, python: 3.12}
5217
runs-on: ${{ matrix.os }}-latest
53-
defaults:
54-
run:
55-
shell: bash
18+
defaults: {run: {shell: bash}}
5619
steps:
57-
- uses: actions/checkout@v3
58-
with:
59-
fetch-depth: 0
60-
- uses: actions/setup-python@v4
20+
- uses: actions/checkout@v4
21+
with: {fetch-depth: 0}
22+
- uses: actions/setup-python@v5
6123
with:
6224
python-version: ${{ matrix.python }}
6325
- name: Install
@@ -79,7 +41,7 @@ jobs:
7941
needs: test
8042
runs-on: ubuntu-latest
8143
steps:
82-
- uses: actions/setup-python@v4
44+
- uses: actions/setup-python@v5
8345
with:
8446
python-version: '3.x'
8547
- name: Coveralls Finished
@@ -90,13 +52,14 @@ jobs:
9052
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9153
deploy:
9254
name: Deploy
93-
needs: [check, test]
55+
needs: test
9456
runs-on: ubuntu-latest
57+
environment: pypi
58+
permissions: {contents: write, id-token: write, packages: write}
9559
steps:
96-
- uses: actions/checkout@v3
97-
with:
98-
fetch-depth: 0
99-
- uses: actions/setup-python@v4
60+
- uses: actions/checkout@v4
61+
with: {fetch-depth: 0}
62+
- uses: actions/setup-python@v5
10063
with:
10164
python-version: '3.x'
10265
- name: Install
@@ -107,7 +70,6 @@ jobs:
10770
- id: dist
10871
uses: casperdcl/deploy-pypi@v2
10972
with:
110-
password: ${{ secrets.TWINE_PASSWORD }}
11173
gpg_key: ${{ secrets.GPG_KEY }}
11274
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
11375
- id: collect_assets

.meta/requirements-build.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
py-make>=0.1.0
22
twine
3-
wheel
3+
build

.pre-commit-config.yaml

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ default_language_version:
22
python: python3
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.4.0
5+
rev: v5.0.0
66
hooks:
77
- id: check-added-large-files
88
- id: check-case-conflict
@@ -35,10 +35,11 @@ repos:
3535
additional_dependencies:
3636
- pytest-timeout
3737
- argopt
38+
- pyyaml
3839
- tabulate
3940
- tqdm
4041
- repo: https://github.com/PyCQA/flake8
41-
rev: 5.0.4
42+
rev: 7.1.1
4243
hooks:
4344
- id: flake8
4445
args: [-j8]
@@ -48,14 +49,15 @@ repos:
4849
- flake8-comprehensions
4950
- flake8-debugger
5051
- flake8-isort
52+
- flake8-pyproject
5153
- flake8-string-format
5254
- repo: https://github.com/google/yapf
53-
rev: v0.32.0
55+
rev: v0.40.2
5456
hooks:
5557
- id: yapf
5658
args: [-i]
5759
additional_dependencies: [toml]
5860
- repo: https://github.com/PyCQA/isort
59-
rev: 5.12.0
61+
rev: 5.13.2
6062
hooks:
6163
- id: isort

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11-alpine
1+
FROM python:3.12-alpine
22
RUN apk update && apk add --no-cache git
33
COPY dist/*.whl .
44
RUN pip install -U $(ls *.whl)[full] && rm *.whl

LICENCE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
* files: *
2-
MPLv2.0 2016-2023 (c) Casper da Costa-Luis
2+
MPLv2.0 2016-2024 (c) Casper da Costa-Luis
33
[casperdcl](https://github.com/casperdcl).
44

55

Makefile

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# IMPORTANT: for compatibility with `python setup.py make [alias]`, ensure:
1+
# IMPORTANT: for compatibility with `python -m pymake [alias]`, ensure:
22
# 1. Every alias is preceded by @[+]make (eg: @make alias)
33
# 2. A maximum of one @make alias or command per line
44
# see: https://github.com/tqdm/py-make/issues/1
@@ -29,7 +29,7 @@
2929
run
3030

3131
help:
32-
@python setup.py make -p
32+
@python -m pymake -p
3333

3434
alltests:
3535
@+make testcoverage
@@ -51,8 +51,7 @@ pytest:
5151

5252
testsetup:
5353
@make gitfame/git-fame.1
54-
python setup.py check --metadata --restructuredtext --strict
55-
python setup.py make none
54+
@make help
5655

5756
testcoverage:
5857
@make coverclean
@@ -91,29 +90,26 @@ coverclean:
9190
@+python -c "import shutil; shutil.rmtree('gitfame/__pycache__', True)"
9291
clean:
9392
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('*.py[co]')]"
94-
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('gitfame/*.py[co]')]"
95-
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('gitfame/*.c')]"
96-
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('gitfame/*.so')]"
9793
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('tests/*.py[co]')]"
94+
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('gitfame/*.py[co]')]"
9895
toxclean:
9996
@+python -c "import shutil; shutil.rmtree('.tox', True)"
10097

10198
install:
102-
python setup.py install
99+
python -m pip install .
103100
install_dev:
104-
python setup.py develop --uninstall
105-
python setup.py develop
101+
python -m pip install -e .
106102
install_build:
107103
python -m pip install -r .meta/requirements-build.txt
108104

109105
build:
110106
@make prebuildclean
111107
@make testsetup
112-
python setup.py sdist bdist_wheel
113-
# python setup.py bdist_wininst
108+
python -m build
109+
python -m twine check dist/*
114110

115111
pypi:
116-
twine upload dist/*
112+
python -m twine upload dist/*
117113

118114
buildupload:
119115
@make build

gitfame/_gitfame.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -480,13 +480,15 @@ def main(args=None):
480480
log.debug(args)
481481
if args.manpath is not None:
482482
import sys
483-
from os import path
484-
from shutil import copyfile
483+
from pathlib import Path
485484

486-
from pkg_resources import resource_filename
487-
fi = resource_filename(__name__, 'git-fame.1')
488-
fo = path.join(args.manpath, 'git-fame.1')
489-
copyfile(fi, fo)
485+
try: # py<3.9
486+
import importlib_resources as resources
487+
except ImportError:
488+
from importlib import resources
489+
fi = resources.files('gitfame') / 'git-fame.1'
490+
fo = Path(args.manpath) / 'git-fame.1'
491+
fo.write_bytes(fi.read_bytes())
490492
log.info("written:%s", fo)
491493
sys.exit(0)
492494

gitfame/_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def Max(it, empty_default=0):
113113
try:
114114
return max(it)
115115
except ValueError as e:
116-
if 'empty sequence' in str(e):
116+
if 'empty' in str(e):
117117
return empty_default
118118
raise # pragma: no cover
119119

0 commit comments

Comments
 (0)